/* ===========================================
   GESTIOLEX - Command Palette / Ricerca Globale
   Stile Spotlight/VS Code
   =========================================== */

/* ===========================================
   OVERLAY
   =========================================== */
.command-palette-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.command-palette-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* ===========================================
   CONTAINER PRINCIPALE
   =========================================== */
.command-palette {
  position: fixed;
  top: 15%;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  width: 90%;
  max-width: 600px;
  max-height: 70vh;
  background: white;
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25),
              0 0 0 1px rgba(0, 0, 0, 0.05);
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.command-palette.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

/* ===========================================
   HEADER / INPUT RICERCA
   =========================================== */
.command-palette-header {
  padding: 16px;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
  border-radius: 12px 12px 0 0;
}

.command-palette-input-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.command-palette-icon {
  font-size: 1.25rem;
  color: #6b7280;
  flex-shrink: 0;
}

.command-palette-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 1.1rem;
  color: #111827;
  outline: none;
  padding: 0;
}

.command-palette-input::placeholder {
  color: #9ca3af;
}

.command-palette-shortcut {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.command-palette-shortcut kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  font-size: 0.75rem;
  font-family: inherit;
  font-weight: 500;
  color: #6b7280;
  background: #e5e7eb;
  border-radius: 4px;
  border: 1px solid #d1d5db;
}

/* ===========================================
   CORPO / RISULTATI
   =========================================== */
.command-palette-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

/* Sezione categoria */
.command-palette-section {
  padding: 8px 16px 4px;
}

.command-palette-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

/* Griglia per azioni rapide (2 colonne) */
.command-palette-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 0 8px;
}

.command-palette-grid .command-palette-item {
  padding: 8px 12px;
  border-radius: 6px;
}

/* Singolo item */
.command-palette-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background-color 0.1s ease;
  text-decoration: none;
  color: inherit;
}

.command-palette-item:hover {
  background-color: #f3f4f6;
}

.command-palette-item.selected {
  background-color: #e0f2fe;
  outline: 2px solid #0B5E70;
  outline-offset: -2px;
}

.command-palette-item.selected {
  background-color: #e0f2fe;
}

.command-palette-item-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  background: #f3f4f6;
  border-radius: 8px;
  flex-shrink: 0;
}

/* Colori icone per tipo */
.command-palette-item-icon.action {
  background: #dbeafe;
  color: #2563eb;
}

.command-palette-item-icon.pratica {
  background: #fef3c7;
  color: #d97706;
}

.command-palette-item-icon.persona {
  background: #d1fae5;
  color: #059669;
}

.command-palette-item-icon.fattura {
  background: #fce7f3;
  color: #db2777;
}

.command-palette-item-icon.email {
  background: #e0e7ff;
  color: #4f46e5;
}

.command-palette-item-icon.nav {
  background: #f3f4f6;
  color: #6b7280;
}

.command-palette-item-icon.evento {
  background: #fef3c7;
  color: #b45309;
}

.command-palette-item-content {
  flex: 1;
  min-width: 0;
}

.command-palette-item-title {
  font-size: 0.9rem;
  font-weight: 500;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.command-palette-item-subtitle {
  font-size: 0.75rem;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.command-palette-item-badge {
  flex-shrink: 0;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: #e5e7eb;
  color: #4b5563;
}

/* Hint tastiera per item selezionato */
.command-palette-item-hint {
  flex-shrink: 0;
  font-size: 0.7rem;
  color: #9ca3af;
  opacity: 0;
  transition: opacity 0.1s;
}

.command-palette-item.selected .command-palette-item-hint {
  opacity: 1;
}

/* ===========================================
   FOOTER
   =========================================== */
.command-palette-footer {
  padding: 10px 16px;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
  border-radius: 0 0 12px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: #6b7280;
}

.command-palette-footer-hints {
  display: flex;
  align-items: center;
  gap: 16px;
}

.command-palette-footer-hint {
  display: flex;
  align-items: center;
  gap: 4px;
}

.command-palette-footer-hint kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  font-size: 0.65rem;
  font-family: inherit;
  font-weight: 500;
  color: #6b7280;
  background: white;
  border-radius: 3px;
  border: 1px solid #d1d5db;
}

/* ===========================================
   STATO VUOTO / LOADING
   =========================================== */
.command-palette-empty {
  padding: 40px 20px;
  text-align: center;
  color: #6b7280;
}

.command-palette-empty-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.5;
}

.command-palette-empty-text {
  font-size: 0.9rem;
}

.command-palette-loading {
  padding: 40px 20px;
  text-align: center;
  color: #6b7280;
}

.command-palette-loading i {
  font-size: 1.5rem;
  animation: spin 1s linear infinite;
}

/* ===========================================
   TRIGGER BUTTON (opzionale nella navbar)
   =========================================== */
.command-palette-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.command-palette-trigger:hover {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

.command-palette-trigger kbd {
  font-size: 0.7rem;
  padding: 2px 5px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* ===========================================
   HIGHLIGHT TESTO RICERCA
   =========================================== */
.command-palette-highlight {
  background: #fef08a;
  color: #854d0e;
  border-radius: 2px;
  padding: 0 2px;
}

/* ===========================================
   ANIMAZIONI
   =========================================== */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ===========================================
   RESPONSIVE
   =========================================== */
@media (max-width: 640px) {
  .command-palette {
    top: 10%;
    width: 95%;
    max-height: 80vh;
  }
  
  .command-palette-header {
    padding: 12px;
  }
  
  .command-palette-input {
    font-size: 1rem;
  }
  
  .command-palette-shortcut {
    display: none;
  }
  
  .command-palette-item {
    padding: 12px;
  }
  
  .command-palette-footer-hints {
    display: none;
  }
}

/* ===========================================
   DARK MODE (per futuro)
   =========================================== */
@media (prefers-color-scheme: dark) {
  /* Placeholder per dark mode futuro */
}
