/* ============================================================
   Cave CellarTracker — Feuille de styles
   Thème sombre, inspiré des caves à vin
   ============================================================ */

:root {
  --bg:          #131210;
  --bg-card:     #1e1b18;
  --bg-card2:    #252220;
  --bg-hover:    #2e2a26;
  --border:      #3a342e;
  --border-light:#4a433c;

  --gold:        #c9a84c;
  --gold-dim:    #8a7030;
  --burgundy:    #7a1e2e;
  --burgundy-l:  #9e2a3d;

  --text:        #e8e0d4;
  --text-dim:    #9a8e80;
  --text-muted:  #6a5e52;

  --red:         #c0392b;
  --orange:      #e67e22;
  --yellow:      #f1c40f;
  --green:       #27ae60;

  --radius:      8px;
  --radius-sm:   4px;
  --shadow:      0 4px 20px rgba(0,0,0,.5);
  --transition:  0.18s ease;
}

/* ---- Thème clair ---- */
[data-theme="light"] {
  --bg:          #f5f2ee;
  --bg-card:     #ffffff;
  --bg-card2:    #f0ece6;
  --bg-hover:    #e8e4dc;
  --border:      #d5cec4;
  --border-light:#c0b8ae;

  --gold:        #8a6d20;
  --gold-dim:    #b08c30;
  --burgundy:    #8a1e30;
  --burgundy-l:  #a42840;

  --text:        #2c2520;
  --text-dim:    #6a5e52;
  --text-muted:  #9a8e80;

  --red:         #c0392b;
  --orange:      #d35400;
  --yellow:      #c29d0b;
  --green:       #1e8449;

  --shadow:      0 4px 20px rgba(0,0,0,.1);
}

[data-theme="light"] #login-screen {
  background: radial-gradient(ellipse at center, #f0e8dd 0%, #e5ddd0 100%);
}

[data-theme="light"] .modal-overlay {
  background: rgba(0,0,0,.35);
}

[data-theme="light"] .rack-cell.filled:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
}

[data-theme="light"] .stat-item.clickable:hover {
  background: rgba(0,0,0,.06);
}

[data-theme="light"] .stat-item.clickable.active {
  background: rgba(0,0,0,.10);
  outline: 1px solid rgba(0,0,0,.20);
}

[data-theme="light"] .loading-overlay {
  background: rgba(255,255,255,.7);
}

[data-theme="light"] .location-select option {
  background: var(--bg-card);
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: var(--border-light);
}

[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
  background: #a8a090;
}

[data-theme="light"] .login-card {
  box-shadow: var(--shadow), 0 0 60px rgba(130, 40, 40, .04);
}

[data-theme="light"] .rack-card:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
}

[data-theme="light"] .error-msg {
  background: rgba(231, 76, 60, .08);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

/* ============================================================
   Écran de connexion
   ============================================================ */

#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: radial-gradient(ellipse at center, #1e1510 0%, #0a0806 100%);
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px;
  width: 380px;
  box-shadow: var(--shadow), 0 0 60px rgba(130, 40, 40, .08);
  text-align: center;
}

.login-logo {
  font-size: 48px;
  margin-bottom: 8px;
}

.login-card h1 {
  font-size: 22px;
  font-weight: 600;
  color: var(--gold);
  margin-bottom: 6px;
  letter-spacing: .3px;
}

.login-card p {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 32px;
}

.form-group {
  margin-bottom: 16px;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  transition: border-color var(--transition);
}

.form-group input:focus {
  border-color: var(--gold-dim);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--burgundy);
  color: #fff;
  width: 100%;
  margin-top: 8px;
  font-size: 15px;
  padding: 13px;
}

.btn-primary:hover { background: var(--burgundy-l); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 7px 14px;
  font-size: 13px;
}

.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #a93226; }

.error-msg {
  color: #e74c3c;
  font-size: 13px;
  margin-top: 14px;
  padding: 10px 14px;
  background: rgba(231, 76, 60, .12);
  border-radius: var(--radius-sm);
  border-left: 3px solid #e74c3c;
}

/* ============================================================
   Layout principal
   ============================================================ */

#app-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ---- Header ---- */
#app-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  height: 56px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.header-logo { font-size: 22px; }

