/* ─────────────────────────────────────────────────────────────
   Design tokens
   Palette pensée pour un outil métier "électricité industrielle" :
   encre profonde + cuivre (plutôt que le bleu SaaS générique),
   avec un traitement monospace systématique des données chiffrées
   (prix, stock, SKU) pour un rendu "instrument de précision".
   ───────────────────────────────────────────────────────────── */
:root {
  --ink: #10151f;
  --ink-soft: #1b2333;
  --ink-border: #2a3348;

  --bg: #f2f3f6;
  --surface: #ffffff;
  --border: #e2e4ea;
  --border-soft: #edeef2;

  --text: #1b2333;
  --text-muted: #67708a;
  --text-faint: #9aa1b5;

  --copper: #bd6a1e;
  --copper-dark: #98550f;
  --copper-soft: #f7ead6;

  --success: #2f7a55;
  --success-soft: #e4f3ea;
  --danger: #c1392b;
  --danger-soft: #fbe8e5;
  --warning: #b5790f;
  --warning-soft: #fbefd9;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 21, 31, 0.06);
  --shadow: 0 6px 20px rgba(16, 21, 31, 0.08);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", Menlo, Consolas, monospace;
}

/* ───────────────────────────── Reset ──────────────────────────── */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0 0 4px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); }
h2 { font-size: 15px; }
a { color: var(--copper-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: 0 0 8px; }
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--copper); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ───────────────────────── App shell ──────────────────────────── */
.shell { display: flex; min-height: 100vh; }
.shell-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--ink);
  color: #cfd4e2;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--ink-border);
  background-image: repeating-linear-gradient(
    115deg,
    rgba(189, 106, 30, 0.10) 0px,
    rgba(189, 106, 30, 0.10) 1px,
    transparent 1px,
    transparent 22px
  );
}
.sidebar-eyebrow {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--copper);
  font-weight: 600;
  margin-bottom: 3px;
}
.sidebar-title { display: block; font-size: 16px; font-weight: 700; color: #fff; letter-spacing: -0.01em; }

.sidebar-nav { flex: 1; padding: 14px 12px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: #b7bdd0;
  font-weight: 500;
  font-size: 13.5px;
}
.sidebar-nav a svg { opacity: 0.8; flex-shrink: 0; }
.sidebar-nav a:hover { background: var(--ink-soft); color: #fff; text-decoration: none; }
.sidebar-nav a.is-active { background: var(--copper); color: #fff; }
.sidebar-nav a.is-active svg { opacity: 1; }

.sidebar-footer { padding: 14px 20px 18px; border-top: 1px solid var(--ink-border); }
.sidebar-user { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: #9aa1b8; margin-bottom: 8px; }
.sidebar-user-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); flex-shrink: 0; }
.link-button {
  background: none; border: none; padding: 0; color: #9aa1b8; font-size: 12.5px;
  cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
}
.link-button:hover { color: #fff; }

.topbar {
  padding: 18px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 19px; }

.content { padding: 24px 32px 60px; max-width: 1180px; }

/* ───────────────────────────── Flash ──────────────────────────── */
.flash-stack { margin-bottom: 18px; display: flex; flex-direction: column; gap: 8px; }
.flash {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid transparent;
}
.flash-success { background: var(--success-soft); color: var(--success); border-color: rgba(47, 122, 85, 0.18); }
.flash-error { background: var(--danger-soft); color: var(--danger); border-color: rgba(193, 57, 43, 0.18); }

/* ───────────────────────────── Panels ─────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-header h2 { margin: 0; }

/* ────────────────────────── Stat cards ────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  border-left: 3px solid var(--copper);
}
.stat-card-danger { border-left-color: var(--danger); }
.stat-card-muted { border-left-color: var(--text-faint); }
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 600; }
.stat-value { font-family: var(--font-mono); font-size: 28px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }

/* ───────────────────────────── Buttons ────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--copper); border-color: var(--copper); color: #fff; }
.btn-primary:hover { background: var(--copper-dark); border-color: var(--copper-dark); }
.btn-secondary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-secondary:hover { background: var(--ink-soft); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--bg); border-color: var(--text-faint); }
.btn-danger-text { color: var(--danger); }
.btn-danger-text:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { display: flex; width: 100%; margin-top: 8px; }

/* ──────────────────────────── Data table ──────────────────────── */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--border);
}
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg); }

