/* ══════════════════════════════════════════════════════════
   COBREAD'S & CUPCUP'S CORNER — Design System v2
   Thème : Cuisine Moderne
   Appliqué à toutes les pages via <link rel="stylesheet" href="/design-system.css">
   ══════════════════════════════════════════════════════════ */

/* ─── RESET ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

/* ─── VARIABLES GLOBALES ─── */
:root {
  /* Layout */
  --max:       860px;
  --nav-h:     64px;
  --radius:    16px;
  --radius-sm: 10px;
  --radius-xs: 8px;

  /* Couleurs de fond */
  --bg:         #F8F8F6;
  --surface:    #FFFFFF;
  --surface-2:  #F4F4F2;

  /* Bordures */
  --border:        #EBEBEA;
  --border-strong: #D8D8D6;

  /* Texte */
  --text:   #1A1A18;
  --text-2: #6A6A68;
  --text-3: #A8A8A4;

  /* Accent Recettes — Vert Olive */
  --accent:       #3D5A3E;
  --accent-mid:   #527554;
  --accent-light: #EBF2EB;

  /* Accent Vins — Bordeaux */
  --accent-vin:       #6B3A5A;
  --accent-vin-mid:   #8A4D74;
  --accent-vin-light: #F5EAF3;

  /* Typographies */
  --font-body:    'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Plus Jakarta Sans', 'DM Sans', -apple-system, sans-serif;

  /* Ombres */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.07);
  --shadow-lg: 0 8px 28px rgba(0,0,0,0.09);
}

/* ─── BASE ─── */
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100svh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
}

/* ══════════════════════════════════════════════════════════
   HEADER — Structure commune à toutes les pages
   ══════════════════════════════════════════════════════════ */
.header {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg); padding: 0 16px;
}

.header-card {
  background: var(--surface);
  border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 12px 16px 10px;
  max-width: var(--max); margin: 0 auto;
  box-shadow: var(--shadow-sm);
}

/* Ligne top : logo + actions */
.header-top {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 10px;
}

/* Logo (pages principales) */
.header-logo {
  display: flex; align-items: center; gap: 9px;
}

.header-logo-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 17px; font-weight: 800; flex-shrink: 0;
  letter-spacing: -0.5px;
}

.header-logo-text {
  font-family: var(--font-display);
  font-size: 19px; font-weight: 800; font-style: normal;
  color: var(--text); letter-spacing: -0.5px; line-height: 1.1;
}

.header-logo-sub {
  font-size: 10px; color: var(--text-3);
  font-family: var(--font-body); font-style: normal; font-weight: 400;
  letter-spacing: 0.3px;
}

/* Titre de page (pages secondaires) */
.header-page-titre {
  display: flex; align-items: center; gap: 10px; flex: 1;
}

.header-back-btn {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border);
  cursor: pointer; display: flex; align-items: center;
  justify-content: center; color: var(--text-2); flex-shrink: 0;
  transition: background 0.15s;
}
.header-back-btn:hover { background: var(--border); }

.header-titre-txt {
  font-size: 15px; font-weight: 600; color: var(--text);
  flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Actions côté droit */
.header-actions {
  display: flex; align-items: center; gap: 6px;
}

/* Bouton icône générique */
.btn-icon {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border);
  cursor: pointer; display: flex; align-items: center;
  justify-content: center; color: var(--text-2);
  text-decoration: none; transition: background 0.15s;
  font-size: 14px;
}
.btn-icon:hover { background: var(--border); }
.btn-icon svg { pointer-events: none; }

/* Barre de recherche */
.recherche-row { display: flex; gap: 8px; margin-bottom: 10px; }

.recherche-wrap { position: relative; flex: 1; }

.icone-recherche {
  position: absolute; left: 11px; top: 50%;
  transform: translateY(-50%); color: var(--text-3); pointer-events: none;
}

.btn-clear-recherche {
  position: absolute; right: 10px; top: 50%;
  transform: translateY(-50%); color: var(--text-3);
  cursor: pointer; background: none; border: none;
  font-size: 16px; padding: 0; line-height: 1; display: none;
}
.btn-clear-recherche.visible { display: block; }

.champ-recherche, #champ-recherche {
  width: 100%; height: 36px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0 32px 0 34px;
  font-size: 14px; color: var(--text); outline: none;
  font-family: var(--font-body); transition: border-color 0.15s, box-shadow 0.15s;
}
.champ-recherche::placeholder, #champ-recherche::placeholder { color: var(--text-3); }
.champ-recherche:focus, #champ-recherche:focus {
  border-color: var(--accent-mid);
  box-shadow: 0 0 0 3px rgba(61,90,62,0.10);
}

/* Bouton tri */
.btn-tri {
  height: 36px; padding: 0 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 12px; font-weight: 500;
  color: var(--text-2); cursor: pointer; white-space: nowrap;
  display: flex; align-items: center; gap: 5px;
  font-family: var(--font-body); transition: all 0.15s; flex-shrink: 0;
}
.btn-tri.actif { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }
.btn-tri svg { transition: transform 0.2s; }
.btn-tri.asc svg { transform: scaleY(-1); }

/* Dropdown tri */
.tri-wrap { position: relative; }
.tri-dropdown {
  position: absolute; top: calc(100% + 6px); right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px;
  box-shadow: var(--shadow-lg); z-index: 200;
  min-width: 190px; display: none;
}
.tri-dropdown.visible { display: block; }
.tri-option {
  padding: 9px 12px; border-radius: var(--radius-xs); cursor: pointer;
  font-size: 13px; color: var(--text-2); transition: all 0.12s;
  display: flex; align-items: center; gap: 8px;
}
.tri-option:hover { background: var(--surface-2); color: var(--text); }
.tri-option.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.tri-option-icone { font-size: 15px; width: 20px; text-align: center; }

