/* Boutik'IN — styles adaptés de la démo, responsive + desktop */
:root {
  --bg: #FFF6E9;
  --surface: #FFFFFF;
  --surface-2: #FFFBF3;
  --ink: #1B2A2F;
  --ink-soft: #5B6B64;
  --accent: #E8590C;
  --accent-ink: #FFFFFF;
  --accent-2: #0F7B6C;
  --highlight: #F2B705;
  --line: #E7DAC0;
  --danger: #C43D3D;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(27,42,47,0.08);
  --max-mobile: 480px;
  --max-desktop: 1100px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14201F;
    --surface: #1C2B29;
    --surface-2: #223330;
    --ink: #F3EEDD;
    --ink-soft: #A9BAB2;
    --accent: #FF7A3D;
    --accent-ink: #1B2A2F;
    --accent-2: #3ECBAC;
    --highlight: #F2B705;
    --line: #2C3D3A;
    --danger: #E8746B;
    --shadow: 0 2px 14px rgba(0,0,0,0.35);
  }
}
:root[data-theme="dark"] {
  --bg: #14201F; --surface: #1C2B29; --surface-2: #223330;
  --ink: #F3EEDD; --ink-soft: #A9BAB2; --accent: #FF7A3D;
  --accent-ink: #1B2A2F; --accent-2: #3ECBAC; --line: #2C3D3A;
  --danger: #E8746B; --shadow: 0 2px 14px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
h1, h2, h3, .display { font-family: 'Space Grotesk', system-ui, sans-serif; font-weight: 600; margin: 0; }

.app {
  max-width: var(--max-mobile);
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
@media (min-width: 768px) {
  .app { max-width: var(--max-desktop); }
  .app.desktop-layout { display: grid; grid-template-columns: 240px 1fr; }
}

/* Topbar & nav */
.topbar { padding: 16px 18px 0; }
.platform-tag {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--accent); margin-bottom: 8px;
}
.brand-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.brand-emoji {
  width: 44px; height: 44px; min-width: 44px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; font-size: 24px;
}
.brand-emoji img { width: 100%; height: 100%; object-fit: cover; }
.brand-name { font-size: 18px; }
.brand-sub { font-size: 12px; color: var(--ink-soft); }

.tabs {
  display: flex; background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px; gap: 4px; margin-bottom: 8px;
}
.tab-btn {
  flex: 1; border: none; background: transparent; color: var(--ink-soft);
  font-weight: 600; font-size: 13px; padding: 10px 8px; border-radius: 999px;
  cursor: pointer;
}
.tab-btn.active { background: var(--accent); color: var(--accent-ink); }

/* Side nav desktop */
.side-nav {
  display: none; background: var(--surface); border-right: 1px solid var(--line);
  padding: 20px 12px; min-height: 100vh;
}
@media (min-width: 768px) {
  .side-nav { display: block; }
  .tabs.mobile-only { display: none; }
}
.side-nav a, .side-nav button {
  display: block; width: 100%; text-align: left;
  padding: 10px 12px; border-radius: 10px; border: none;
  background: transparent; color: var(--ink); font-weight: 600;
  font-size: 14px; cursor: pointer; margin-bottom: 4px; text-decoration: none;
}
.side-nav a.active, .side-nav button.active {
  background: var(--accent); color: var(--accent-ink);
}

.screen { padding: 16px 18px 40px; flex: 1; }
.hidden { display: none !important; }

/* Cards & buttons */
.link-card, .track-card, .stat, .order-row, .rank-row, .cust-row, .prod-card, .cat-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.link-card, .track-card { padding: 14px; margin-bottom: 16px; }
.btn {
  border: none; border-radius: 10px; padding: 10px 14px;
  font-weight: 600; font-size: 13.5px; cursor: pointer; white-space: nowrap;
  font-family: inherit;
}
.btn-accent { background: var(--accent); color: var(--accent-ink); }
.btn-outline { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 10px; font-size: 12.5px; border-radius: 8px; }
.btn-ghost { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }

.stats-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 18px;
}
@media (min-width: 768px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}
.stat { padding: 12px 8px; text-align: center; }
.stat .num { font-family: 'Space Grotesk', sans-serif; font-size: 19px; font-weight: 700; }
.stat .label { font-size: 10.5px; color: var(--ink-soft); margin-top: 2px; }

