/* ============================================================
   MANIKA KIDS — Design System professionnel
   Thème clair élégant, sidebar, cartes, cibles tactiles
   ============================================================ */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #0f172a;
  --ink-2: #475569;
  --muted: #94a3b8;
  --line: #e6eaf1;
  --brand: #0e7490;
  --brand-2: #0891b2;
  --brand-soft: #e0f2fe;
  --accent: #f59e0b;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15,23,42,.05), 0 8px 24px rgba(15,23,42,.06);
  --shadow-lg: 0 12px 40px rgba(15,23,42,.14);
  --sidebar-w: 252px;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: 'Plus Jakarta Sans', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg); color: var(--ink);
  overscroll-behavior: none; font-size: 14px; -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-weight: 500; font-size: 12.5px; }

/* ============ Boutons ============ */
.btn {
  border: 1px solid transparent; border-radius: var(--radius-sm); padding: 10px 16px;
  font-size: 13.5px; font-weight: 700; cursor: pointer; font-family: inherit;
  background: var(--surface-2); color: var(--ink);
  transition: transform .06s, box-shadow .15s, background .15s, border-color .15s;
  min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(14,116,144,.24); }
.btn-primary:hover { background: #0b5c72; }
.btn-success { background: var(--success); color: #fff; box-shadow: 0 6px 16px rgba(22,163,74,.22); }
.btn-success:hover { background: #15803d; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-ghost   { background: var(--surface); border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-sm { min-height: 36px; padding: 7px 12px; font-size: 12.5px; }
.btn-lg { min-height: 52px; font-size: 16px; }
.btn-block { width: 100%; }
.icon-btn { background: var(--surface); border: 1px solid var(--line); color: var(--ink-2);
  font-size: 17px; cursor: pointer; padding: 8px 11px; border-radius: var(--radius-sm); }
.icon-btn:hover { border-color: var(--brand); color: var(--brand); }

/* ============ Login ============ */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; position: relative; overflow: hidden;
  background: linear-gradient(135deg, #0b1220 0%, #0e7490 100%); }
.login-bg { position: absolute; inset: 0;
  background: radial-gradient(600px 400px at 15% 10%, rgba(8,145,178,.55), transparent 60%),
              radial-gradient(700px 500px at 90% 90%, rgba(245,158,11,.22), transparent 55%); }
.login-card { position: relative; background: var(--surface); border-radius: 24px; padding: 40px 34px;
  width: 100%; max-width: 400px; box-shadow: var(--shadow-lg); text-align: center; }
.login-logo { font-size: 54px; margin-bottom: 6px; }
.login-card h1 { font-size: 27px; letter-spacing: -.5px; color: var(--ink); }
.login-sub { color: var(--muted); font-size: 13px; margin: 6px 0 24px; font-weight: 600; }
.login-card form { text-align: left; display: grid; gap: 15px; }
.login-error { color: var(--danger); font-size: 13px; min-height: 18px; text-align: center; font-weight: 600; }

/* ============ Formulaires ============ */
label { display: grid; gap: 6px; font-size: 12.5px; color: var(--ink-2); font-weight: 700; }
input[type=text], input[type=password], input[type=number], input[type=search],
input[type=date], input[type=month], select, textarea {
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  color: var(--ink); padding: 11px 13px; font-size: 14px; width: 100%; outline: none;
  font-family: inherit; font-weight: 500; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px var(--brand-soft); }
.input-sm { width: auto; padding: 8px 11px; font-size: 13px; }
label.check { display: flex; align-items: center; gap: 8px; flex-direction: row; font-weight: 600; }
label.check input { width: 18px; height: 18px; accent-color: var(--brand); }

/* ============ Layout app ============ */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: #0b1220; color: #cbd5e1;
  display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 40;
  transition: transform .25s;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand-logo { width: 42px; height: 42px; border-radius: 12px; background: linear-gradient(135deg, var(--brand-2), var(--brand));
  display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; overflow: hidden; }
.brand-logo img { width: 100%; height: 100%; object-fit: cover; }
.brand-text strong { display: block; color: #fff; font-size: 15px; letter-spacing: -.2px; }
.brand-text span { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.nav { flex: 1; padding: 14px 12px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.nav button {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: none; border: 0; color: #94a3b8; font-size: 14px; font-weight: 600;
  padding: 11px 14px; border-radius: 10px; cursor: pointer; font-family: inherit; transition: all .15s;
}
.nav button .nav-ico { font-size: 17px; width: 22px; text-align: center; }
.nav button:hover { background: rgba(255,255,255,.06); color: #e2e8f0; }
.nav button.active { background: linear-gradient(135deg, var(--brand-2), var(--brand)); color: #fff; box-shadow: 0 8px 20px rgba(8,145,178,.3); }
.sidebar-foot { padding: 14px; border-top: 1px solid rgba(255,255,255,.07); display: grid; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), #d97706);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; flex-shrink: 0; }
.user-meta strong { display: block; color: #fff; font-size: 13.5px; }
.user-meta span { font-size: 11.5px; color: var(--muted); text-transform: capitalize; }
.sidebar .btn-ghost { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.1); color: #cbd5e1; }
.sidebar .btn-ghost:hover { background: rgba(255,255,255,.12); color: #fff; }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 14px 24px;
  background: rgba(255,255,255,.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30;
}
.menu-toggle { display: none; background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--ink); }
.topbar-title { font-size: 19px; font-weight: 800; letter-spacing: -.3px; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.clock { font-size: 13px; font-weight: 700; color: var(--ink-2); background: var(--surface-2);
  padding: 7px 12px; border-radius: 10px; border: 1px solid var(--line); }
.content { padding: 22px 24px 40px; }

/* ============ Filtres ============ */
.filters { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.filter-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 2px; }
.seg button { background: none; border: 0; padding: 8px 16px; border-radius: 9px; font-size: 13px; font-weight: 700;
  color: var(--ink-2); cursor: pointer; font-family: inherit; transition: all .15s; }
.seg button.active { background: var(--brand); color: #fff; }

/* ============ Cartes ============ */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-head h3 { font-size: 14.5px; font-weight: 800; color: var(--ink); }
.card.span-2 { grid-column: span 2; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 16px; }
.settings-layout { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; align-items: start; }

/* ============ KPI ============ */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi::after { content: ''; position: absolute; top: 0; left: 0; width: 4px; height: 100%; background: var(--brand); }
.kpi.green::after { background: var(--success); } .kpi.amber::after { background: var(--accent); } .kpi.red::after { background: var(--danger); }
.kpi .kpi-label { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.kpi .kpi-val { font-size: 25px; font-weight: 800; color: var(--ink); margin: 8px 0 2px; letter-spacing: -.6px; }
.kpi .kpi-sub { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.kpi-sm .kpi { padding: 14px 16px; } .kpi-sm .kpi .kpi-val { font-size: 20px; }

/* ============ Bars ============ */
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 5px; font-size: 13px; }
.bar-row .bar-label { font-weight: 600; color: var(--ink); }
.bar-row .bar-val { font-weight: 800; color: var(--brand); font-variant-numeric: tabular-nums; }
.bar-row .bar-bg { grid-column: 1 / -1; height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; background: linear-gradient(90deg, var(--brand-2), var(--brand)); border-radius: 99px; transition: width .4s; }
.bars .empty { color: var(--muted); font-size: 13px; padding: 16px 0; text-align: center; }
.mini-list { display: flex; flex-direction: column; }
.mini-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.mini-item:last-child { border-bottom: 0; }
canvas { width: 100%; display: block; }

/* ============ POS ============ */
.pos-layout { display: grid; grid-template-columns: 1fr 370px; gap: 16px; height: calc(100vh - 130px); }
.pos-left { display: flex; flex-direction: column; gap: 12px; overflow: hidden; }
.pos-search-row { display: grid; grid-template-columns: 1fr 160px; gap: 10px; }
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.chip { background: var(--surface); border: 1px solid var(--line); color: var(--ink-2);
  border-radius: 999px; padding: 9px 18px; font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap; transition: all .15s; }
.chip:hover { border-color: var(--brand-2); }
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.chip.cat-manage { display: inline-flex; align-items: center; gap: 8px; }
.chip .cat-del { color: var(--danger); font-weight: 800; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; overflow-y: auto; align-content: start; padding-bottom: 20px; }
.prod-card-wrap { position: relative; }
.prod-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; transition: transform .1s, box-shadow .15s, border-color .15s;
  display: flex; flex-direction: column; box-shadow: var(--shadow); height: 100%; }
.prod-card:active { transform: scale(.96); }
.prod-card:hover { border-color: var(--brand-2); box-shadow: var(--shadow-lg); }
.prod-card img { width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--surface-2); }
.prod-card .prod-info { padding: 10px 12px; flex: 1; display: flex; flex-direction: column; }
.prod-card .prod-name { font-size: 12.5px; line-height: 1.3; font-weight: 600; flex: 1; }
.prod-card .prod-price { color: var(--brand); font-weight: 800; font-size: 14.5px; margin-top: 6px; }
.prod-card.inactive { opacity: .5; }
.prod-badge { position: absolute; top: 8px; left: 8px; background: var(--accent); color: #fff;
  font-size: 10px; font-weight: 800; padding: 3px 9px; border-radius: 999px; z-index: 2; }

/* Panier */
.pos-cart { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow); }
.cart-head { display: flex; gap: 10px; align-items: center; padding: 14px; border-bottom: 1px solid var(--line); }
.cart-head span { font-weight: 800; font-size: 14px; white-space: nowrap; }
.cart-head input { flex: 1; padding: 9px 11px; font-size: 13px; }
.cart-items { flex: 1; overflow-y: auto; padding: 10px; }
.cart-empty { color: var(--muted); text-align: center; padding: 40px 10px; font-size: 13px; }
.cart-line { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; padding: 10px; border-radius: 10px; }
.cart-line:nth-child(odd) { background: var(--surface-2); }
.cart-line .cl-name { font-size: 13px; font-weight: 700; }
.cart-line .cl-sub { grid-column: 1; color: var(--muted); font-size: 11.5px; }
.cart-line .cl-total { font-weight: 800; font-size: 13px; text-align: right; color: var(--brand); }
.cl-qty { display: inline-flex; align-items: center; gap: 8px; grid-column: 1 / -1; justify-content: flex-end; }
.cl-qty button { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-size: 15px; cursor: pointer; font-weight: 800; }
.cl-qty button:hover { border-color: var(--brand); color: var(--brand); }
.cl-qty span { min-width: 26px; text-align: center; font-weight: 800; }
.cart-summary { border-top: 1px solid var(--line); padding: 12px 16px; display: grid; gap: 7px; }
.cart-summary .row { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; }
.cart-summary .row.total { font-size: 21px; font-weight: 800; color: var(--brand); padding-top: 8px; border-top: 1.5px dashed var(--line); }
.remise-row input { width: 110px; padding: 5px 9px; font-size: 13px; }
.cart-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; padding: 14px; }

/* ============ Tableaux ============ */
.table-wrap-inner { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th { text-align: left; padding: 11px 14px; color: var(--muted); font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .3px; border-bottom: 1.5px solid var(--line); white-space: nowrap; }
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--line); font-weight: 500; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data .right { text-align: right; }
table.data .num { font-variant-numeric: tabular-nums; }
.thumb-sm { width: 40px; height: 40px; border-radius: 9px; object-fit: cover; background: var(--surface-2); }
.badge { font-size: 11px; font-weight: 800; padding: 4px 11px; border-radius: 999px; white-space: nowrap; display: inline-block; }
.badge.validee { background: var(--success-soft); color: #15803d; }
.badge.en_attente { background: var(--warn-soft); color: var(--warn); }
.badge.annulee { background: var(--danger-soft); color: var(--danger); }
.badge.entree { background: var(--success-soft); color: #15803d; }
.badge.sortie { background: var(--danger-soft); color: var(--danger); }
.badge.admin { background: #ede9fe; color: #6d28d9; }
.badge.gerant { background: var(--brand-soft); color: var(--brand); }
.badge.vendeur { background: var(--warn-soft); color: var(--warn); }
/* commandes : ligne cliquable */
tr.row-click { cursor: pointer; }

.orders-layout { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }

/* ============ Paramètres / logo ============ */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.logo-uploader { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.logo-preview { width: 72px; height: 72px; border-radius: 14px; object-fit: contain; border: 1px solid var(--line); background: var(--surface-2); }
.logo-preview.placeholder { display: flex; align-items: center; justify-content: center; font-size: 32px; }
.logo-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.qr-box { display: flex; justify-content: center; padding: 12px 0; }
.qr-box canvas, .qr-box img { background: #fff; padding: 10px; border-radius: 12px; border: 1px solid var(--line); }
.qr-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ============ Modales ============ */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 16px; backdrop-filter: blur(3px); }
.modal-card { background: var(--surface); border-radius: 20px; padding: 24px; width: 100%; max-width: 520px;
  max-height: 92vh; overflow-y: auto; box-shadow: var(--shadow-lg); display: grid; gap: 16px; }
.modal-head h3 { font-size: 18px; font-weight: 800; }
.modal-sm { max-width: 400px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.pay-total { font-size: 16px; font-weight: 600; }
.pay-total strong { color: var(--brand); font-size: 28px; font-weight: 800; }
.pay-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pay-mode { background: var(--surface-2); border: 1.5px solid var(--line); color: var(--ink); border-radius: 11px;
  padding: 13px 6px; font-size: 12.5px; cursor: pointer; font-weight: 700; font-family: inherit; }
.pay-mode.active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.pay-rendu { font-size: 15px; font-weight: 600; }
.pay-rendu strong { color: var(--success); font-size: 21px; font-weight: 800; }
.quick-cash { display: flex; gap: 6px; flex-wrap: wrap; }
.quick-cash button { background: var(--surface-2); border: 1px solid var(--line); color: var(--ink);
  border-radius: 8px; padding: 7px 11px; font-size: 12px; cursor: pointer; font-weight: 700; font-family: inherit; }
.quick-cash button:hover { border-color: var(--brand); color: var(--brand); }
.prod-form-layout { display: grid; grid-template-columns: 140px 1fr; gap: 16px; }
.prod-photo-box { display: grid; gap: 8px; align-content: start; }
.prod-photo-box img { width: 140px; height: 140px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); }
.prod-photo-box input[type=file] { font-size: 11px; }
.prod-fields { display: grid; gap: 11px; }
.seg-radio { display: flex; gap: 8px; }
.seg-radio label { display: flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1.5px solid var(--line);
  border-radius: 10px; padding: 10px 14px; cursor: pointer; font-weight: 700; flex: 1; }
.seg-radio input { accent-color: var(--brand); }

/* ============ Toast ============ */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 13px 22px; border-radius: 12px; font-size: 14px; font-weight: 600;
  z-index: 200; box-shadow: var(--shadow-lg); max-width: 90vw; }
.toast.success { background: var(--success); } .toast.error { background: var(--danger); }

/* ============ Responsive ============ */
@media (max-width: 1150px) { .orders-layout, .settings-layout { grid-template-columns: 1fr; } .card.span-2 { grid-column: span 1; } }
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main { margin-left: 0; }
  .menu-toggle { display: block; }
  .content { padding: 16px; }
  .pos-layout { grid-template-columns: 1fr; height: auto; }
  .pos-cart { max-height: 52vh; }
  .form-grid { grid-template-columns: 1fr; }
  .prod-form-layout { grid-template-columns: 1fr; }
  .card.span-2 { grid-column: span 1; }
}
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 35; }
.sidebar-overlay.show { display: block; }

@media print {
  body * { visibility: hidden; }
  #print-frame, #print-frame * { visibility: visible; }
  #print-frame { position: absolute; left: 0; top: 0; width: 100%; }
}
