/* ============================================================
   Le Paradis des Épices — Administration
   ============================================================ */
:root {
  --cream: #f7f3ec;
  --paper: #ffffff;
  --ink: #2b1e16;
  --ink-soft: #6f5d4f;
  --ink-faint: #9a8a7c;
  --paprika: #c0432a;
  --paprika-dark: #9d3320;
  --green: #1e7a43;
  --gold: #bd8b1f;
  --line: rgba(43, 30, 22, 0.12);
  --line-soft: rgba(43, 30, 22, 0.07);
  --shadow-sm: 0 2px 8px rgba(63, 42, 26, 0.07);
  --shadow-md: 0 14px 40px -16px rgba(63, 42, 26, 0.28);
  --radius: 16px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font-body); color: var(--ink); background: var(--cream); -webkit-font-smoothing: antialiased; }
svg { width: 1.3em; height: 1.3em; }
h1, h3, h4 { font-family: var(--font-display); margin: 0; font-weight: 600; }
.btn { display: inline-flex; align-items: center; gap: 0.5em; padding: 0.7em 1.2em; border-radius: 999px; font-weight: 600; font-size: 0.92rem; cursor: pointer; border: none; transition: 0.18s; }
.btn-sm { padding: 0.55em 1em; font-size: 0.86rem; }
.btn-primary { background: var(--paprika); color: #fff; }
.btn-primary:hover { background: var(--paprika-dark); }
.btn-ghost { background: #fff; border: 1px solid var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-block { width: 100%; justify-content: center; }
.btn-danger { background: #fcebe7; color: var(--paprika-dark); }
.btn-danger:hover { background: var(--paprika); color: #fff; }
.btn-wa { background: #25d366; color: #fff; }
.btn-wa:hover { background: #1eb858; }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; color: var(--ink); }
.icon-btn:hover { background: var(--line-soft); }
.brand-mark { width: 44px; height: 44px; border-radius: 12px; background: linear-gradient(150deg, #fff, #f0e6d4); border: 1px solid var(--line); display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; flex: none; }
.brand-mark.sm { width: 38px; height: 38px; font-size: 1rem; }
.brand-mark b { color: var(--paprika); }
.brand-mark i { color: var(--green); font-style: normal; margin-left: -3px; }

/* ---------- Connexion ---------- */
.login-screen { min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: radial-gradient(120% 120% at 50% 0%, #3a261a, #241710); }
.login-card { background: var(--paper); border-radius: 24px; padding: 40px 34px; width: min(400px, 100%); box-shadow: var(--shadow-md); text-align: center; }
.login-card .brand-mark { margin: 0 auto 18px; width: 56px; height: 56px; font-size: 1.5rem; }
.login-card h1 { font-size: 1.6rem; }
.login-card > p { color: var(--ink-soft); margin: 4px 0 26px; }
.login-field input { width: 100%; padding: 13px 16px; border: 1.5px solid var(--line); border-radius: 12px; font: inherit; font-size: 1rem; }
.login-field input:focus { outline: none; border-color: var(--paprika); box-shadow: 0 0 0 3px rgba(192,67,42,0.1); }
.login-error { color: var(--paprika-dark); font-size: 0.88rem; min-height: 20px; margin: 10px 0; }
.login-card .btn { margin-top: 4px; padding: 0.85em; }
.login-back { display: inline-block; margin-top: 18px; color: var(--ink-soft); font-size: 0.88rem; text-decoration: none; }
.login-back:hover { color: var(--ink); }

/* ---------- En-tête admin ---------- */
.admin-top { background: var(--ink); color: #f3e6d4; padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; position: sticky; top: 0; z-index: 20; }
.admin-brand { display: flex; align-items: center; gap: 12px; }
.admin-brand strong { display: block; font-family: var(--font-display); font-size: 1.05rem; }
.admin-brand small { color: rgba(243,230,212,0.6); font-size: 0.78rem; }
.admin-top .btn-ghost { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.18); color: #f3e6d4; }
.admin-top .btn-ghost:hover { background: rgba(255,255,255,0.16); border-color: rgba(255,255,255,0.3); }
.admin-top-actions { display: flex; gap: 10px; }
.admin-main { max-width: 1200px; margin: 0 auto; padding: 28px 24px 60px; }

/* ---------- Statistiques ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 26px; }
.stat { background: var(--paper); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow-sm); }
.stat small { color: var(--ink-faint); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; }
.stat b { display: block; font-family: var(--font-display); font-size: 1.9rem; font-weight: 600; margin-top: 6px; line-height: 1; }
.stat.accent b { color: var(--paprika); }
.stat.green b { color: var(--green); }

/* ---------- Barre d'outils ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-chip { padding: 8px 15px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-weight: 500; font-size: 0.86rem; color: var(--ink-soft); cursor: pointer; transition: 0.16s; }
.filter-chip:hover { border-color: var(--paprika); }
.filter-chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------- Tableau commandes ---------- */
.orders-card { background: var(--paper); border: 1px solid var(--line-soft); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.table-scroll { overflow-x: auto; }
.orders-table { width: 100%; border-collapse: collapse; min-width: 860px; }
.orders-table thead th { text-align: left; padding: 14px 18px; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-faint); border-bottom: 1px solid var(--line); font-weight: 600; }
.orders-table td { padding: 14px 18px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.orders-table tbody tr { transition: background 0.14s; cursor: pointer; }
.orders-table tbody tr:hover { background: var(--cream); }
.o-ref { font-weight: 700; font-family: var(--font-body); font-size: 0.9rem; }
.o-date { color: var(--ink-soft); font-size: 0.86rem; white-space: nowrap; }
.o-client b { font-weight: 600; }
.o-client small { display: block; color: var(--ink-soft); font-size: 0.82rem; }
.o-total { font-family: var(--font-display); font-weight: 600; font-size: 1.02rem; white-space: nowrap; }
.o-actions { display: flex; gap: 6px; justify-content: flex-end; }
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 0.76rem; font-weight: 600; white-space: nowrap; }
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag.nouvelle { background: #eef4ff; color: #2d63c8; }
.tag.confirmee { background: #fff4e3; color: #b67611; }
.tag.en_livraison { background: #eae6ff; color: #5b46c8; }
.tag.livree { background: #e3f5e9; color: var(--green); }
.tag.annulee { background: #fbe9e6; color: var(--paprika-dark); }
.tag.paye { background: #e3f5e9; color: var(--green); }
.tag.en_attente { background: #fff4e3; color: #b67611; }
.tag.echoue { background: #fbe9e6; color: var(--paprika-dark); }
.pay-chip { font-size: 0.82rem; color: var(--ink-soft); white-space: nowrap; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--ink-soft); }
.empty-state .es-ic { font-size: 2.6rem; margin-bottom: 10px; }

/* ---------- Tiroir détail ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(31,18,11,0.5); opacity: 0; visibility: hidden; transition: 0.3s; z-index: 40; }
.drawer-backdrop.show { opacity: 1; visibility: visible; }
.detail-drawer { position: fixed; top: 0; right: 0; height: 100dvh; width: min(480px, 100%); background: var(--cream); z-index: 50; transform: translateX(100%); transition: transform 0.32s cubic-bezier(.4,0,.1,1); display: flex; flex-direction: column; box-shadow: var(--shadow-md); }
.detail-drawer.open { transform: translateX(0); }
.detail-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); background: var(--paper); }
.detail-head h3 { font-size: 1.2rem; }
.detail-body { flex: 1; overflow-y: auto; padding: 22px; }
.dd-section { background: var(--paper); border: 1px solid var(--line-soft); border-radius: 14px; padding: 18px; margin-bottom: 16px; }
.dd-section h4 { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-faint); margin-bottom: 12px; font-family: var(--font-body); }
.dd-row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 0.92rem; }
.dd-row span:first-child { color: var(--ink-soft); }
.dd-row span:last-child { font-weight: 500; text-align: right; }
.dd-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.dd-item:last-child { border-bottom: none; }
.dd-item img { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; border: 1px solid var(--line); flex: none; }
.dd-item .di-main { flex: 1; }
.dd-item .di-name { font-weight: 600; font-size: 0.9rem; }
.dd-item .di-meta { color: var(--ink-soft); font-size: 0.8rem; }
.dd-item .di-price { font-family: var(--font-display); font-weight: 600; }
.dd-total { display: flex; justify-content: space-between; align-items: baseline; padding-top: 12px; border-top: 2px solid var(--ink); margin-top: 8px; }
.dd-total b { font-family: var(--font-display); font-size: 1.4rem; }
.dd-field { margin-bottom: 14px; }
.dd-field label { display: block; font-size: 0.8rem; font-weight: 600; margin-bottom: 6px; }
.dd-field select, .dd-field textarea { width: 100%; padding: 11px 13px; border: 1.5px solid var(--line); border-radius: 10px; font: inherit; font-size: 0.92rem; background: #fff; }
.dd-field select:focus, .dd-field textarea:focus { outline: none; border-color: var(--paprika); box-shadow: 0 0 0 3px rgba(192,67,42,0.1); }
.dd-actions { display: grid; gap: 10px; margin-top: 8px; }
.dd-actions .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- Toasts ---------- */
.toast-wrap { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.toast { background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px; box-shadow: var(--shadow-md); font-weight: 500; font-size: 0.9rem; animation: tin 0.3s; }
.toast.success { background: var(--green); }
.toast.error { background: var(--paprika-dark); }
@keyframes tin { from { transform: translateY(20px); opacity: 0; } }
.toast.out { opacity: 0; transform: translateY(20px); transition: 0.3s; }

@media (max-width: 760px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .admin-brand small { display: none; }
}