.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 20px 0 10px;
}
.section-head h2 { font-size: 15.5px; }
.section-note { font-size: 11.5px; color: var(--ink-soft); margin: -4px 0 10px; }

/* Products */
.prod-grid, .catalog-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
@media (min-width: 768px) {
  .prod-grid, .catalog-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; }
}
@media (min-width: 1024px) {
  .prod-grid, .catalog-grid { grid-template-columns: repeat(4, 1fr); }
}
.prod-card, .cat-card { overflow: hidden; position: relative; }
.prod-thumb, .cat-thumb {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); font-size: 36px; position: relative;
}
.prod-thumb img, .cat-thumb img { width: 100%; height: 100%; object-fit: contain; }
.prod-body, .cat-body { padding: 9px 10px 10px; }
.prod-name, .cat-name { font-size: 13px; font-weight: 600; }
.prod-price, .cat-price { font-size: 12.5px; color: var(--accent-2); font-weight: 700; margin-top: 2px; }
.old-price { color: var(--ink-soft); text-decoration: line-through; font-size: 11px; margin-right: 3px; }
.promo-badge {
  position: absolute; top: 6px; left: 6px; background: var(--accent); color: var(--accent-ink);
  font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 999px; z-index: 2;
}
.prod-ref, .cat-ref { font-size: 10.5px; color: var(--ink-soft); margin-top: 2px; font-weight: 600; }
.stock-ok { color: var(--ink-soft); } .stock-low { color: var(--accent); } .stock-out { color: var(--danger); }
.prod-actions { display: flex; gap: 6px; margin-top: 8px; }
.prod-actions .btn { flex: 1; padding: 7px 4px; font-size: 11.5px; }
.add-card {
  border: 1.5px dashed var(--line); border-radius: var(--radius); background: transparent;
  color: var(--ink-soft); display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 4px; min-height: 120px; cursor: pointer; font-size: 12.5px; font-weight: 600;
}

/* Orders */
.order-row { padding: 11px 12px; margin-bottom: 8px; }
.order-top { display: flex; justify-content: space-between; gap: 8px; }
.order-customer { font-size: 13.5px; font-weight: 600; }
.order-ref { font-size: 11.5px; font-weight: 600; color: var(--accent-2); }
.order-meta, .order-phone, .order-address { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.order-phone a { color: var(--accent-2); text-decoration: none; font-weight: 600; margin-right: 10px; }
.status-group { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }
.status-btn {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-soft);
  font-size: 11px; font-weight: 700; padding: 10px 6px; min-height: 40px;
  border-radius: 999px; cursor: pointer;
}
.status-btn.active.pending { background: rgba(242,183,5,0.20); color: #A97A00; border-color: transparent; }
.status-btn.active.paid { background: rgba(15,123,108,0.18); color: var(--accent-2); border-color: transparent; }
.status-btn.active.delivered { background: rgba(45,108,223,0.18); color: #2D6CDF; border-color: transparent; }
.status-btn.active.cancelled { background: rgba(196,61,61,0.15); color: var(--danger); border-color: transparent; text-decoration: line-through; }

.rank-row, .cust-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 8px;
}
.rank-num {
  width: 28px; height: 28px; min-width: 28px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--line);
  font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 13px; color: var(--ink-soft);
}
.rank-num.top1 { background: var(--highlight); border-color: transparent; color: #1B2A2F; }
.rank-main { flex: 1; min-width: 0; }
.rank-title { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-sub { font-size: 11.5px; color: var(--ink-soft); margin-top: 2px; }
.rank-side { text-align: right; }
.rank-amount { font-size: 12.5px; font-weight: 700; color: var(--accent-2); }
.rank-bar { height: 4px; border-radius: 999px; background: var(--surface-2); margin-top: 6px; overflow: hidden; }
.rank-bar span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

/* Modal */
.modal-back {
  position: fixed; inset: 0; background: rgba(15,20,20,0.5);
  display: flex; align-items: flex-end; z-index: 50;
}
.modal-back.center { align-items: center; padding: 20px; }
.modal {
  background: var(--surface); width: 100%; max-width: 480px; margin: 0 auto;
  border-radius: 18px 18px 0 0; padding: 20px 18px 26px; max-height: 88vh; overflow-y: auto;
}
.modal-back.center .modal { border-radius: 18px; }
.modal h3 { font-size: 16px; margin-bottom: 14px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-bottom: 5px; }
.field input, .field textarea, .field select {
  width: 100%; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  border-radius: 10px; padding: 10px 11px; font-size: 14px; font-family: inherit;
}
.modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.modal-close {
  position: absolute; top: 14px; right: 14px; background: var(--surface-2);
  border: 1px solid var(--line); color: var(--ink-soft); border-radius: 999px;
  width: 36px; height: 36px; cursor: pointer; font-size: 16px;
}
.modal-wrap { position: relative; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 999px;
  font-size: 13px; font-weight: 600; z-index: 100; max-width: 90%; text-align: center;
}

.stock-alert-box {
  background: rgba(196,61,61,0.10); border: 1px solid rgba(196,61,61,0.35);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px;
}
.stock-alert-box .alert-title { font-weight: 700; font-size: 13px; color: var(--danger); }

.empty {
  text-align: center; padding: 30px 10px; color: var(--ink-soft); font-size: 13px;
  background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius);
}

.shop-header { text-align: center; padding: 8px 0 18px; }
.shop-header .brand-emoji { width: 72px; height: 72px; border-radius: 18px; margin: 0 auto; font-size: 40px; }
.shop-header h1 { font-size: 20px; margin-top: 6px; }

/* Login */
.login-box {
  max-width: 400px; margin: 40px auto; padding: 24px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow);
}
.login-box h1 { text-align: center; margin-bottom: 8px; }
.login-box p { text-align: center; color: var(--ink-soft); font-size: 13px; margin-bottom: 20px; }