.col-thumb { width: 44px; }
.thumb { width: 40px; height: 40px; border-radius: var(--radius-sm); object-fit: cover; border: 1px solid var(--border); background: var(--bg); display: block; }
.thumb-empty { display: flex; }
.row-title { color: var(--ink); font-weight: 600; }
.row-title:hover { color: var(--copper-dark); }
.row-sub { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
.col-actions { text-align: right; white-space: nowrap; }
.col-actions .btn { margin-left: 4px; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.strike { text-decoration: line-through; color: var(--text-faint); margin-right: 4px; }
.text-muted { color: var(--text-muted); }
.inline-form { display: inline; }

/* ───────────────────────────── Badges ─────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  margin: 1px 3px 1px 0;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-neutral { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

/* ───────────────────────── Empty state ────────────────────────── */
.empty-state { color: var(--text-muted); padding: 18px 4px; }

/* ────────────────────────── Filter bar ────────────────────────── */
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filter-search { flex: 1; min-width: 220px; }

/* ───────────────────────────── Forms ──────────────────────────── */
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text); margin: 14px 0 5px; }
.panel > label:first-child, .panel > input:first-child, .panel > select:first-child { margin-top: 0; }
input[type="text"], input[type="url"], input[type="number"], input[type="password"], input[type="email"],
select, textarea {
  width: 100%;
  padding: 9px 11px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.12s ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--copper); }
textarea { resize: vertical; min-height: 70px; }
.field-hint { font-size: 12px; color: var(--text-faint); margin-top: 5px; }

.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; margin: 10px 0; cursor: pointer; }
.checkbox-label input { width: auto; }
.checkbox-label-sm { font-size: 12px; margin: 0; white-space: nowrap; }

.form-grid { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.form-side .panel h2 { margin-bottom: 2px; }
.form-actions { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.dim-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

/* Repeatable rows: images */
.repeat-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.repeat-row input { flex: 1; }
.image-preview { width: 42px; height: 42px; border-radius: var(--radius-sm); object-fit: cover; border: 1px solid var(--border); flex-shrink: 0; background: var(--bg); }
.image-preview-empty { display: block; }

/* Repeatable rows: attributes */
.attribute-row {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
  background: var(--bg);
}
.attribute-row-fields { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 8px; }
.attribute-row-fields input, .attribute-row-fields select { background: var(--surface); }
.attribute-row-toggles { display: flex; align-items: center; gap: 16px; margin-top: 8px; }
.attribute-row-toggles .btn { margin-left: auto; }

.category-list { max-height: 220px; overflow-y: auto; padding-right: 4px; }
.category-list .checkbox-label { margin: 6px 0; }
.quick-add-category { display: flex; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.quick-add-category input { flex: 1; }

/* ────────────────────────── Pagination ────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 18px; font-size: 13px; }
.pagination a { color: var(--copper-dark); font-weight: 600; }
.pagination a.is-disabled { color: var(--text-faint); pointer-events: none; text-decoration: none; }
.pagination-status { color: var(--text-muted); }

/* ──────────────────────────── Auth page ───────────────────────── */
.auth-body {
  background: var(--ink);
  background-image:
    repeating-linear-gradient(115deg, rgba(189, 106, 30, 0.06) 0px, rgba(189, 106, 30, 0.06) 1px, transparent 1px, transparent 26px);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-shell { width: 100%; max-width: 380px; padding: 20px; }
.auth-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px 30px;
  box-shadow: var(--shadow);
  text-align: left;
}
.auth-mark { margin-bottom: 14px; }
.auth-eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--copper-dark); font-weight: 700; margin-bottom: 4px; }
.auth-card h1 { font-size: 21px; margin-bottom: 6px; }
.auth-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 6px; }
.auth-form label { margin-top: 14px; }
.auth-form .btn { margin-top: 20px; }

/* ─────────────────────── Variations grid (non-tabulaire) ───────── */
.back-link { font-size: 13px; color: var(--text-muted); }
.generate-form { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; padding-top: 14px; border-top: 1px solid var(--border); }
.generate-form input { width: 220px; }

