/* ── Sidebar : état actif ─────────────────────────────────── */
.nav-btn.actif {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

/* ── Champs de formulaire ─────────────────────────────────── */
.form-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
}

.form-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 0.625rem;
  font-size: 0.875rem;
  color: #1e293b;
  background: #fff;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.form-input:focus {
  border-color: #6B2D3E;
  box-shadow: 0 0 0 3px rgba(107,45,62,0.1);
}

/* ── Badges couleur (tableau + stats) ─────────────────────── */
.badge {
  display: inline-block;
  padding: 0.18rem 0.55rem;
  border-radius: 5px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.badge-rouge { background:#fee2e2; color:#991b1b; }
.badge-blanc { background:#fef9c3; color:#854d0e; }
.badge-rose  { background:#fce7f3; color:#9d174d; }
.badge-bulles{ background:#dbeafe; color:#1e40af; }
.badge-autre { background:#f1f5f9; color:#475569; }

/* ── Barres du dashboard (CSS) ────────────────────────────── */
.barre-rouge        { background: #b91c1c; }
.barre-blanc        { background: #ca8a04; }
.barre-rosé         { background: #db2777; }
.barre-effervescent { background: #2563eb; }
.barre-autre        { background: #94a3b8; }
.barre-default      { background: #6B2D3E; }

/* ── Tri des colonnes du tableau ──────────────────────────── */
th[data-sort]::after        { content:" ↕"; opacity:0.3; font-size:0.7em; }
th[data-sort].tri-asc::after  { content:" ↑"; opacity:1; }
th[data-sort].tri-desc::after { content:" ↓"; opacity:1; }

/* ── Tableau "Ma Cave" : design amélioré ───────────────────── */
.table-cave-wrap { max-height: 68vh; overflow-y: auto; }
.table-cave thead th {
  position: sticky; top: 0; z-index: 5;
  transition: background-color 0.12s;
}
.table-cave thead th:hover { background: #5a2535; }
.table-cave thead th.tri-asc, .table-cave thead th.tri-desc { background: #5a2535; color: #fde9ee; }
.table-cave tbody tr { transition: background-color 0.1s; }
.table-cave tbody tr:nth-child(even) { background: #fbfaf9; }
.table-cave tbody tr:hover { background: #fdf2f4; }

/* ── Chart.js : conteneurs canvas ────────────────────────── */
.chart-card { display: flex; flex-direction: column; }
.canvas-wrap-sm { position:relative; height:200px; }
.canvas-wrap-md { position:relative; height:260px; }
.canvas-wrap-lg { position:relative; height:320px; }

/* Carte de France : hauteur CSS explicite — jamais un pourcentage ambigu ni un
   ratio deviné en JS, pour ne jamais rogner la carte quelle que soit la fenêtre. */
.carte-conteneur { width:100%; height:70vh; min-height:420px; max-height:760px; }
@media (max-width: 640px) {
  .carte-conteneur { height:52vh; min-height:300px; }
}

/* ── Donut : centre + légende HTML ────────────────────────── */
.donut-centre-val { font-size:1.5rem; font-weight:800; fill:#1e293b; }
.donut-centre-lbl { font-size:0.68rem; font-weight:600; letter-spacing:0.06em;
                    text-transform:uppercase; fill:#94a3b8; }
html.dark .donut-centre-val { fill:#f1f5f9; }
html.dark .donut-centre-lbl { fill:#64748b; }
.donut-legende {
  display:flex; flex-wrap:wrap; justify-content:center;
  column-gap:1.1rem; row-gap:0.45rem; margin-top:0.9rem;
}
.donut-legende-item { display:inline-flex; align-items:center; gap:0.4rem; font-size:0.75rem; }
.donut-legende-dot  { width:0.6rem; height:0.6rem; border-radius:9999px; flex-shrink:0; }
.donut-legende-lbl  { color:#475569; font-weight:600; }
.donut-legende-val  { color:#94a3b8; font-variant-numeric:tabular-nums; }
html.dark .donut-legende-lbl { color:#cbd5e1; }
html.dark .donut-legende-val { color:#64748b; }
.card-titre  { font-size:0.82rem; font-weight:700; color:#6B2D3E; margin-bottom:0.9rem; }
.section-titre {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  margin: 1.5rem 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid #f1f5f9;
}

/* ── Dropdown export ──────────────────────────────────────── */
.dropdown-menu {
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.dropdown-menu.ouvert {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

/* ── Toast notifications ──────────────────────────────────── */
.notif-toast {
  max-width: min(22rem, calc(100vw - 2rem));
  padding: 0.75rem 1.1rem;
  border-radius: 0.875rem;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s ease;
  animation: notifSlideIn 0.2s ease;
}
.notif-toast-sortie { opacity: 0; transform: translateX(12px); }

.notif-erreur {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}
.notif-succes {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

@keyframes notifSlideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

html.dark .notif-erreur { background: #3a1414; color: #fca5a5; border-color: #5c2020; }
html.dark .notif-succes { background: #123420; color: #86efac; border-color: #1e5636; }

/* ── Lignes tableau en retard d'apogée ────────────────────── */
tr.ligne-retard td { background: #fff7f7; }

/* ── Plan de cave : étagères ──────────────────────────────── */
.cave-plan {
  background: #1a0f0a;
  border-radius: 1rem;
  padding: 16px 12px;
  overflow-x: auto;
  box-shadow: inset 0 2px 12px rgba(0,0,0,0.4), 0 4px 20px rgba(0,0,0,0.15);
}
.cave-etagere-row {
  display: flex;
  align-items: stretch;
  margin-bottom: 10px;
}
.cave-etagere-row:last-child { margin-bottom: 0; }

/* Label étagère */
.cave-etagere-label {
  width: 72px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  padding-right: 10px;
  gap: 2px;
}
.cave-etagere-label span {
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #8b7355;
  text-transform: uppercase;
}
.cave-etagere-label small {
  font-size: 0.5rem;
  color: #5c4a35;
}

/* La planche (shelf board) */
.cave-shelf {
  flex: 1;
  position: relative;
}
.cave-shelf-board {
  background: linear-gradient(180deg, #5c3d1e 0%, #3d2512 60%, #2a1a0d 100%);
  height: 6px;
  border-radius: 2px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.5);
  margin-bottom: 6px;
}
.cave-slots {
  display: flex;
  gap: 5px;
  padding: 0 4px 4px;
}

/* Slot individuel */
.cave-slot {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
  flex-shrink: 0;
}

/* Slot vide - trou dans le rayonnage */
.cave-slot-vide {
  background: #0d0704;
  border: 2px dashed #3d2a1a;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.6);
}
.cave-slot-vide:hover {
  border-color: #8b7355;
  background: #1a0f08;
  transform: scale(1.05);
}
.cave-slot-vide::after {
  content: '+';
  color: #5c4a35;
  font-size: 1.1rem;
  font-weight: 300;
  opacity: 0;
  transition: opacity 0.15s;
}
.cave-slot-vide:hover::after { opacity: 1; }

/* Slot occupé */
.cave-slot-occupee {
  box-shadow: 0 2px 8px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.15);
  border: 2px solid rgba(255,255,255,0.1);
}
.cave-slot-occupee:hover {
  transform: scale(1.1) translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.5);
  z-index: 20;
}

/* Glisser-déposer */
.cave-slot-en-cours-glisser { opacity: 0.35; }
.cave-slot-survole {
  outline: 3px dashed #C4913A;
  outline-offset: 2px;
  transform: scale(1.08);
}

/* Couleurs des bouteilles */
.slot-rouge        { background: radial-gradient(circle at 35% 35%, #c0392b, #7b241c); }
.slot-blanc        { background: radial-gradient(circle at 35% 35%, #f7dc6f, #b7950b); }
.slot-rosé         { background: radial-gradient(circle at 35% 35%, #f1948a, #c0392b80); }
.slot-effervescent { background: radial-gradient(circle at 35% 35%, #85c1e9, #2471a3); }
.slot-autre        { background: radial-gradient(circle at 35% 35%, #aab7b8, #616a6b); }

.cave-slot-qte {
  font-size: 0.75rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
  line-height: 1;
}
.cave-slot-lettre {
  font-size: 0.45rem;
  font-weight: 700;
  color: rgba(255,255,255,0.75);
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  max-width: 46px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: center;
  line-height: 1.2;
  margin-top: 1px;
}

/* Slot meuble vitrine (rectangulaire) */
.cave-plan.meuble_vitrine .cave-slot {
  border-radius: 6px;
  width: 60px;
  height: 52px;
}

/* Tooltip */
.cave-slot-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #f8fafc;
  font-size: 0.68rem;
  font-weight: 500;
  padding: 0.4rem 0.65rem;
  border-radius: 8px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 50;
  max-width: 180px;
  white-space: normal;
  text-align: center;
  line-height: 1.4;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.cave-slot-tooltip::after {
  content: '';
  position: absolute;
  top: 100%; left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1e293b;
}
.cave-slot:hover .cave-slot-tooltip { opacity: 1; }

/* Position number badge */
.cave-pos-num {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.45rem;
  font-weight: 700;
  color: #5c4a35;
  letter-spacing: 0.05em;
}

/* ── Recherche vin externe ────────────────────────────────── */
.search-result-card {
  border: 1.5px solid #e2e8f0;
  border-radius: 0.625rem;
  padding: 0.625rem 0.875rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.search-result-card:hover {
  border-color: #6B2D3E;
  background: #fff5f5;
}

/* ── Formulaire : sections ────────────────────────────────── */
.form-section-title {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6B2D3E;
  padding: 0.5rem 0 0.25rem;
  border-bottom: 1.5px solid #fee2e2;
  margin-bottom: 0.5rem;
}

/* Emplacements des graphiques D3 */
.d3-slot { position:absolute; inset:0; }
.canvas-wrap-sm, .canvas-wrap-md, .canvas-wrap-lg { position:relative; }
.d3-slot svg { width:100%; height:100%; }

/* ══ Mode sombre ═══════════════════════════════════════════════════════════
   Surcouche globale (plutôt que des variantes dark: sur chaque élément) :
   plus robuste face au CDN Tailwind qui régénère les classes à la volée. */
html.dark { color-scheme: dark; }

html.dark body { background: #0f1117; color: #e2e8f0; }

/* Cartes, modales, tableaux : tous les fonds blancs deviennent des surfaces sombres */
html.dark .bg-white { background-color: #1a1d27 !important; }
html.dark .bg-slate-50 { background-color: #12141c !important; }
html.dark .bg-slate-100 { background-color: #262a38 !important; }
html.dark .hover\:bg-wine-50\/40:hover { background-color: #2a1e2455 !important; }

/* Bordures */
html.dark .border-slate-100,
html.dark .border-slate-200 { border-color: #2c3040 !important; }
html.dark .divide-slate-50 > * + * { border-color: #262a38 !important; }

/* Textes */
html.dark .text-slate-800 { color: #f1f5f9 !important; }
html.dark .text-slate-700 { color: #e2e8f0 !important; }
html.dark .text-slate-600 { color: #cbd5e1 !important; }
html.dark .text-slate-500 { color: #94a3b8 !important; }
html.dark .text-slate-400 { color: #64748b !important; }
html.dark .text-slate-300 { color: #475569 !important; }
html.dark .text-slate-200 { color: #334155 !important; }

/* Champs de formulaire */
html.dark .form-input {
  background: #12141c;
  border-color: #2c3040;
  color: #e2e8f0;
}
html.dark .form-input:focus { box-shadow: 0 0 0 3px rgba(217,77,108,0.18); }
html.dark .form-input::placeholder { color: #4b5566; }
html.dark .form-label { color: #94a3b8; }
html.dark .form-section-title { color: #e97291; border-bottom-color: #3a2530; }

/* Tableau Ma Cave */
html.dark .table-cave tbody tr:nth-child(even) { background: #1e222e; }
html.dark .table-cave tbody tr:hover { background: #2a1e24; }
html.dark tr.ligne-retard td { background: #2a1418 !important; }

/* Survols & listes */
html.dark .hover\:bg-slate-50:hover { background-color: #262a38 !important; }
html.dark .hover\:border-wine-300:hover { border-color: #8a4a5c !important; }

/* Badges couleur : légèrement assombris pour rester lisibles sur fond sombre */
html.dark .badge-rouge { background:#3a1414; color:#fca5a5; }
html.dark .badge-blanc { background:#3a3014; color:#fde68a; }
html.dark .badge-rose  { background:#3a1428; color:#f9a8d4; }
html.dark .badge-bulles{ background:#142a3a; color:#93c5fd; }
html.dark .badge-autre { background:#262a38; color:#cbd5e1; }

/* Badges de notation millésime (fiche bouteille + dashboard) */
html.dark .bg-slate-100.text-slate-500 { background:#262a38 !important; color:#94a3b8 !important; }
html.dark .bg-amber-50  { background:#3a2e12 !important; }
html.dark .text-amber-600 { color:#fbbf24 !important; }
html.dark .bg-blue-50   { background:#122438 !important; }
html.dark .text-blue-600  { color:#7dd3fc !important; }
html.dark .bg-green-50  { background:#123420 !important; }
html.dark .text-green-700 { color:#86efac !important; }
html.dark .bg-red-50    { background:#3a1414 !important; }
html.dark .text-red-600   { color:#fca5a5 !important; }
html.dark .bg-wine-50   { background:#2a1e24 !important; }
html.dark .text-wine-700  { color:#f3a8b6 !important; }

/* Dropdowns & tooltips */
html.dark .dropdown-menu { background:#1a1d27 !important; border-color:#2c3040 !important; }
html.dark .dropdown-item:hover { background:#262a38 !important; }

/* Graphiques D3 (hors carte de France, qui garde son fond parchemin clair) :
   le fill défini en JS reste dans l'attribut SVG mais une règle CSS le
   surpasse toujours (les attributs de présentation ont la plus faible priorité). */
html.dark .d3-slot svg text { fill: #cbd5e1; }

/* Carte de stockage (déjà sombre par nature) : inchangée dans les deux modes */

/* Scrollbar (Webkit) plus discrète en sombre */
html.dark ::-webkit-scrollbar { width: 10px; height: 10px; }
html.dark ::-webkit-scrollbar-track { background: #12141c; }
html.dark ::-webkit-scrollbar-thumb { background: #2c3040; border-radius: 5px; }

/* ── Matrice des millésimes ─────────────────────────────────────────────── */
.matrice-millesimes-wrap { max-height: 74vh; overflow: auto; }
.matrice-millesimes { border-collapse: separate; border-spacing: 0; width: max-content; }
.matrice-millesimes th, .matrice-millesimes td {
  padding: 6px 8px; text-align: center; white-space: nowrap; border-bottom: 1px solid #f1f5f9;
}
.matrice-millesimes thead th {
  position: sticky; top: 0; z-index: 3; background: #6B2D3E; color: #fff;
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
}
.matrice-millesimes .sticky-col {
  position: sticky; left: 0; z-index: 2; background: #fff; text-align: left; min-width: 130px;
}
.matrice-millesimes thead .sticky-col { z-index: 4; background: #6B2D3E; }
.cellule-millesime {
  width: 30px; color: #fff; font-weight: 700; cursor: pointer; border-radius: 4px;
  transition: transform 0.1s;
}
.cellule-millesime:hover { transform: scale(1.15); position: relative; z-index: 1; }
.cellule-vide { color: #cbd5e1; background: #f8fafc; font-weight: 400; cursor: pointer; }
.cellule-vide:hover { background: #f1f5f9; color: #94a3b8; }

html.dark .matrice-millesimes th, html.dark .matrice-millesimes td { border-bottom-color: #262a38; }
html.dark .matrice-millesimes .sticky-col { background: #1a1d27; color: #e2e8f0; }
html.dark .cellule-vide { background: #12141c; color: #2c3040; }
html.dark .cellule-vide:hover { background: #1e222e; color: #475569; }

/* Boutons d'origine dans la modal dégustation */
.origine-btn { border-color: #e2e8f0; }
html.dark .origine-btn { border-color: #2c3040; }
html.dark .origine-btn.border-wine-600 { border-color: #d94d6c !important; }
html.dark .origine-btn.bg-wine-50 { background: #2a1e24 !important; }