/* Admin table */
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.admin-table th { font-weight: 700; color: var(--ink-soft); font-size: 11px; text-transform: uppercase; }

.link-row { display: flex; gap: 8px; }
.link-row input { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); border-radius: 10px; padding: 9px 10px; font-size: 13px; }
.link-note { font-size: 11.5px; color: var(--ink-soft); margin-top: 8px; }

/* === V1.2 : plein écran large, modales centrées, commandes, zoom === */
@media (min-width: 768px) {
  .app { max-width: none; width: 100%; }
  .app.desktop-layout { grid-template-columns: 220px 1fr; min-height: 100vh; }
  .screen { max-width: 1100px; margin: 0 auto; }
  /* Commandes : colonne plus étroite sur grand écran */
  #ordersList, #ordersHistory { max-width: 640px; }
  .orders-wrap { max-width: 640px; }
}

/* Modales centrées H+V */
.modal-back {
  align-items: center !important;
  justify-content: center;
  padding: 16px;
}
.modal-back .modal {
  border-radius: 18px !important;
  max-height: 90vh;
  width: 100%;
  max-width: 440px;
}

/* Lightbox zoom image */
.lightbox {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; cursor: zoom-out;
}
.lightbox img {
  max-width: 96vw; max-height: 92vh; object-fit: contain;
  border-radius: 8px; cursor: default;
}

/* Pagination */
.pager {
  display: flex; gap: 8px; align-items: center; justify-content: center;
  margin: 14px 0; flex-wrap: wrap;
}
.pager button { min-width: 36px; }
.pager .pg-info { font-size: 12px; color: var(--ink-soft); }

/* Vitrine boutiques */
.vitrine-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
@media (min-width: 768px) {
  .vitrine-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1024px) {
  .vitrine-grid { grid-template-columns: repeat(4, 1fr); }
}
.vitrine-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; text-align: center; box-shadow: var(--shadow); cursor: pointer;
  text-decoration: none; color: var(--ink); display: block;
}
.vitrine-card .v-logo {
  width: 64px; height: 64px; border-radius: 16px; margin: 0 auto 8px;
  background: var(--surface-2); display: flex; align-items: center; justify-content: center;
  overflow: hidden; font-size: 28px;
}
.vitrine-card .v-logo img { width: 100%; height: 100%; object-fit: cover; }
.vitrine-card .v-name { font-weight: 700; font-size: 14px; }
.vitrine-card .v-meta { font-size: 11px; color: var(--ink-soft); margin-top: 4px; }

/* PWA install banner */
.pwa-banner {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  z-index: 150; background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow); border-radius: 16px; padding: 12px 14px;
  display: flex; gap: 10px; align-items: center; max-width: 92%; width: 360px;
}
.pwa-banner p { margin: 0; font-size: 13px; flex: 1; }

/* Zoomable thumbs */
.zoomable { cursor: zoom-in; }
.order-detail-box {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; margin-top: 8px; font-size: 12.5px;
}