.header-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--gold);
  letter-spacing: .2px;
  white-space: nowrap;
}

.search-wrap {
  flex: 1;
  max-width: 480px;
  position: relative;
}

.search-wrap input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  font-size: 13px;
  padding: 7px 16px 7px 36px;
  outline: none;
  transition: border-color var(--transition);
}

.search-wrap input:focus { border-color: var(--gold-dim); }

.search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.search-clear:hover { color: var(--text); }

.search-wrap .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}

/* Sélecteur de cave */
.location-select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  padding: 6px 10px;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
  white-space: nowrap;
}
.location-select:focus { border-color: var(--gold-dim); }
.location-select option { background: var(--bg-card); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.header-user {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
}

/* ---- Stats bar ---- */
#stats-bar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 8px 20px;
  background: var(--bg-card2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-dim);
  overflow-x: auto;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.stat-item.clickable {
  cursor: pointer;
  border-radius: 6px;
  padding: 4px 8px;
  margin: -4px -8px;
  transition: background 0.15s;
  user-select: none;
}

.stat-item.clickable:hover {
  background: rgba(255,255,255,0.06);
}

.stat-item.clickable.active {
  background: rgba(255,255,255,0.10);
  outline: 1px solid rgba(255,255,255,0.20);
}

.stat-item strong { color: var(--text); font-size: 13px; }

.stat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.stat-dot.red    { background: var(--red); }
.stat-dot.orange { background: var(--orange); }
.stat-dot.yellow { background: var(--yellow); }
.stat-dot.green  { background: var(--green); }

.last-sync { margin-left: auto; font-size: 11px; color: var(--text-muted); }

/* ---- Contenu principal ---- */
#main-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* ============================================================
   Vue : Grille des casiers
   ============================================================ */

.view-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.racks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}

.rack-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: all var(--transition);
}

.rack-card:hover {
  border-color: var(--gold-dim);
  background: var(--bg-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,.4);
}

.rack-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.rack-number {
  font-size: 16px;
  font-weight: 700;
  color: var(--gold);
}

.rack-count {
  font-size: 11px;
  color: var(--text-muted);
}

/* Mini-grille représentant les bouteilles dans le casier */
.rack-mini {
  display: grid;
  gap: 2px;
}

.rack-mini-cell {
  border-radius: 2px;
  aspect-ratio: 1;
}

.rack-mini-cell.empty {
  background: var(--bg);
  border: 1px solid var(--border);
}

/* ============================================================
   Vue : Détail d'un casier
   ============================================================ */

.rack-detail-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.rack-detail-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--gold);
}

.rack-detail-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.rack-grid {
  display: inline-grid;
  gap: 4px;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

.rack-cell {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  transition: all var(--transition);
  overflow: hidden;
}

.rack-cell.empty {
  background: var(--bg);
  border: 1px dashed var(--border);
  cursor: default;
}

.rack-cell.filled {
  border: 2px solid transparent;
}

.rack-cell.filled:hover {
  filter: brightness(1.25);
  transform: scale(1.1);
  z-index: 2;
  box-shadow: 0 4px 16px rgba(0,0,0,.6);
}

/* Indicateurs d'urgence sur les cellules */
.rack-cell.urgency-red    { border-color: var(--red) !important; }
.rack-cell.urgency-orange { border-color: var(--orange) !important; }
.rack-cell.urgency-yellow { border-color: var(--yellow) !important; }

/* Label de colonne/rangée */
.rack-axis-label {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text-muted);
  width: 40px;
  height: 20px;
}

/* ============================================================
   Vue : Résultats de recherche
   ============================================================ */

.search-results-header {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 14px;
}

.search-results-header strong { color: var(--text); }

.bottle-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bottle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  cursor: pointer;
  transition: all var(--transition);
}

.bottle-row:hover {
  border-color: var(--gold-dim);
  background: var(--bg-hover);
}

.bottle-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.bottle-info { flex: 1; min-width: 0; }

.bottle-wine {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bottle-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 1px;
}

.bottle-location {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  text-align: right;
}

