:root {
  --blue-1: #3c6091;
  --blue-2: #1e3a5f;
  --bg: #f6f8fb;
  --text: #2f3640;
  --muted: #6b7280;
  --card: #fff;
  --bd: #e8edf3;
  --chip-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --chip-in-ms: 900ms;
  --chip-out-ms: 800ms;
  --chip-reorder-ms: 1800ms;
  --chip-reorder-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --chip-close-ms: 1400ms;
  --chip-close-ease: cubic-bezier(0.16, 1, 0.3, 1);
}

body {
  background: var(--bg);
  padding-top: 4rem;
}

/* Fix navbar z-index pour la page assistant */
.navbar {
  z-index: 1030 !important;
}

/* Hero section */
.assistant-hero {
  position: relative;
  padding: 0;
  text-align: center;
  margin-top: -4rem; /* Compense le padding-top du body */
}

.assistant-hero .hero-bg {
  background: linear-gradient(135deg, var(--blue-1) 0%, var(--blue-2) 100%);
  height: 220px;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: -1;
}

@media (min-width: 992px) {
  .assistant-hero .hero-bg {
    height: 260px;
  }
}

.assistant-hero .hero-inner {
  position: relative;
  padding: 6rem 0 2rem 0;
  display: grid;
  justify-items: center;
}

/* Hero titles */
.hero-title {
  color: #ffffff !important;
  font-weight: 700;
  margin: 0 0 1rem 0;
  font-size: clamp(1.75rem, 2.5vw + 1rem, 2.5rem);
  line-height: 1.2;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.hero-subtitle {
  color: #f8fafc !important;
  font-size: clamp(1rem, 0.8vw + 0.75rem, 1.125rem);
  line-height: 1.4;
  margin-bottom: 3rem !important;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Search bar */
.search-nl {
  max-width: 720px;
  margin: 0 auto;
}

.search-nl .input-group {
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 16px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.06);
  overflow: hidden;
  flex-wrap: nowrap; /* Force une seule ligne */
}

.search-nl .input-group-text {
  background: transparent;
  border: none;
  color: var(--blue-1);
  padding: 0.75rem 1rem;
  flex-shrink: 0; /* Empêche la compression */
}

.search-nl .form-control {
  border: none;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  flex: 1; /* Prend l'espace disponible */
  min-width: 0; /* Permet la compression du texte */
}

.search-nl .form-control:focus {
  box-shadow: none;
  outline: none;
}

.search-nl .btn {
  background: linear-gradient(135deg, var(--blue-1), var(--blue-2));
  border: none;
  color: white;
  padding: 0.75rem 1.5rem;
  font-weight: 600;
  flex-shrink: 0; /* Empêche la compression */
  white-space: nowrap; /* Empêche le retour à la ligne du texte */
}

.search-nl .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(60, 96, 145, 0.25);
}

/* Cards */
.cardx {
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 18px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.06);
  transition: all 0.2s ease;
}

.cardx:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
}

.cardx-head {
  padding: 18px 18px 0px 18px;
  position: relative;
}

.cardx-head::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--blue-1) 0%, var(--blue-2) 100%);
}

/* Card titles */
.cardx-head h2 {
  font-size: clamp(1.1rem, 0.6vw + 0.9rem, 1.35rem);
  line-height: 1.3;
  margin: 0 0 14px 0;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--bd);
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cardx-head h2 i {
  color: var(--blue-1);
}

.cardx-body {
  padding: 18px;
}

/* Chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--bd);
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  margin: 0.25rem;
  background: var(--card);
  transition: transform var(--chip-in-ms) var(--chip-ease), opacity var(--chip-in-ms) var(--chip-ease), background 300ms ease, box-shadow 300ms ease, border-color 300ms ease, margin var(--chip-in-ms) var(--chip-ease), padding var(--chip-in-ms) var(--chip-ease), max-width var(--chip-in-ms) var(--chip-ease), max-height var(--chip-in-ms) var(--chip-ease), border-width var(--chip-in-ms) var(--chip-ease);
  font-size: 0.9rem;
  max-width: 1000px; /* permet le collapse en douceur */
  max-height: 60px;  /* idem */
  will-change: transform, opacity, max-width, max-height;
}