/* Pills / filtres catégorie */
.cats { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.filtres-row { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.filtres-row::-webkit-scrollbar { display: none; }

.cat-pill, .filtre-pill {
  flex-shrink: 0; padding: 5px 13px; border-radius: 40px;
  font-size: 12px; font-weight: 500; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); transition: all 0.15s; white-space: nowrap;
}
.cat-pill:hover, .filtre-pill:hover { border-color: var(--accent-mid); color: var(--accent); }
.cat-pill.active, .filtre-pill.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
}

/* Pills vins */
.filtre-pill.active[data-filtre="rouge"],
.filtre-pill.active[data-filtre="blanc"],
.filtre-pill.active[data-filtre="rosé"],
.filtre-pill.active[data-filtre="mousseux"],
.filtre-pill.active[data-filtre="fortifié"] {
  background: var(--accent-vin); border-color: var(--accent-vin);
}
.filtre-pill:hover[data-groupe="type"] { border-color: var(--accent-vin-mid); color: var(--accent-vin); }

.cats-header {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 6px;
}
.cats-label {
  font-size: 10px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.8px;
}
.cats-reset {
  font-size: 11px; color: var(--accent); cursor: pointer;
  font-weight: 500; display: none;
}
.cats-reset.visible { display: block; }

/* Badge filtre actif */
.barre-contexte {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; gap: 8px;
}
.section-label {
  font-size: 11px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.8px;
}
.filtres-actifs-badges { display: flex; gap: 4px; flex-wrap: wrap; }
.badge-filtre {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px;
  background: var(--accent-light); color: var(--accent);
  font-size: 11px; font-weight: 500; cursor: pointer;
  border: 1px solid rgba(61,90,62,0.2);
}
.badge-filtre::after { content: '×'; font-size: 13px; opacity: 0.6; }

/* ══════════════════════════════════════════════════════════
   NAV BAS — Nav 2 : pill active, unifié sur toutes les pages
   ══════════════════════════════════════════════════════════ */
.nav-bas {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: var(--bg); padding: 0 16px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  -webkit-transform: translateZ(0); transform: translateZ(0);
}

.nav-bas-card {
  max-width: var(--max); margin: 0 auto;
  background: var(--surface); border: 1px solid var(--border);
  border-bottom: none; border-radius: var(--radius) var(--radius) 0 0;
  display: flex; justify-content: space-around;
  height: var(--nav-h); gap: 4px; padding: 6px 8px 0;
}

.nav-item {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; cursor: pointer;
  text-decoration: none; flex: 1; padding: 5px 4px;
  border-radius: 12px; transition: background 0.15s;
}
.nav-item.active { background: var(--accent-light); }

.nav-icone { font-size: 18px; line-height: 1; }
@media (max-width: 380px) { .nav-icone { font-size: 16px; } .nav-label { font-size: 9px !important; } }

.nav-label {
  font-size: 10px; font-weight: 500; color: var(--text-3);
  font-family: var(--font-body);
}
.nav-item.active .nav-label { color: var(--accent); font-weight: 600; }

/* ══════════════════════════════════════════════════════════
   CONTENUS COMMUNS
   ══════════════════════════════════════════════════════════ */
.contenu { max-width: var(--max); margin: 14px auto 0; padding: 0 16px; }

/* Spinner */
.chargement { display: flex; justify-content: center; padding: 60px; }
.spinner-wrap { display: flex; justify-content: center; padding: 60px; }
.spinner {
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* État vide */
.etat-vide {
  display: none; flex-direction: column; align-items: center;
  padding: 70px 24px; text-align: center;
}
.etat-vide.visible { display: flex; }
.etat-vide-icone { font-size: 52px; margin-bottom: 16px; animation: float 3s ease-in-out infinite; }
@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-6px)} }
.etat-vide-titre {
  font-family: var(--font-display); font-size: 18px;
  font-weight: 600; margin-bottom: 8px; font-style: italic; color: var(--text);
}
.etat-vide-sous { font-size: 13px; color: var(--text-2); line-height: 1.6; }

/* Carte surface générique */
.surface-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 10px;
}

/* Grille 2 colonnes */
.grille { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Animation entrée cartes */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.grille .carte:nth-child(1)  { animation: fadeUp 0.3s ease both 0.00s; }
.grille .carte:nth-child(2)  { animation: fadeUp 0.3s ease both 0.03s; }
.grille .carte:nth-child(3)  { animation: fadeUp 0.3s ease both 0.06s; }
.grille .carte:nth-child(4)  { animation: fadeUp 0.3s ease both 0.09s; }
.grille .carte:nth-child(5)  { animation: fadeUp 0.3s ease both 0.12s; }
.grille .carte:nth-child(6)  { animation: fadeUp 0.3s ease both 0.15s; }
.grille .carte:nth-child(n+7){ animation: fadeUp 0.3s ease both 0.18s; }

/* ── DESKTOP ── */
@media (min-width: 768px) {
  .header { padding: 0 24px; }
  .header-card { padding: 14px 24px 12px; }
  .contenu { padding: 0 24px; margin-top: 18px; }
  .nav-bas { padding: 0 24px; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .grille { grid-template-columns: repeat(3, 1fr); gap: 14px; }
}
@media (min-width: 1100px) {
  :root { --max: 1060px; }
  .grille { grid-template-columns: repeat(4, 1fr); }
}