.urgency-badge {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.urgency-badge.red    { background: var(--red); box-shadow: 0 0 6px var(--red); }
.urgency-badge.orange { background: var(--orange); }
.urgency-badge.yellow { background: var(--yellow); }
.urgency-badge.green  { background: var(--green); }

/* Cellules grisées lors d'une recherche */
.rack-cell.dimmed {
  opacity: 0.1;
  filter: grayscale(100%);
  cursor: default;
  pointer-events: none;
}
.rack-mini-cell.dimmed {
  opacity: 0.08;
  filter: grayscale(100%);
}
.rack-card.faded { opacity: 0.35; }

/* Casiers Pyla — fond légèrement doré/sablé */
.rack-card--pyla {
  background: rgba(180, 140, 50, 0.10);
  border-color: rgba(200, 160, 70, 0.35);
}
.rack-card--pyla:hover {
  background: rgba(180, 140, 50, 0.18);
  border-color: rgba(220, 180, 80, 0.55);
}

/* Séparateur de ligne pleine largeur avant les casiers Pyla */
.rack-grid-break {
  grid-column: 1 / -1;
  border-top: 1px solid var(--border);
  margin: 8px 0 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: .5px;
}
.rack-grid-break::before {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Badge de correspondance sur les cartes casier */
.match-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 10px;
  background: var(--gold-dim);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}

/* Résultats de recherche intégrés sous les casiers */
.search-results-section {
  margin-top: 28px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

/* ============================================================
   Section bouteilles sans emplacement
   ============================================================ */
.unlocated-section {
  margin-top: 28px;
}

/* Groupes par statut dans la section sans emplacement */
.status-group {
  margin-bottom: 20px;
}

.status-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.status-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-dim);
}

.status-group-count {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 8px;
}

/* ============================================================
   Modal — Détail d'une bouteille
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  backdrop-filter: blur(4px);
  animation: fadeIn .15s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 500px;
  box-shadow: var(--shadow);
  animation: slideUp .2s ease;
  max-height: 90vh;
  overflow-y: auto;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
  padding: 20px 20px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.modal-wine-name {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  flex: 1;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 0 0 0 8px;
  flex-shrink: 0;
  transition: color var(--transition);
}

.modal-close:hover { color: var(--text); }

.modal-producer {
  padding: 4px 20px 0;
  font-size: 13px;
  color: var(--gold);
}

.modal-body {
  padding: 16px 20px 20px;
}

.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.tag {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.tag.vintage {
  background: var(--bg-card2);
  color: var(--gold);
  border-color: var(--gold-dim);
  font-size: 13px;
}

.tag.appellation { color: var(--text); }

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 20px;
  margin-bottom: 18px;
}

.modal-field label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 2px;
}

.modal-field span {
  font-size: 13px;
  color: var(--text);
}

/* Barre de fenêtre de consommation */
.consume-bar-wrap { grid-column: 1 / -1; }

.consume-bar-wrap label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 6px;
}

.consume-bar {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
}

.consume-fill {
  height: 100%;
  border-radius: 3px;
  position: absolute;
}