.chip:hover {
  background: #f4f7fb;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.chip.active {
  background: linear-gradient(135deg, var(--blue-1), var(--blue-2));
  color: #fff;
  border-color: var(--blue-1);
  box-shadow: 0 4px 12px rgba(60, 96, 145, 0.25);
}

.chip.chip-disabled {
  opacity: 0.45;
  filter: grayscale(0.2);
  cursor: not-allowed;
}

.chip.chip-disabled:hover {
  transform: none;
  background: var(--card);
  box-shadow: none;
}

/* Entrée en douceur */
.chip-enter {
  opacity: 0;
  transform: translateY(4px) scale(0.94);
  max-width: 0;
  max-height: 0;
  margin: 0;
  padding-left: 0;
  padding-right: 0;
  border-width: 0;
}
.chip-enter:not(.chip-exit) {
  opacity: 1;
  transform: translateY(0) scale(1);
  max-width: 1000px;
  max-height: 60px;
}

/* Sortie en douceur */
.chip-exit {
  opacity: 0;
  transform: translateY(4px) scale(0.94);
  max-width: 0;
  max-height: 0;
  margin: 0;
  padding-left: 0;
  padding-right: 0;
  border-width: 0;
}

/* Transition dédiée au réagencement (FLIP) */
.chip.reorder-anim {
  transition: transform var(--chip-reorder-ms) var(--chip-reorder-ease), opacity 220ms ease;
}

@media (prefers-reduced-motion: reduce) {
  .chip {
    transition: none !important;
  }
  .chip-enter,
  .chip-exit {
    transition: none !important;
  }
  .chip.reorder-anim {
    transition: none !important;
  }
}

.chips-wrap {
  margin-top: 0.5rem;
}

/* Animation de redimensionnement du conteneur de chips */
.chips-wrap.sizing { overflow: hidden; }
.chips-wrap.sizing-open { transition: height var(--chip-reorder-ms) var(--chip-reorder-ease); }
.chips-wrap.sizing-close { transition: height var(--chip-close-ms) var(--chip-close-ease); }

/* Quick cards */
.card-quick {
  border: 1px solid var(--bd);
  border-radius: 12px;
  padding: 1rem;
  transition: 0.2s;
  height: 100%;
  cursor: pointer;
  background: var(--card);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100px;
}

.card-quick:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.06);
  border-color: var(--blue-1);
}

.card-quick.active {
  border-color: var(--blue-1);
  box-shadow: 0 0 0 2px rgba(39, 128, 227, 0.15);
  background: linear-gradient(135deg, rgba(60, 96, 145, 0.05), rgba(30, 58, 95, 0.03));
}

.card-quick .fw-semibold {
  font-size: 0.95rem;
  line-height: 1.3;
  margin-bottom: 0.5rem;
}

.card-quick .small {
  font-size: 0.8rem;
}

.card-quick .badge {
  font-size: 0.75rem;
  align-self: flex-start;
  margin-top: auto;
}

/* Result box */
.result-box {
  border: 1px dashed #ced4da;
  border-radius: 12px;
  padding: 1.5rem;
  background: #f8f9fa;
}

/* Result main code */
.result-code {
  font-size: clamp(1.1rem, 0.8vw + 0.9rem, 1.6rem);
  line-height: 1.25;
  font-weight: 700;
  color: var(--blue-1);
  margin-bottom: 0.5rem;
}

.result-label {
  color: var(--muted);
  margin-bottom: 1rem;
}

