/* ════════════════════════════════════════════════════════════════════════════
   Boutique — style Apple (App Store / apple.com)
   Blanc, near-black #1D1D1F, icônes vectorielles SF-like, bleu Apple discret.
   Clair + sombre selon le système. Aucun emoji, aucune fioriture.
   ════════════════════════════════════════════════════════════════════════════ */

:root {
  --bg:          #F5F5F7;   /* gris très clair apple.com */
  --bg-elevated: #FFFFFF;
  --card-bg:     #FFFFFF;
  --row-active:  #EBEBED;
  --text:        #1D1D1F;   /* near-black Apple */
  --text-2:      #6E6E73;   /* gris secondaire */
  --text-3:      #AEAEB2;
  --separator:   rgba(0,0,0,0.10);
  --fill:        rgba(0,0,0,0.05);   /* champs / chips */
  --accent:      #0071E3;   /* bleu apple.com */
  --danger:      #E5342B;
  --success:     #1A9E4B;
  --warning:     #C9740A;
  --nav-bg:      rgba(245,245,247,0.80);
  --shadow:      0 2px 14px rgba(0,0,0,0.06);

  --radius:      14px;
  --radius-lg:   18px;
  --header-h:    52px;
  --nav-h:       64px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #000000;
    --bg-elevated: #1C1C1E;
    --card-bg:     #1C1C1E;
    --row-active:  #2C2C2E;
    --text:        #F5F5F7;
    --text-2:      #98989D;
    --text-3:      #5A5A5E;
    --separator:   rgba(255,255,255,0.12);
    --fill:        rgba(255,255,255,0.09);
    --accent:      #2997FF;
    --danger:      #FF453A;
    --success:     #30D158;
    --warning:     #FF9F0A;
    --nav-bg:      rgba(20,20,20,0.80);
    --shadow:      0 0 0 0.5px rgba(255,255,255,0.10);  /* fin liseré pour détacher du noir */
  }
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
               system-ui, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

input, textarea, button, select { font-family: inherit; font-size: inherit; color: inherit; }
img { display: block; max-width: 100%; }
button { background: none; border: none; cursor: pointer; }

/* ── Icônes vectorielles (SF-like) ─────────────────────────────────────────── */
.ic {
  width: 24px; height: 24px; display: block;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.ic-sm { width: 18px; height: 18px; }

/* ── App shell ─────────────────────────────────────────────────────────────── */
#app { display: flex; flex-direction: column; min-height: 100vh; max-width: 520px; margin: 0 auto; position: relative; }

/* ── Barre de navigation ───────────────────────────────────────────────────── */
#header {
  position: fixed; top: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 520px; height: var(--header-h);
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--separator);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 0 6px; z-index: 100;
}
.header-left { display: flex; align-items: center; justify-self: start; }
#header-title { grid-column: 2; font-size: 17px; font-weight: 600; letter-spacing: -0.2px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-btn { justify-self: end; }

.icon-btn {
  color: var(--accent);
  padding: 8px; min-width: 40px; min-height: 40px;
  display: flex; align-items: center; justify-content: center; position: relative; border-radius: 50%;
}
.icon-btn:active { opacity: 0.4; }
.icon-btn.hidden { visibility: hidden; pointer-events: none; }

.badge {
  position: absolute; top: 1px; right: 1px;
  background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 600; border-radius: 999px;
  min-width: 17px; height: 17px; padding: 0 4px;
  display: flex; align-items: center; justify-content: center; line-height: 1; pointer-events: none;
}
.badge.hidden { display: none; }

/* ── Contenu ───────────────────────────────────────────────────────────────── */
#main { padding-top: var(--header-h); padding-bottom: var(--nav-h); flex: 1; overflow-x: hidden; }
.page { display: none; min-height: calc(100vh - var(--header-h) - var(--nav-h)); }
.page.active { display: block; }