.variation-table { display: flex; flex-direction: column; }
.variation-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr 0.85fr 0.85fr 1.9fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border-soft);
}
.variation-row:last-child { border-bottom: none; }
.variation-row-head {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}
.variation-combo { display: flex; flex-wrap: wrap; gap: 4px; }
.variation-edit-form, .variation-delete-form { display: contents; }
.cell-input { padding: 7px 9px; font-size: 13px; }
.cell-input-sm { padding: 6px 8px; font-size: 12px; }
.stock-cell { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.stock-cell .cell-input { width: 56px; flex: none; }
.stock-cell select.cell-input { width: auto; flex: 1; min-width: 92px; }

/* ─────────────────────────── Responsive ───────────────────────── */
@media (max-width: 960px) {
  .form-grid { grid-template-columns: 1fr; }
  .variation-row { grid-template-columns: 1fr; }
  .variation-row-head { display: none; }
}
@media (max-width: 780px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; align-items: center; padding: 0 12px; }
  .sidebar-brand { border-bottom: none; border-right: 1px solid var(--ink-border); padding: 12px 16px; background-image: none; }
  .sidebar-nav { flex-direction: row; padding: 8px; }
  .sidebar-footer { border-top: none; padding: 8px 16px; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
}

/* ═══════════════════════ Tableau de bord enrichi ═══════════════════════ */

.dash-greeting { color: var(--text-muted); font-size: 14px; margin-bottom: 16px; }

.alert-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.alert-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
}
.alert-bar > div { display: flex; flex-direction: column; gap: 2px; }
.alert-bar strong { font-size: 13.5px; }
.alert-bar span { font-size: 12px; opacity: 0.85; }
.alert-bar-warning { background: var(--warning-soft); color: var(--warning); border-color: rgba(181, 121, 15, 0.18); }
.alert-bar-danger { background: var(--danger-soft); color: var(--danger); border-color: rgba(193, 57, 43, 0.18); }
.alert-bar .btn-secondary { flex-shrink: 0; }

.stat-grid-6 { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 1280px) { .stat-grid-6 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .stat-grid-6 { grid-template-columns: repeat(2, 1fr); } }
.stat-sub { font-size: 11px; color: var(--text-faint); }

.dash-grid { display: grid; gap: 16px; margin-bottom: 16px; }
.dash-grid-3 { grid-template-columns: 2fr 1fr; }
.dash-grid-2 { grid-template-columns: 1fr 1fr; }
.dash-span-2 { grid-column: span 1; }
@media (max-width: 960px) {
  .dash-grid-3, .dash-grid-2 { grid-template-columns: 1fr; }
}

.panel-header-note { font-size: 12px; color: var(--text-faint); font-weight: 500; }

.chart-svg { width: 100%; height: auto; display: block; }
.chart-grid-line { stroke: var(--border); stroke-width: 1; }
.chart-axis-label { font-size: 10.5px; fill: var(--text-faint); font-family: var(--font-sans); }
.chart-empty-text { font-size: 12.5px; fill: var(--text-faint); font-family: var(--font-sans); }

.donut-layout { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.donut-layout .chart-svg { width: 150px; height: 150px; flex-shrink: 0; }
.donut-center-label { font-size: 22px; font-weight: 700; fill: var(--ink); font-family: var(--font-mono); }
.donut-center-sublabel { font-size: 10px; fill: var(--text-faint); font-family: var(--font-sans); text-transform: uppercase; letter-spacing: 0.04em; }
.donut-legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 140px; font-size: 12.5px; }
.donut-legend li { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.chart-legend-inline { display: flex; gap: 16px; margin-top: 10px; font-size: 12px; color: var(--text-muted); }
.chart-legend-inline span { display: inline-flex; align-items: center; gap: 6px; }

.ranked-list { list-style: none; margin: 0; padding: 0; }
.ranked-list li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border-soft); }
.ranked-list li:last-child { border-bottom: none; }
.rank-num {
  width: 20px; height: 20px; border-radius: 50%; background: var(--bg); color: var(--text-muted);
  font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.thumb-xs { width: 30px; height: 30px; }
.ranked-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ranked-name { font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ranked-sub { font-size: 11.5px; color: var(--text-faint); }
.ranked-value { font-size: 12.5px; font-weight: 600; color: var(--ink); flex-shrink: 0; }

.activity-feed { list-style: none; margin: 0; padding: 0; }
.activity-feed li { padding: 9px 0; border-bottom: 1px solid var(--border-soft); position: relative; }
.activity-feed li:last-child { border-bottom: none; }
.activity-feed a { font-size: 13px; font-weight: 600; color: var(--ink); }
.activity-feed a:hover { color: var(--copper-dark); }
.activity-sub { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.activity-time { font-size: 11px; color: var(--text-faint); display: block; margin-top: 2px; }

.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.quick-action {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: border-color 0.12s ease, transform 0.12s ease;
}
.quick-action:hover { border-color: var(--copper); text-decoration: none; transform: translateY(-1px); }
.quick-action-title { font-size: 13.5px; font-weight: 700; color: var(--ink); }
.quick-action-sub { font-size: 12px; color: var(--text-muted); }

.order-total-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 4px 4px; margin-top: 4px; border-top: 1px solid var(--border);
  font-size: 14px; font-weight: 700; color: var(--ink);
}
.order-note { margin-top: 16px; padding: 12px; background: var(--bg); border-radius: var(--radius-sm); font-size: 13px; }
.order-note p { margin: 4px 0 0; color: var(--text-muted); }