.consume-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* Urgency banner */
.urgency-banner {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.urgency-banner.red    { background: rgba(192, 57, 43, .2);  color: #e74c3c; border-left: 3px solid var(--red); }
.urgency-banner.orange { background: rgba(230, 126, 34, .15); color: #e67e22; border-left: 3px solid var(--orange); }
.urgency-banner.yellow { background: rgba(241, 196, 15, .1);  color: #f1c40f; border-left: 3px solid var(--yellow); }
.urgency-banner.green  { background: rgba(39, 174, 96, .1);   color: #2ecc71; border-left: 3px solid var(--green); }

/* Formulaire de consommation */
.drink-form {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-top: 4px;
}

.drink-form h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 12px;
}

.drink-form .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.drink-form .form-group { margin-bottom: 10px; }

.drink-form input,
.drink-form textarea {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  padding: 8px 12px;
  outline: none;
  transition: border-color var(--transition);
  font-family: inherit;
  resize: vertical;
}

.drink-form input:focus,
.drink-form textarea:focus { border-color: var(--gold-dim); }

.drink-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.modal-footer {
  padding: 0 20px 20px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ============================================================
   Loading spinner
   ============================================================ */

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
  gap: 16px;
  color: var(--text-dim);
  font-size: 14px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Scrollbar
   ============================================================ */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ============================================================
   Utilities
   ============================================================ */

/* ---- Theme toggle ---- */
.theme-toggle {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-dim);
  font-size: 16px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  padding: 0;
  line-height: 1;
}

.theme-toggle:hover {
  background: var(--bg-hover);
  border-color: var(--gold-dim);
  color: var(--text);
}

/* ============================================================
   Menu burger (gauche) + dropdown
   ============================================================ */

.burger-menu-wrap {
  position: relative;
  flex-shrink: 0;
}

.burger-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 36px;
  height: 36px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  padding: 0;
  transition: all var(--transition);
}

.burger-btn:hover {
  background: var(--bg-hover);
  border-color: var(--gold-dim);
}

.burger-btn.active {
  background: var(--gold-dim);
  border-color: var(--gold);
}

.burger-line {
  display: block;
  width: 16px;
  height: 2px;
  background: var(--text-dim);
  border-radius: 1px;
  transition: all 0.2s ease;
}

.burger-btn:hover .burger-line { background: var(--text); }
.burger-btn.active .burger-line { background: #fff; }

/* Dropdown menu */
.burger-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 220px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
  z-index: 200;
  padding: 6px 0;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.burger-dropdown.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.burger-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition);
}

.burger-menu-item:hover {
  background: var(--bg-hover);
}

.burger-menu-item.active {
  color: var(--gold);
  background: rgba(201,168,76,.08);
}

.burger-menu-item-icon {
  font-size: 15px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.burger-menu-item-label {
  flex: 1;
}

.burger-menu-item-arrow {
  color: var(--text-muted);
  font-size: 16px;
  font-weight: 300;
  margin-left: auto;
}

/* Thème clair */
[data-theme="light"] .burger-dropdown {
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
}

/* ============================================================
   Volet latéral droit (domaines)
   ============================================================ */

.side-panel {
  position: fixed;
  top: 56px;   /* hauteur du header */
  right: 0;
  bottom: 0;
  width: 320px;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  z-index: 50;
  display: flex !important;  /* toujours flex, jamais none — la transition gère la visibilité */
  flex-direction: column;
  box-shadow: -4px 0 20px rgba(0,0,0,.3);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  pointer-events: none;
}

.side-panel.open {
  transform: translateX(0);
  pointer-events: auto;
}

/* Quand le panel est ouvert, décaler le contenu principal */
#main-content {
  transition: margin-right 0.25s ease;
}

.side-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.side-panel-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--gold);
  letter-spacing: .2px;
}

.side-panel-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color var(--transition);
}

.side-panel-close:hover { color: var(--text); }

.side-panel-search-wrap {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.side-panel-search-wrap input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text);
  font-size: 12px;
  padding: 6px 14px;
  outline: none;
  transition: border-color var(--transition);
}

.side-panel-search-wrap input:focus { border-color: var(--gold-dim); }

.side-panel-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

.producer-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background var(--transition);
  font-size: 13px;
}

.producer-item:hover {
  background: var(--bg-hover);
}

.producer-item.active {
  background: rgba(201, 168, 76, 0.12);
  border-right: 3px solid var(--gold);
}

.producer-item-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.producer-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.producer-item.active .producer-item-name {
  color: var(--gold);
  font-weight: 600;
}

.producer-item-count {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 7px;
}

/* Thème clair — ajustements volet */
[data-theme="light"] .side-panel {
  box-shadow: -4px 0 20px rgba(0,0,0,.08);
}

[data-theme="light"] .producer-item.active {
  background: rgba(138, 109, 32, 0.08);
}

[data-theme="light"] .burger-btn.active {
  background: var(--gold);
}
[data-theme="light"] .burger-menu-item:hover {
  background: rgba(0,0,0,.05);
}

.hidden { display: none !important; }
.text-dim { color: var(--text-dim); }
.text-gold { color: var(--gold); }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }

/* ============================================================
   Wizard "Ranger une caisse"
   ============================================================ */

.storage-wizard {
  max-width: 720px;
  width: 92vw;
}

.wizard-step-label {
  margin: 0 0 12px;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
}