/* ── Grand titre (style apple.com) ─────────────────────────────────────────── */
.store-hero { padding: 14px 20px 6px; }
.store-hero-eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.6px; text-transform: uppercase; color: var(--text-2); margin-bottom: 2px; }
.store-hero-title { font-size: 32px; font-weight: 700; letter-spacing: -0.6px; line-height: 1.08; }
.store-hero-tag, .store-hero-badge { display: none; }

/* ── Recherche ─────────────────────────────────────────────────────────────── */
.search-bar { padding: 8px 16px; }
.search-field { display: flex; align-items: center; gap: 8px; background: var(--fill); border-radius: 11px; padding: 9px 12px; }
.search-ic { color: var(--text-2); flex-shrink: 0; }
.search-field input { flex: 1; border: none; background: none; outline: none; font-size: 17px; color: var(--text); }
.search-field input::placeholder { color: var(--text-2); }

/* ── Filtres ───────────────────────────────────────────────────────────────── */
.catalog-toolbar { display: flex; align-items: center; gap: 8px; padding: 2px 16px 6px; }
.category-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 6px 0; flex: 1; scrollbar-width: none; -ms-overflow-style: none;
  -webkit-mask-image: linear-gradient(to right, #000 86%, transparent);
  mask-image: linear-gradient(to right, #000 86%, transparent); }
.category-tabs::-webkit-scrollbar { display: none; }
.cat-tab { padding: 7px 15px; border-radius: 999px; border: none; background: var(--fill); color: var(--text); font-size: 15px; font-weight: 500; white-space: nowrap; flex-shrink: 0; }
.cat-tab:active { opacity: 0.6; }
.cat-tab.active { background: var(--text); color: var(--bg); }
.sort-select { flex-shrink: 0; padding: 6px 6px; border: none; background: transparent; color: var(--accent); font-size: 15px; font-weight: 500; outline: none; }

/* ── Grille produits ───────────────────────────────────────────────────────── */
.product-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; padding: 10px 16px 16px; }
.product-card { background: var(--card-bg); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); transition: opacity 0.15s ease; }
.product-card:active { opacity: 0.7; }
.card-img { width: 100%; aspect-ratio: 1; overflow: hidden; background: var(--fill); position: relative; }
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.img-placeholder { width: 100%; height: 100%; background: var(--fill); display: flex; align-items: center; justify-content: center; aspect-ratio: 1; color: var(--text-3); }
.img-placeholder .ic { width: 34px; height: 34px; stroke-width: 1.4; }
.img-placeholder .mono { font-size: 40px; font-weight: 600; letter-spacing: -1px; color: var(--text-2); }
.cart-img .img-placeholder .mono { font-size: 22px; }
.product-detail-img .img-placeholder .mono { font-size: 76px; }
.card-body { padding: 11px 13px 14px; }
.card-name { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 3px; }
.card-price { font-size: 15px; font-weight: 600; color: var(--text); }
.out-of-stock { font-size: 13px; color: var(--danger); margin-top: 2px; }

/* ── Skeleton ──────────────────────────────────────────────────────────────── */
.skeleton { pointer-events: none; }
.skeleton-img { width: 100%; aspect-ratio: 1; background: var(--fill); animation: pulse 1.5s ease-in-out infinite; }
.skeleton-body { padding: 11px 13px 14px; }
.skeleton-line { height: 12px; border-radius: 6px; background: var(--fill); margin-bottom: 8px; animation: pulse 1.5s ease-in-out infinite; }
.skeleton-line.short { width: 55%; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }

.load-more-container { display: flex; justify-content: center; padding: 4px 16px 20px; }
.load-more-container.hidden { display: none; }

