/* ============================================================
   EQI Budget System — command-palette.css
   Command Palette (A2): Ctrl+K / Cmd+K overlay para busca global
   Depende de: ../styles.css (design tokens)
   ============================================================ */

/* ============================================================
   OVERLAY BACKDROP
   ============================================================ */
.cp-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  background-color: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
}

.cp-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

@supports (backdrop-filter: blur(1px)) {
  .cp-overlay {
    backdrop-filter: blur(4px);
  }
}

/* ============================================================
   DIALOG CONTAINER
   ============================================================ */
.cp-dialog {
  width: 100%;
  max-width: 560px;
  background-color: #fff;
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0, 41, 30, 0.25),
              0 4px 12px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  transform: translateY(-8px) scale(0.98);
  transition: transform 0.15s ease;
}

.cp-overlay.is-open .cp-dialog {
  transform: translateY(0) scale(1);
}

/* ============================================================
   SEARCH INPUT
   ============================================================ */
.cp-input-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border, #D0DCDA);
}

.cp-search-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--text-muted, #5A6A66);
}

.cp-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text-base, #1A1A1A);
  background: transparent;
  line-height: 1.4;
}

.cp-input::placeholder {
  color: var(--text-muted, #5A6A66);
  opacity: 0.7;
}

.cp-kbd {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.4rem;
  font-size: 0.6875rem;
  font-family: inherit;
  font-weight: 500;
  color: var(--text-muted, #5A6A66);
  background-color: var(--surface, #F2EDED);
  border: 1px solid var(--border, #D0DCDA);
  border-radius: 4px;
  line-height: 1;
  flex-shrink: 0;
}

/* ============================================================
   RESULTS LIST
   ============================================================ */
.cp-results {
  max-height: 360px;
  overflow-y: auto;
  padding: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 41, 30, 0.12) transparent;
}

.cp-results::-webkit-scrollbar {
  width: 5px;
}

.cp-results::-webkit-scrollbar-track {
  background: transparent;
}

.cp-results::-webkit-scrollbar-thumb {
  background: rgba(0, 41, 30, 0.12);
  border-radius: 3px;
}

/* Group label */
.cp-group-label {
  padding: 0.5rem 0.75rem 0.25rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted, #5A6A66);
}

/* Result item */
.cp-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.1s ease;
  text-decoration: none;
  color: var(--text-base, #1A1A1A);
}

.cp-item:hover,
.cp-item.is-selected {
  background-color: var(--surface, #F2EDED);
}

.cp-item.is-selected {
  background-color: rgba(0, 158, 118, 0.08);
}

.cp-item-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background-color: var(--surface, #F2EDED);
  color: var(--green-primary, #009E76);
  flex-shrink: 0;
}

.cp-item.is-selected .cp-item-icon {
  background-color: rgba(0, 158, 118, 0.12);
}

.cp-item-icon svg {
  width: 14px;
  height: 14px;
}

.cp-item-text {
  flex: 1;
  min-width: 0;
}

.cp-item-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-base, #1A1A1A);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cp-item-path {
  font-size: 0.6875rem;
  color: var(--text-muted, #5A6A66);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cp-item-enter {
  flex-shrink: 0;
  font-size: 0.6875rem;
  color: var(--text-muted, #5A6A66);
  opacity: 0;
  transition: opacity 0.1s;
}

.cp-item.is-selected .cp-item-enter {
  opacity: 1;
}

/* Empty state */
.cp-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted, #5A6A66);
  font-size: 0.875rem;
}

/* ============================================================
   FOOTER (hint de atalhos)
   ============================================================ */
.cp-footer {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1rem;
  border-top: 1px solid var(--border, #D0DCDA);
  background-color: var(--surface, #F2EDED);
}

.cp-footer-hint {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.6875rem;
  color: var(--text-muted, #5A6A66);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 639px) {
  .cp-overlay {
    padding-top: 5vh;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .cp-dialog {
    max-width: 100%;
  }

  .cp-results {
    max-height: 50vh;
  }
}

/* ============================================================
   ACCESSIBILITY: prefers-reduced-motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .cp-overlay,
  .cp-dialog {
    transition: none;
  }
}

/* ============================================================
   PRINT: esconder
   ============================================================ */
@media print {
  .cp-overlay {
    display: none !important;
  }
}