.wizard-success-flash {
  padding: 10px 14px;
  background: rgba(39, 174, 96, .15);
  border-left: 3px solid #27ae60;
  border-radius: 4px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #b9efd0;
  animation: flashIn .3s ease;
}
@keyframes flashIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.wizard-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-dim);
  font-style: italic;
}

.wizard-info {
  padding: 10px 12px;
  background: rgba(255, 255, 255, .04);
  border-left: 3px solid var(--gold);
  border-radius: 4px;
  margin: 10px 0;
  font-size: 13px;
  color: var(--text-dim);
}

.wizard-error {
  padding: 10px 12px;
  background: rgba(192, 57, 43, .12);
  border-left: 3px solid #c0392b;
  border-radius: 4px;
  margin: 10px 0;
  color: #ffb4ab;
  font-size: 13px;
}

.wizard-warn {
  padding: 10px 12px;
  background: rgba(230, 126, 34, .12);
  border-left: 3px solid #e67e22;
  border-radius: 4px;
  margin: 10px 0;
  color: #ffd0a3;
  font-size: 13px;
}

.wizard-summary {
  padding: 10px 14px;
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 14px;
  line-height: 1.5;
}

.wizard-field {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 0;
}

.wizard-field > label {
  font-size: 12px;
  color: var(--text-dim);
  min-width: 80px;
  flex-shrink: 0;
}

.wizard-field-stacked {
  display: block;
}
.wizard-field-stacked > label {
  display: block;
  margin-bottom: 6px;
}

.wizard-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  color: var(--text);
  font-size: 14px;
  width: 80px;
}

.wizard-help {
  margin-left: 8px;
  color: var(--text-dim);
  font-size: 13px;
}

/* Liste de vins pending — étape 1 */
.wizard-search-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 14px;
  margin-bottom: 10px;
  box-sizing: border-box;
}
.wizard-search-input:focus {
  outline: none;
  border-color: var(--gold);
}

.wizard-search-count {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 8px;
  letter-spacing: .03em;
}

.wizard-wine-list-wrap {
  display: flex;
  flex-direction: column;
}

.wizard-wine-list {
  max-height: 55vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wizard-wine-item {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  cursor: pointer;
  color: var(--text);
  transition: background .15s;
}
.wizard-wine-item:hover {
  background: rgba(255, 255, 255, .08);
}

.wizard-wine-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.wizard-wine-text {
  flex: 1;
  min-width: 0;
}
.wizard-wine-line1 {
  font-weight: 600;
  font-size: 13px;
}
.wizard-wine-line2 {
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wizard-wine-count {
  font-size: 12px;
  color: var(--gold);
  background: rgba(138, 109, 32, .12);
  padding: 3px 8px;
  border-radius: 12px;
  flex-shrink: 0;
  font-weight: 600;
}

/* Pills lieu / casier */
.wizard-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.wizard-pill {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 5px 12px;
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
  transition: all .15s;
}
.wizard-pill:hover:not(.full) {
  border-color: var(--gold);
  color: var(--gold);
}
.wizard-pill.active {
  background: var(--gold);
  border-color: var(--gold);
  color: #1a1410;
  font-weight: 600;
}
.wizard-pill.full {
  opacity: .35;
  cursor: not-allowed;
}

.wizard-rack-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 56px;
  padding: 6px 10px;
}
.wizard-rack-num { font-weight: 600; }
.wizard-rack-fill { font-size: 11px; opacity: .75; margin-top: 2px; }
.wizard-rack-row { max-height: 200px; overflow-y: auto; }

.wizard-new-rack {
  border-style: dashed;
  color: var(--gold);
  background: transparent;
}
.wizard-new-rack:hover {
  background: rgba(138, 109, 32, .12);
  border-color: var(--gold);
  border-style: solid;
}

/* Mini-grille de sélection de la position de départ */
.wizard-label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin: 14px 0 6px;
}

.wizard-rack-grid {
  display: grid;
  gap: 2px;
  margin: 6px 0 12px;
  width: fit-content;     /* la grille ne s'étire plus à toute la largeur du modal */
  max-width: 100%;
  overflow-x: auto;
}

.wizard-rack-hdr, .wizard-rack-corner {
  font-size: 10px;
  color: var(--text-dim);
  text-align: center;
  padding: 0 3px;
  line-height: 22px;
  min-width: 14px;
}