/* ── Détail produit ────────────────────────────────────────────────────────── */
.product-detail-img { width: 100%; max-height: 380px; overflow: hidden; background: var(--fill); }
.product-detail-img img { width: 100%; max-height: 380px; object-fit: cover; }
.product-detail-img .img-placeholder { height: 320px; aspect-ratio: unset; }
.product-detail-video { width: 100%; max-height: 380px; background: #000; display: block; }
.product-detail-img .img-placeholder .ic { width: 64px; height: 64px; }
.product-detail-body { padding: 18px 20px 28px; }
.detail-category { font-size: 12px; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; margin-bottom: 6px; }
.detail-name { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; line-height: 1.15; margin-bottom: 6px; }
.detail-price { font-size: 22px; font-weight: 600; margin-bottom: 16px; }
.detail-desc { font-size: 16px; color: var(--text-2); line-height: 1.5; margin-bottom: 20px; }
.detail-stock { font-size: 15px; margin-bottom: 20px; color: var(--text-2); }
.detail-stock.in { color: var(--success); }
.detail-stock.out { color: var(--danger); }

/* ── Variantes ─────────────────────────────────────────────────────────────── */
.variants-section { margin-bottom: 20px; }
.variants-label { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.variants-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.variant-pill { padding: 9px 16px; border-radius: 10px; border: 1px solid var(--separator); background: var(--card-bg); color: var(--text); font-size: 15px; font-weight: 500; }
.variant-pill.selected { background: var(--text); border-color: var(--text); color: var(--bg); }
.variant-pill:disabled { opacity: 0.4; text-decoration: line-through; }

/* ── Boutons ───────────────────────────────────────────────────────────────── */
.btn-primary { background: var(--accent); color: #fff; border-radius: var(--radius); padding: 15px 20px; font-size: 17px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: opacity 0.15s ease; }
.btn-primary:active { opacity: 0.7; }
.btn-primary:disabled { background: var(--text-3); color: #fff; }
.btn-secondary { background: var(--fill); color: var(--accent); border-radius: var(--radius); padding: 13px 18px; font-size: 16px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn-secondary:active { opacity: 0.6; }
.btn-danger { background: none; color: var(--danger); border-radius: 10px; padding: 8px 12px; font-size: 15px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.btn-danger:active { opacity: 0.5; }
.btn-sm { padding: 6px 10px; font-size: 15px; }
.btn-full { width: 100%; }
.btn-add { margin-top: 4px; }
.btn-back { color: var(--accent); font-size: 17px; font-weight: 400; padding: 12px 14px; display: inline-flex; align-items: center; gap: 2px; }
.btn-back .ic { stroke-width: 2; }
.btn-back:active { opacity: 0.5; }

/* ── Panier (liste groupée) ────────────────────────────────────────────────── */
#cart-content { padding: 16px; }
.cart-items { background: var(--card-bg); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.cart-item { display: flex; align-items: center; gap: 12px; padding: 12px; border-bottom: 0.5px solid var(--separator); }
.cart-item:last-child { border-bottom: none; }
.cart-img { width: 58px; height: 58px; border-radius: 10px; overflow: hidden; flex-shrink: 0; background: var(--fill); }
.cart-img img { width: 100%; height: 100%; object-fit: cover; }
.cart-img .img-placeholder { width: 58px; height: 58px; aspect-ratio: unset; }
.cart-img .img-placeholder .ic { width: 24px; height: 24px; }
.cart-info { flex: 1; min-width: 0; }
.cart-item-name { font-size: 16px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 2px; }
.cart-item-price { font-size: 15px; color: var(--text-2); }
.cart-qty { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.qty-btn { width: 30px; height: 30px; border-radius: 50%; background: var(--fill); color: var(--accent); font-size: 19px; font-weight: 500; display: flex; align-items: center; justify-content: center; line-height: 1; }
.qty-btn:active { opacity: 0.5; }
.qty-btn:disabled { opacity: 0.3; }
.cart-qty span { font-size: 17px; font-weight: 600; min-width: 18px; text-align: center; }
.cart-footer { display: flex; align-items: center; justify-content: space-between; padding: 18px 4px 4px; }
.cart-subtotal { font-size: 15px; color: var(--text-2); }
.cart-subtotal strong { color: var(--text); font-size: 17px; font-weight: 600; }

/* ── Formulaire / checkout ─────────────────────────────────────────────────── */
.form-container { padding: 16px; }
.form-container h2 { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; margin-bottom: 18px; }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 7px; }
.form-group input[type="text"], .form-group input[type="tel"], .form-group textarea {
  width: 100%; padding: 13px 14px; border-radius: 11px; border: none;
  background: var(--card-bg); box-shadow: 0 0 0 0.5px var(--separator);
  color: var(--text); font-size: 17px; outline: none; resize: vertical;
}
.form-group input:focus, .form-group textarea:focus { box-shadow: 0 0 0 2px var(--accent); }
.form-group input::placeholder, .form-group textarea::placeholder { color: var(--text-2); }

.promo-row { display: flex; gap: 10px; }
.promo-row input { flex: 1; padding: 13px 14px; border-radius: 11px; border: none; background: var(--card-bg); box-shadow: 0 0 0 0.5px var(--separator); color: var(--text); font-size: 17px; outline: none; }
.promo-row input:focus { box-shadow: 0 0 0 2px var(--accent); }
#promo-result { margin-top: 8px; font-size: 15px; font-weight: 500; min-height: 18px; }
.promo-ok { color: var(--success); }
.promo-err { color: var(--danger); }

/* ── Zones ─────────────────────────────────────────────────────────────────── */
.zone-list { background: var(--card-bg); border-radius: var(--radius); overflow: hidden; box-shadow: 0 0 0 0.5px var(--separator); }
.zone-item { display: flex; justify-content: space-between; align-items: center; padding: 14px; border-bottom: 0.5px solid var(--separator); font-size: 16px; }
.zone-item:last-child { border-bottom: none; }
.zone-item:active { background: var(--row-active); }
.zone-item.selected { color: var(--accent); }
.zone-item.selected::after { content: "✓"; color: var(--accent); font-weight: 700; margin-left: 8px; }
.zone-item strong { font-weight: 600; }
.zone-item.selected strong { color: var(--accent); }

/* ── Récap commande ────────────────────────────────────────────────────────── */
.order-summary { background: var(--card-bg); border-radius: var(--radius); padding: 14px 16px; margin: 18px 0; box-shadow: 0 0 0 0.5px var(--separator); }
.summary-row { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; font-size: 16px; }
.summary-row:not(:last-child) { border-bottom: 0.5px solid var(--separator); }
.summary-row.discount span:last-child { color: var(--success); font-weight: 600; }
.summary-row.total { padding-top: 11px; }
.summary-row.total span { font-size: 19px; font-weight: 700; }

/* ── Commandes ─────────────────────────────────────────────────────────────── */
#orders-content { padding: 16px; }
.order-card { background: var(--card-bg); border-radius: var(--radius); padding: 15px 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.order-card:active { opacity: 0.7; }
.order-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.order-header strong { font-size: 16px; font-weight: 600; }
.order-meta { display: flex; justify-content: space-between; font-size: 15px; color: var(--text-2); }
.order-meta span:last-child { font-weight: 600; color: var(--text); }
.order-zone, .order-eta { font-size: 14px; color: var(--text-2); margin-top: 6px; }
.order-detail { background: var(--card-bg); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.order-detail h3 { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; margin-bottom: 8px; }
.eta-box { background: var(--fill); color: var(--warning); border-radius: 10px; padding: 10px 14px; font-size: 15px; font-weight: 600; margin: 12px 0; display: inline-block; }
.order-items { margin: 14px 0; border-top: 0.5px solid var(--separator); border-bottom: 0.5px solid var(--separator); padding: 8px 0; }
.order-item { display: flex; justify-content: space-between; padding: 6px 0; font-size: 16px; }
.order-item span:last-child { font-weight: 600; flex-shrink: 0; margin-left: 8px; }
.order-totals { padding-top: 6px; }

/* ── Badges de statut ──────────────────────────────────────────────────────── */
.status-badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; }
.status-pending   { background: rgba(201,116,10,0.14);  color: var(--warning); }
.status-confirmed { background: rgba(0,113,227,0.14);   color: var(--accent); }
.status-shipped   { background: rgba(94,92,230,0.16);   color: #5E5CE6; }
.status-delivered { background: rgba(26,158,75,0.16);   color: var(--success); }
.status-cancelled { background: rgba(229,52,43,0.14);   color: var(--danger); }

/* ── Barre d'onglets ───────────────────────────────────────────────────────── */
#bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 520px; height: var(--nav-h);
  background: var(--nav-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--separator);
  display: flex; align-items: stretch; z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 10px; font-weight: 500; color: var(--text-2); }
.nav-btn:active { opacity: 0.5; }
.nav-btn.active { color: var(--accent); }
.nav-icon { position: relative; line-height: 1; }
.nav-ic { width: 26px; height: 26px; stroke-width: 1.6; }
.nav-badge { position: absolute; top: -5px; right: -10px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 600; border-radius: 999px; min-width: 16px; height: 16px; padding: 0 4px; display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
.nav-badge.hidden { display: none; }

/* ── Toast ─────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: calc(var(--nav-h) + 16px); left: 50%; transform: translateX(-50%);
  background: rgba(30,30,30,0.92); color: #fff;
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  padding: 12px 20px; border-radius: 999px;
  font-size: 15px; font-weight: 500; z-index: 999;
  max-width: calc(100vw - 40px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-shadow: 0 8px 30px rgba(0,0,0,0.18); transition: opacity 0.25s ease; pointer-events: none;
}
.toast.hidden { opacity: 0; display: none; }
@media (prefers-color-scheme: dark) { .toast { background: rgba(240,240,240,0.95); color: #000; } }

/* ── États ─────────────────────────────────────────────────────────────────── */
.loading-spinner { text-align: center; padding: 56px 16px; font-size: 16px; color: var(--text-2); }
.empty-state { text-align: center; padding: 64px 24px; color: var(--text-2); font-size: 16px; line-height: 1.6; grid-column: 1 / -1; }
.empty-ic { display: flex; justify-content: center; margin-bottom: 16px; color: var(--text-3); }
.empty-ic .ic { width: 46px; height: 46px; stroke-width: 1.4; }
.empty-state.error, .error-msg { color: var(--danger); text-align: center; padding: 28px 16px; grid-column: 1 / -1; }
.text-muted { color: var(--text-2); font-size: 15px; }

/* ── Portail « glisser pour entrer » ───────────────────────────────────────── */
.gate { position: fixed; inset: 0; z-index: 1000; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 32px; transition: opacity 0.4s ease; }
.gate.hide { opacity: 0; pointer-events: none; }
.gate-inner { width: 100%; max-width: 320px; text-align: center; color: var(--text); }
.gate-logo { width: 52px; height: 52px; margin: 0 auto; color: var(--text); stroke-width: 1.5; }
.gate-title { font-size: 30px; font-weight: 700; letter-spacing: -0.5px; margin-top: 18px; }
.gate-sub { font-size: 16px; color: var(--text-2); margin: 8px 0 34px; }
.slider { --progress: 0; position: relative; height: 58px; border-radius: 999px; background: var(--fill); overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: none; }
.slider-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 52px; background: rgba(0,113,227,0.14); pointer-events: none; }
.slider-label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 500; color: var(--text-2); opacity: calc(1 - var(--progress) * 1.5); pointer-events: none; }
.slider-handle { position: absolute; top: 4px; left: 4px; width: 50px; height: 50px; border-radius: 50%; background: var(--bg-elevated); color: var(--accent); font-size: 22px; font-weight: 600; display: flex; align-items: center; justify-content: center; line-height: 1; box-shadow: 0 2px 8px rgba(0,0,0,0.16); transition: transform 0.25s cubic-bezier(.2,.9,.3,1.15), background 0.2s ease, color 0.2s ease; touch-action: none; }
.slider-handle .ic { width: 24px; height: 24px; stroke-width: 2; }
.slider-handle.grabbing { transition: background 0.2s ease; }
.slider.unlocked .slider-handle { background: var(--success); color: #fff; }

/* ── Divers ────────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
