/* ==========================================================================
   Back-office (mobile first)
   ========================================================================== */
:root {
  --ink: #0d0f14; --soft: #5b6070; --line: #e6e3dc; --bg: #f4f2ed; --card: #fff;
  --blue: #0469B7; --green: #00814F; --red: #C63230; --yellow: #FECD06;
  --radius: 16px; --sidebar: 240px;
  --display: "Space Grotesk", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body.admin { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 "Inter", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--blue); }
h1, h2 { font-family: var(--display); letter-spacing: -.02em; line-height: 1.15; margin: 0; }
h1 { font-size: 28px; display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
h2 { font-size: 18px; margin-bottom: 14px; }
.muted { color: var(--soft); }
code.code, .code { font: 600 13px/1.4 ui-monospace, Consolas, monospace; padding: 2px 7px; border-radius: 6px; background: #f0eee8; color: var(--ink); }

/* --- Navigation -------------------------------------------------------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40; width: var(--sidebar);
  display: flex; flex-direction: column; gap: 20px; padding: 22px 14px;
  background: var(--ink); color: #c8ccd6;
  transform: translateX(-100%); transition: transform .35s cubic-bezier(.22,1,.36,1);
}
.sidebar.is-open { transform: none; box-shadow: 20px 0 60px rgba(0,0,0,.35); }
.sidebar-logo { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font: 700 18px var(--display); padding: 0 8px; }
.sidebar-logo svg { width: 30px; height: 30px; }
.login .sidebar-logo { color: var(--ink); padding: 0; margin-bottom: 18px; }
.sidebar nav { display: grid; gap: 4px; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; color: inherit; text-decoration: none; font-weight: 500; transition: background .2s, color .2s; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a.is-active { background: #fff; color: var(--ink); }
.sidebar nav svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-badge { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--red); color: #fff; font-size: 12px; text-align: center; }
.sidebar-foot { margin-top: auto; display: grid; gap: 8px; padding: 14px 12px 0; border-top: 1px solid rgba(255,255,255,.1); font-size: 14px; }
.sidebar-foot a { color: #c8ccd6; text-decoration: none; }
.sidebar-foot a:hover { color: #fff; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; height: 60px; padding: 0 16px; background: rgba(244,242,237,.9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.menu-toggle { width: 42px; height: 42px; border: 0; border-radius: 12px; background: var(--ink); display: grid; place-content: center; gap: 4px; cursor: pointer; }
.menu-toggle span { display: block; width: 18px; height: 2px; background: #fff; border-radius: 2px; }
.admin-main { padding: 20px 16px 60px; max-width: 1300px; }

/* --- En-têtes, onglets, barre d'outils ----------------------------------------- */
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 14px; margin-bottom: 22px; }
.page-head p { margin: 4px 0 0; }
.back { display: inline-block; margin-bottom: 6px; font-size: 14px; text-decoration: none; color: var(--soft); }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; padding-bottom: 4px; }
.tabs a { flex: none; padding: 8px 14px; border-radius: 999px; background: #fff; color: var(--ink); text-decoration: none; font-weight: 500; font-size: 14px; border: 1px solid var(--line); }
.tabs a span { margin-left: 4px; color: var(--soft); font-size: 12px; }
.tabs a.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }
.tabs a.is-active span { color: #aab; }
.toolbar { display: flex; gap: 8px; margin-bottom: 14px; }
.toolbar input { flex: 1; min-width: 0; }

/* --- Boutons ------------------------------------------------------------------ */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px; border: 0; border-radius: 999px; background: var(--ink); color: #fff; font: 600 14px "Inter", sans-serif; text-decoration: none; cursor: pointer; transition: transform .2s, opacity .2s; }
.button:hover { transform: translateY(-1px); }
.button-ghost { background: #fff; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.button-danger { background: #fff; color: var(--red); box-shadow: inset 0 0 0 1.5px #f2c7c6; }
.button-small { min-height: 34px; padding: 0 12px; font-size: 13px; }
.button-large { min-height: 52px; font-size: 15px; }
.icon-button { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 14px; }
.icon-button.danger { color: var(--red); }
.icon-button[disabled] { opacity: .35; cursor: default; }

/* --- Cartes, grilles ------------------------------------------------------------- */
.panel-box { background: var(--card); border-radius: var(--radius); padding: 18px; border: 1px solid var(--line); min-width: 0; }
.panel-box.highlight { border: 1.5px solid var(--ink); }
.box-head { display: flex; justify-content: space-between; align-items: baseline; }
.box-head a { font-size: 14px; text-decoration: none; }
.stack { display: grid; gap: 16px; align-content: start; }
.grid-2, .grid-form { display: grid; gap: 16px; margin-bottom: 16px; }
.row-2 { display: grid; gap: 12px; align-items: start; }

/* --- Indicateurs --------------------------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { position: relative; overflow: hidden; display: grid; gap: 4px; padding: 16px; border-radius: var(--radius); background: #fff; border: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c); }
.kpi span { font-size: 13px; color: var(--soft); }
.kpi b { font: 600 24px/1.1 var(--display); letter-spacing: -.02em; }
.kpi small { font-size: 12px; color: var(--soft); }
.kpi-link:hover { border-color: var(--ink); }
.chart { position: relative; height: 260px; }
.chart-small { height: 240px; }
.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.rank li { display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: center; }
.rank-n { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--yellow); font-weight: 700; }
.rank small { display: block; }

/* --- Tableaux (cartes sur mobile) ----------------------------------------------- */
.table { width: 100%; border-collapse: collapse; }
.table thead { display: none; }
.table tr { display: grid; gap: 4px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.table tr:last-child { border-bottom: 0; }
.table td { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }
.table td[data-label]::before { content: attr(data-label); color: var(--soft); font-size: 13px; }
.table td.thumb-cell { display: block; }
.table td.actions { justify-content: flex-start; gap: 8px; }
.table a { text-decoration: none; }
tr[data-href] { cursor: pointer; }
.num { text-align: right; }
.thumb { width: 48px; height: 48px; object-fit: contain; border-radius: 10px; background: var(--bg); }
.pagination { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.pagination a { min-width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.pagination a.is-current { background: var(--ink); color: #fff; }

/* --- Statuts ---------------------------------------------------------------------- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font: 600 12px "Inter", sans-serif; background: #eeece6; color: var(--soft); white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-paid, .pill-processing { background: #e4effa; color: var(--blue); }
.pill-shipped, .pill-delivered { background: #e3f3ea; color: var(--green); }
.pill-pending { background: #fff4c7; color: #8a6a00; }
.pill-failed, .pill-cancelled { background: #fde7e6; color: #a1201e; }

/* --- Formulaires ------------------------------------------------------------------ */
.field { display: grid; gap: 6px; font-size: 14px; }
.field > span { font-weight: 600; }
.field small { color: var(--soft); font-size: 12px; }
input, select, textarea { width: 100%; min-height: 44px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); font: 15px "Inter", sans-serif; }
textarea { resize: vertical; line-height: 1.5; }
input[type=color] { padding: 4px; height: 44px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(254,205,6,.4); }
input[type=checkbox] { width: auto; min-height: 0; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.switch input { position: absolute; opacity: 0; }
.switch span { position: relative; flex: none; width: 42px; height: 24px; border-radius: 999px; background: #d8d5ce; transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px rgba(254,205,6,.6); }
.dropzone { display: grid; place-items: center; text-align: center; padding: 26px; border: 2px dashed var(--line); border-radius: var(--radius); cursor: pointer; transition: border-color .2s, background .2s; }
.dropzone:hover, .dropzone.is-over { border-color: var(--ink); background: var(--bg); }
.dropzone input { display: none; }
.image-grid, .upload-preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.image-item { margin: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--bg); }
.image-item img, .upload-preview img { width: 100%; aspect-ratio: 1; object-fit: contain; display: block; background: var(--bg); }
.upload-preview img { border-radius: 12px; border: 2px dashed var(--yellow); }
.image-item figcaption { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 8px; background: #fff; }
.image-actions { display: flex; gap: 4px; margin-left: auto; }

/* --- Options de produit ------------------------------------------------------------ */
.option-rows { display: grid; gap: 8px; }
.option-row { display: grid; grid-template-columns: minmax(0, 1fr) 110px auto auto; gap: 8px; align-items: center; }
.option-head { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--soft); font-weight: 600; }
.option-delete { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--red); cursor: pointer; white-space: nowrap; }
.option-delete input { width: auto; min-height: 0; }
.option-row .switch span { margin: 0; }

/* --- Détails ------------------------------------------------------------------------ */
.details { display: grid; grid-template-columns: 110px 1fr; gap: 10px 14px; margin: 0; }
.details dt { color: var(--soft); font-size: 14px; }
.details dd { margin: 0; overflow-wrap: anywhere; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 6px 20px; margin: 14px 0 0; padding-top: 14px; border-top: 1px solid var(--line); }
.totals dt { color: var(--soft); } .totals dd { margin: 0; text-align: right; }
.totals .grand { font: 600 20px var(--display); color: var(--ink); padding-top: 6px; }
.totals .ok { color: var(--green); }
.timeline { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--line); display: grid; gap: 14px; }
.timeline li { position: relative; display: grid; }
.timeline li::before { content: ""; position: absolute; left: -23px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px #fff; }
.timeline small { color: var(--soft); }

/* --- Alertes ------------------------------------------------------------------------- */
.alert { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; font-weight: 500; }
.alert ul { margin: 0; padding-left: 18px; }
.alert-success { background: #e3f3ea; color: #0b5a37; }
.alert-error { background: #fde7e6; color: #8a1f1d; }

/* --- Connexion ------------------------------------------------------------------------ */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(60% 50% at 80% 10%, rgba(254,205,6,.25), transparent), radial-gradient(50% 40% at 10% 90%, rgba(4,105,183,.18), transparent), var(--bg); }
.login-card { width: 100%; max-width: 400px; padding: 30px; border-radius: 22px; background: #fff; box-shadow: 0 30px 60px -30px rgba(0,0,0,.3); }
.login-card h1 { font-size: 26px; margin-bottom: 8px; }
.login-card .stack { margin-top: 18px; }
.admin-main:has(.login) { padding: 0; max-width: none; }

/* --- Grand écran ------------------------------------------------------------------------- */
@media (min-width: 760px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .kpis-3 { grid-template-columns: repeat(3, 1fr); }
  .row-2 { grid-template-columns: 1fr 1fr; }
  .table thead { display: table-header-group; }
  .table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--soft); font-weight: 600; padding: 0 10px 10px; border-bottom: 1px solid var(--line); }
  .table th.num { text-align: right; }
  .table tr { display: table-row; padding: 0; }
  .table td { display: table-cell; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
  .table td[data-label]::before { display: none; }
  .table td.actions { white-space: nowrap; text-align: right; }
  .table tbody tr:last-child td { border-bottom: 0; }
  tr[data-href]:hover td { background: #faf9f6; }
  .table-plain td { padding: 10px; }
  .panel-box { padding: 22px; }
  .admin-main { padding: 28px 28px 60px; }
}
@media (min-width: 1100px) {
  .sidebar { transform: none; }
  .topbar { display: none; }
  .admin-main { margin-left: var(--sidebar); padding: 36px 40px 60px; }
  .admin-main:has(.login) { margin-left: 0; }
  .kpis { grid-template-columns: repeat(6, 1fr); }
  .kpis-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-2 { grid-template-columns: 1.6fr 1fr; }
  .grid-form { grid-template-columns: 1.6fr 1fr; align-items: start; }
}

/* Logo LEDoMATIC */
.sidebar-logo picture, .sidebar-logo img { display: block; }
.sidebar .sidebar-logo img { height: 26px; width: auto; }
.login-card .sidebar-logo img { height: 34px; width: auto; }

/* --- Livraison : paliers de tarifs --------------------------------------------------- */
.option-row.rate-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 30px; }