.wizard-cell {
  width: 22px;
  height: 22px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  padding: 0;
  box-sizing: border-box;
  transition: all .1s;
}
.wizard-cell:hover:not(.occupied) {
  background: rgba(138, 109, 32, .25);
  border-color: var(--gold);
}
.wizard-cell.occupied {
  background: rgba(192, 57, 43, .35);
  cursor: not-allowed;
  border-color: rgba(192, 57, 43, .5);
}
.wizard-cell.start {
  background: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(138, 109, 32, .4);
}

/* Preview de la séquence */
.wizard-preview {
  margin: 14px 0;
  padding: 12px;
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.wizard-preview h4 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--gold);
}

.wizard-preview-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 200px;
  overflow-y: auto;
  font-size: 13px;
  font-family: 'SF Mono', Menlo, monospace;
}
.wizard-preview-list li {
  padding: 3px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.wizard-preview-bin {
  background: rgba(138, 109, 32, .15);
  color: var(--gold);
  padding: 1px 6px;
  border-radius: 3px;
  min-width: 70px;
  font-weight: 600;
}
.wizard-preview-arrow { color: var(--text-dim); }
.wizard-preview-bottle { color: var(--text-dim); }

.wizard-skipped {
  margin-top: 10px;
  padding: 8px 10px;
  background: rgba(241, 196, 15, .12);
  border-left: 3px solid #f1c40f;
  border-radius: 4px;
  font-size: 12px;
  color: #ffe8a3;
}

/* Navigation */
.wizard-nav {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.wizard-btn {
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all .15s;
}
.wizard-btn:hover:not([disabled]) {
  border-color: var(--gold);
  color: var(--gold);
}
.wizard-btn.primary {
  background: var(--gold);
  border-color: var(--gold);
  color: #1a1410;
}
.wizard-btn.primary:hover:not([disabled]) {
  filter: brightness(1.1);
}
.wizard-btn[disabled] {
  opacity: .4;
  cursor: not-allowed;
}

/* Thème clair — ajustements wizard */
[data-theme="light"] .wizard-pill.active {
  color: #fff;
}
[data-theme="light"] .wizard-btn.primary {
  color: #fff;
}
[data-theme="light"] .wizard-cell.occupied {
  background: rgba(192, 57, 43, .18);
}

/* ============================================================
   Panier — sélection multiple + actions
   ============================================================ */

/* Bouton panier dans le header */
.cart-btn {
  position: relative;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.cart-btn .cart-count {
  display: inline-block;
  background: var(--gold);
  color: #1a1410;
  font-weight: 700;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}
.cart-btn.has-items {
  border-color: var(--gold);
  color: var(--gold);
}

/* Toggle mode panier (dans rack-detail) */
.cart-mode-toggle {
  margin-left: auto;
  font-size: 12px;
}
.cart-mode-toggle.active {
  background: var(--gold);
  color: #1a1410;
  border-color: var(--gold);
}

.rack-detail-title-wrap {
  flex: 1;
  min-width: 0;
}

/* Cellules en mode panier */
.rack-cell.filled.cart-mode {
  cursor: pointer;
  outline: 1px dashed transparent;
}
.rack-cell.filled.cart-mode:hover {
  outline-color: var(--gold);
}
.rack-cell.filled.in-cart {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
  box-shadow: 0 0 8px rgba(138, 109, 32, .6);
}
.rack-cell.filled.in-cart::after {
  content: '🛒';
  position: absolute;
  bottom: 1px;
  left: 1px;
  font-size: 9px;
  pointer-events: none;
}

/* Modale panier */
.cart-modal { max-width: 600px; width: 92vw; }

.cart-list {
  max-height: 50vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.cart-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
}

.cart-item-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cart-item-text {
  flex: 1;
  min-width: 0;
}
.cart-item-line1 {
  font-weight: 600;
  font-size: 13px;
}
.cart-item-line2 {
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cart-item-bin {
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 11px;
  color: var(--gold);
  background: rgba(138, 109, 32, .12);
  padding: 2px 6px;
  border-radius: 3px;
  flex-shrink: 0;
}

.cart-item-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
  flex-shrink: 0;
}
.cart-item-remove:hover { color: #c0392b; }

.cart-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