.result-why {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.result-actions {
  margin-top: 1rem;
}

.btnx {
  background: linear-gradient(135deg, var(--blue-1), var(--blue-2));
  color: #fff;
  border: none;
  padding: 10px 14px;
  border-radius: 12px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: 0.2s ease;
  font-weight: 600;
}

.btnx:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(60, 96, 145, 0.25);
  color: #fff;
}

.btnx.ghost {
  background: #fff;
  color: #0f172a;
  border: 1px solid var(--bd);
}

.btnx.ghost:hover {
  background: #f4f7fb;
  color: #0f172a;
}

/* Alternatives */
.alt-item {
  border-left: 3px solid var(--bd);
  padding: 0.75rem;
  margin: 0.25rem 0;
  transition: all 0.2s ease;
}

.alt-content {
  flex: 1;
  margin-right: 1rem;
}

.alt-item:hover {
  border-left-color: var(--blue-1);
  background: rgba(60, 96, 145, 0.05);
  border-radius: 0 8px 8px 0;
}

/* Form controls */
.form-control {
  border: 1px solid var(--bd);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  transition: all 0.2s ease;
}

.form-control:focus {
  border-color: var(--blue-1);
  box-shadow: 0 0 0 3px rgba(60, 96, 145, 0.1);
}

.form-label {
  color: #0f172a;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

/* List group (scopé pour ne pas impacter le menu offcanvas) */
.list-group:not(.list-group-flush) {
  border: 1px solid var(--bd);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.list-group:not(.list-group-flush) .list-group-item {
  border: none;
  border-bottom: 1px solid var(--bd);
  padding: 0.75rem 1rem;
  transition: all 0.2s ease;
}

.list-group:not(.list-group-flush) .list-group-item:last-child {
  border-bottom: none;
}

.list-group:not(.list-group-flush) .list-group-item:hover {
  background: #f4f7fb;
  cursor: pointer;
}

.list-group:not(.list-group-flush) .list-group-item.active {
  background: linear-gradient(135deg, rgba(60, 96, 145, 0.1), rgba(30, 58, 95, 0.08));
  color: var(--blue-1);
  font-weight: 600;
}

/* Neutraliser explicitement dans l'offcanvas mobile */
.offcanvas .list-group {
  border: none;
  border-radius: 0;
  box-shadow: none;
}
.offcanvas .list-group-item {
  border: none;
  border-bottom: 1px solid var(--bd);
}

/* Alert */
.alert {
  border: none;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.alert-warning {
  background: linear-gradient(135deg, #fff3cd, #ffeaa7);
  color: #856404;
  border-left: 4px solid #ffc107;
}

.alert .d-flex {
  align-items: center;
}

.alert i {
  color: #ffc107;
  font-size: 1.1rem;
}

/* Responsive */
/* Aligner les règles mobiles pour ne pas écraser clamp() */
@media (max-width: 768px) {
  .assistant-hero .hero-bg {
    height: 280px;
  }
  
  .assistant-hero .hero-inner {
    padding: 5.5rem 0 1.75rem 0;
  }
  
  .hero-title { font-size: clamp(1.75rem, 2.5vw + 1rem, 2.5rem); }
  .hero-subtitle { font-size: clamp(1rem, 0.8vw + 0.75rem, 1.125rem); }
  .result-code { font-size: clamp(1.1rem, 0.8vw + 0.9rem, 1.6rem); }
  
  /* Barre de recherche mobile */
  .search-nl .input-group {
    flex-direction: row; /* Force l'orientation horizontale */
    flex-wrap: nowrap; /* Force une seule ligne */
  }
  
  .search-nl .form-control {
    font-size: 16px; /* Évite le zoom sur iOS */
    padding: 0.75rem 0.5rem; /* Réduit le padding */
  }
  
  .search-nl .btn {
    padding: 0.75rem 1rem; /* Réduit le padding du bouton */
    font-size: 0.9rem; /* Réduit la taille de la police */
  }
  
  .cardx-body {
    padding: 1rem;
  }
  
  .result-box {
    padding: 1rem;
  }
  
  #quickBases {
    grid-template-columns: repeat(2, 1fr) !important; /* Forcer 2 colonnes sur mobile/tablette */
    gap: 0.75rem;
  }
  
  #scenariosGrid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
  
  .card-quick {
    padding: 0.75rem;
  }
  
  .card-quick .fw-semibold {
    font-size: 0.9rem;
  }
  
  .card-quick .small {
    font-size: 0.75rem;
  }
}

@media (max-width: 576px) {
  .assistant-hero .hero-bg {
    height: 320px;
  }
  
  .assistant-hero .hero-inner {
    padding: 5rem 0 1.25rem 0;
  }
  
  /* Barre de recherche très petits écrans */
  .search-nl .input-group {
    flex-direction: row;
    flex-wrap: nowrap;
  }
  
  .search-nl .form-control {
    font-size: 16px;
    padding: 0.5rem 0.25rem; /* Padding encore plus réduit */
  }
  
  .search-nl .btn {
    padding: 0.5rem 0.75rem; /* Padding encore plus réduit */
    font-size: 0.85rem;
  }
  
  #quickBases {
    grid-template-columns: repeat(2, 1fr) !important; /* Forcer 2 colonnes sur petits mobiles */
    gap: 0.5rem;
  }
  
  #scenariosGrid {
    grid-template-columns: 1fr; /* Une seule colonne sur très petits écrans */
    gap: 0.5rem;
  }
}

/* Loading states */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

.spinner-border {
  color: var(--blue-1);
}

/* Interpretation area */
#interpretation {
  min-height: 1.5rem;
  padding: 0.5rem;
  border-radius: 8px;
  background: rgba(60, 96, 145, 0.05);
  border-left: 3px solid var(--blue-1);
  display: none; /* Masqué par défaut */
}

#interpretation:not(:empty) {
  display: block; /* Affiché seulement quand il y a du contenu */
}

/* Selected base display */
#selectedBaseDisplay {
  padding: 0.75rem;
  background: linear-gradient(135deg, rgba(60, 96, 145, 0.1), rgba(30, 58, 95, 0.08));
  border-radius: 12px;
  border: 1px solid rgba(60, 96, 145, 0.2);
  margin-top: 0.5rem;
}

/* Quick bases grid */
#quickBases {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.quick-bases-more {
  grid-column: 1 / -1; /* occupe toute la ligne */
  display: flex;
  justify-content: center;
}

/* Scenarios grid */
#scenariosGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state h4 {
  margin-bottom: 0.5rem;
  color: #0f172a;
}

/* Empty state dans les cards */
.cardx-body .empty-state {
  padding: 2rem 1rem;
}

.cardx-body .empty-state i {
  font-size: 2.5rem;
}

.cardx-body .empty-state h4 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.cardx-body .empty-state p {
  font-size: 0.9rem;
  margin-bottom: 0;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.content-fade-in {
  animation: fadeIn 0.3s ease-out;
}

/* Toast notifications */
.toast-container {
  z-index: 9999;
}

.toast-notification {
  background: #fff;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 1rem;
  margin-bottom: 0.5rem;
  min-width: 300px;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex;
  align-items: center;
}

.toast-notification.show {
  transform: translateX(0);
}

.toast-notification.success {
  border-left: 4px solid #28a745;
}

.toast-notification.error {
  border-left: 4px solid #dc3545;
}

.toast-content {
  display: flex;
  align-items: center;
  width: 100%;
}

.toast-icon {
  margin-right: 0.75rem;
  font-size: 1.2rem;
}

.toast-notification.success .toast-icon {
  color: #28a745;
}

.toast-notification.error .toast-icon {
  color: #dc3545;
}

.toast-message {
  flex: 1;
  font-weight: 500;
  color: #2c3e50;
}
