/* =========================================================
   POS Cloud — Styles globaux (refonte 2026-04-25, design Figma Make)
   - Tokens light/dark + accent personnalisable (--primary)
   - Class names existants préservés (.btn, .card, .pill, .topbar, etc.)
   - Police Inter, coins arrondis, ombres douces
   ========================================================= */

@import url('https://rsms.me/inter/inter.css');

:root {
  /* ---- Palette ---- */
  --background:    #F5F7FA;
  --foreground:    #1E293B;
  --surface:       #FCFDFE;
  --surface-h:     #FFFFFF;
  --card:          #FFFFFF;
  --txt-2:         #64748B;
  --txt-3:         #94A3B8;
  --primary:       #3B82F6;
  --primary-fg:    #FFFFFF;
  --primary-deep:  #2563EB;
  --secondary:     #EEF2F6;
  --success:       #10B981;
  --warning:       #F59E0B;
  --danger:        #EF4444;
  --muted:         #EEF2F6;
  --border:        #E1E7EF;
  --input-bg:      #FAFBFC;
  --topbar-bg:     #FFFFFF;
  --statusbar-bg:  #FCFDFE;

  /* ---- Shadows ---- */
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
  --shadow-md: 0 4px 6px rgba(15,23,42,.08);
  --shadow-lg: 0 10px 20px rgba(15,23,42,.10);
  --shadow-xl: 0 20px 40px rgba(15,23,42,.12);

  /* ---- Radii ---- */
  --radius:    .75rem;     /* 12px */
  --radius-lg: 1rem;       /* 16px */
  --radius-md: .625rem;    /* 10px */
  --radius-sm: .5rem;      /* 8px */

  /* ---- Compat (legacy class refs) ---- */
  --c-bg:           var(--background);
  --c-bg-gradient:  var(--background);
  --c-surface:      var(--card);
  --c-surface-flat: var(--card);
  --c-input-bg:     var(--input-bg);
  --c-input-border: var(--border);
  --c-topbar:       var(--topbar-bg);
  --c-topbar-border:var(--border);
  --c-statusbar:    var(--statusbar-bg);
  --c-text:         var(--foreground);
  --c-text-muted:   var(--txt-3);
  --c-text-dim:     var(--txt-2);
  --c-border:       var(--border);
  --c-border-soft:  var(--border);
  --c-pill-bg:      var(--muted);
  --c-pill-border:  var(--border);
  --c-pill-active-bg:     var(--primary);
  --c-pill-active-border: var(--primary);
  --c-pill-active-text:   var(--primary-fg);
  --c-head-text:    var(--primary);
  --c-accent:       var(--primary);
  --c-accent-dark:  var(--primary-deep);
  --c-accent-deep:  var(--primary-deep);
  --c-success:      var(--success);
  --c-warning:      var(--warning);
  --c-danger:       var(--danger);
  --c-shadow:       rgba(15,23,42,.08);
}

body[data-theme="dark"] {
  --background:    #0A0E1A;
  --foreground:    #F1F5F9;
  --surface:       #131825;
  --surface-h:     #1C2333;
  --card:          #131825;
  --txt-2:         #94A3B8;
  --txt-3:         #64748B;
  --primary-deep:  #1D4ED8;
  --secondary:     #1C2333;
  --success:       #34D399;
  --warning:       #FBBF24;
  --danger:        #F87171;
  --muted:         #1C2333;
  --border:        #1E293B;
  --input-bg:      #131825;
  --topbar-bg:     #131825;
  --statusbar-bg:  #0F1320;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --shadow-md: 0 4px 8px rgba(0,0,0,.4);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.5);
  --shadow-xl: 0 20px 50px rgba(0,0,0,.6);
  --c-shadow:       rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--foreground);
  background: var(--background);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  transition: background 200ms, color 200ms;
}

/* ---------- Splash ---------- */
.splash {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
  background: var(--background); color: var(--txt-2);
  z-index: 9999; transition: opacity 300ms;
}
.splash.hidden { opacity: 0; pointer-events: none; }
.splash .logo { font-size: 32px; letter-spacing: 6px; font-weight: 700; color: var(--foreground); }
.splash .logo span { color: var(--primary); }
.splash .sub { font-size: 12px; text-transform: uppercase; letter-spacing: 3px; color: var(--primary); }
.splash .msg { font-size: 12px; color: var(--txt-3); margin-top: 20px; }
.splash .spin {
  width: 36px; height: 36px;
  border: 3px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 900ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Topbar ---------- */
.topbar {
  height: 56px; background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 20px; gap: 12px;
  font-size: 13px; position: relative; z-index: 10;
  box-shadow: var(--shadow-sm);
}
.topbar .logo { font-weight: 700; font-size: 16px; letter-spacing: 1.5px; color: var(--foreground); }
.topbar .logo span { color: var(--primary); }
.topbar .sub { color: var(--txt-3); font-size: 10px; text-transform: uppercase; letter-spacing: 1px; margin-top: 1px; }
.topbar .pill {
  background: var(--muted); border: 1px solid transparent;
  padding: 5px 12px; border-radius: 999px; color: var(--txt-2);
  font-size: 12px; font-weight: 500;
}
.topbar .pill.active {
  background: color-mix(in srgb, var(--primary) 15%, transparent);
  color: var(--primary); border-color: transparent;
}
.topbar .spacer { flex: 1; }
.topbar .clock {
  font-variant-numeric: tabular-nums; color: var(--foreground);
  font-weight: 500; min-width: 72px; text-align: right;
}

/* ---------- Main ---------- */
main {
  position: absolute;
  top: 56px; left: 0; right: 0; bottom: 32px;
  padding: 20px;
  overflow: hidden;
}

/* ---------- Statusbar ---------- */
.statusbar {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 32px; background: var(--statusbar-bg);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 20px; gap: 16px;
  font-size: 12px; color: var(--txt-3); z-index: 9;
}
.statusbar .ok   { color: var(--success); }
.statusbar .warn { color: var(--warning); }
.statusbar .err  { color: var(--danger); }
.statusbar .spacer { flex: 1; }

/* ---------- Boutons ---------- */
.btn {
  background: var(--secondary); color: var(--foreground);
  border: 0; border-radius: var(--radius-md);
  padding: 10px 16px; font: inherit;
  font-weight: 500; font-size: 14px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: all .15s ease;
  box-shadow: var(--shadow-sm);
}
.btn:hover:not([disabled]) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  background: color-mix(in srgb, var(--secondary) 80%, var(--foreground));
}
.btn:active:not([disabled]) {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}
.btn.primary {
  background: var(--primary); color: var(--primary-fg);
}
.btn.primary:hover:not([disabled]) {
  background: color-mix(in srgb, var(--primary) 88%, black);
}
.btn.danger {
  background: var(--danger); color: #fff;
}
.btn.danger:hover:not([disabled]) {
  background: color-mix(in srgb, var(--danger) 88%, black);
}
.btn.light {
  background: var(--surface-h); color: var(--foreground);
  border: 1px solid var(--border);
}
.btn.light:hover:not([disabled]) {
  background: var(--muted);
}
.btn.dark {
  background: var(--secondary); color: var(--foreground);
}
.btn.ghost {
  background: transparent; color: var(--foreground); box-shadow: none;
  border: 1px solid var(--border);
}
.btn.ghost:hover:not([disabled]) {
  background: var(--muted); transform: none; box-shadow: none;
}
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* ---------- Pill generic ---------- */
.pill {
  background: var(--muted); border: 1px solid transparent;
  padding: 4px 10px; border-radius: 999px; color: var(--txt-2);
  font-size: 11px; font-weight: 500;
}

/* ---------- Formulaires ---------- */
.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 12px; color: var(--txt-2);
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px;
  font-weight: 500;
}
.field input[type=text], .field input[type=number], .field input[type=time],
.field input[type=email], .field input[type=date], .field input[type=tel],
.field input[type=search], .field input[type=url],
.field input[type=password], .field input:not([type]),
.field select, .field textarea {
  width: 100%; padding: 10px 14px;
  background: var(--input-bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--foreground); font: inherit; font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- Cartes ---------- */
.card {
  background: var(--card);
  border: 0;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: visible;
}
.card .head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 12px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--txt-2); font-weight: 600;
  background: transparent;
}
.card .body { padding: 18px; }

/* ---------- Login ---------- */
/* #137-#140 : fond vidéo CHR Solution avec auto-rotation et tag dark/light.
   Le wrap est position:fixed full-viewport pour couvrir derrière topbar/status.
   L'overlay (gradient dark→transparent) garantit la lisibilité du contenu.    */
.login-bg {
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.login-bg-video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  filter: saturate(0.85);
}
.login-bg-overlay {
  position: absolute; inset: 0;
  /* Light theme : voile clair léger, on veut VOIR la vidéo. */
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--background) 55%, transparent),
    color-mix(in srgb, var(--background) 30%, transparent)
  );
}
body[data-theme="dark"] .login-bg-overlay {
  /* Dark theme : voile sombre LÉGER (était 0.75 = vidéo invisible).
     30-50% laisse la vidéo bien visible tout en gardant le contenu lisible. */
  background: linear-gradient(
    135deg,
    rgba(0, 0, 0, 0.45),
    rgba(0, 0, 0, 0.25)
  );
}
.login {
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 32px;
  align-items: center;
  justify-items: center;
  position: relative; z-index: 1; /* au-dessus du fond vidéo */
}
.login .operators {
  display: grid;
  grid-template-columns: repeat(3, 180px);
  grid-auto-rows: 160px;
  gap: 18px;
  max-width: 620px;
}
.op-card {
  background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px; cursor: pointer; color: var(--foreground);
  box-shadow: var(--shadow-md);
  transition: all .2s ease;
}
.op-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.op-card.selected {
  border: 2px solid var(--primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 20%, transparent);
}
.op-card .avatar {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; color: var(--primary-fg);
}
.op-card .name { font-weight: 600; font-size: 14px; }
.op-card .role { font-size: 11px; color: var(--txt-2); text-transform: uppercase; letter-spacing: .5px; }

.pinpad {
  background: var(--card);
  border: 0; border-radius: var(--radius-lg);
  padding: 20px; width: 320px;
  box-shadow: var(--shadow-lg);
}
.pinpad h3 {
  margin: 0 0 14px; text-align: center;
  color: var(--txt-2); font-weight: 500; font-size: 14px;
}
.pindisplay {
  background: var(--muted); border: 0;
  border-radius: var(--radius-md);
  height: 52px; display: flex; align-items: center; justify-content: center;
  font-size: 28px; letter-spacing: 10px; margin-bottom: 14px;
  color: var(--primary); font-variant-numeric: tabular-nums; font-weight: 700;
}
.pin-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.pin-grid .btn { padding: 16px 0; font-size: 22px; aspect-ratio: 1; box-shadow: none; }
.pin-grid .btn:not(.primary):not(.danger) { background: var(--muted); }

/* ---------- Home (page connectée) ---------- */
.home {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  height: 100%;
}
.home .left  { display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.home .right { display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.home .user-card { text-align: center; padding: 22px; }
.home .user-card .avatar-lg {
  width: 80px; height: 80px; border-radius: 50%;
  background: var(--primary);
  font-size: 32px; font-weight: 700; color: var(--primary-fg);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
}
.home .user-card h2 { margin: 0 0 4px; font-size: 18px; font-weight: 600; }
.home .user-card .role {
  color: var(--txt-2); font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
}
.home .actions { display: grid; gap: 10px; }
.home .actions .btn {
  padding: 14px; text-align: left;
  display: flex; align-items: center; gap: 12px;
  justify-content: flex-start;
  font-weight: 500;
}
.home .actions .btn .ico { font-size: 18px; }

.home .tile-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.home .tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px; box-shadow: none;
}
.card .body .home .tile,
.card .body .tile {
  /* nested tiles inside a card → flat, no shadow */
  background: transparent;
  border-color: transparent;
  background: color-mix(in srgb, var(--primary) 4%, var(--surface));
}
.home .tile .label {
  font-size: 11px; color: var(--txt-2);
  text-transform: uppercase; letter-spacing: 0.5px; font-weight: 500;
}
.home .tile .val {
  font-size: 26px; font-weight: 700; margin-top: 6px;
  font-variant-numeric: tabular-nums; line-height: 1.1;
  color: var(--primary);
}
.home .tile .val.blue  { color: var(--primary); }
.home .tile .val.green { color: var(--success); }

.home .rights-list {
  display: flex; flex-wrap: wrap; gap: 6px;
  max-height: 200px; overflow-y: auto;
}
.home .rights-list .chip {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary);
  border: 0; padding: 4px 10px;
  border-radius: 999px; font-size: 11px; font-weight: 500;
}
.home .rights-list .chip.disabled {
  background: var(--muted); color: var(--txt-3);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 60px; left: 50%; transform: translateX(-50%);
  background: var(--foreground); color: var(--background);
  padding: 12px 20px; border-radius: var(--radius-md);
  font-weight: 500; font-size: 14px;
  box-shadow: var(--shadow-xl);
  animation: toastIn 200ms ease-out; z-index: 999;
}
.toast.err { background: var(--danger); color: #fff; }
.toast.ok  { background: var(--success); color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 20px); } to { opacity: 1; } }

/* ---------- Readonly banner (mode visualisation pos-mobile migration) ---------- */
#readonly-banner {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: linear-gradient(90deg, #ff9800 0%, #f57c00 100%);
  color: #fff;
  padding: 10px 16px;
  display: flex; align-items: center; gap: 12px;
  font-size: 13px; font-weight: 500;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.15);
  z-index: 998;
  border-top: 2px solid #e65100;
}
#readonly-banner .ro-icon { font-size: 20px; line-height: 1; }
#readonly-banner .ro-text { flex: 1; line-height: 1.4; }
#readonly-banner .ro-text a { color: #fff; text-decoration: underline; font-weight: 700; }
#readonly-banner button {
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.4);
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}
#readonly-banner button:hover { background: rgba(255,255,255,0.28); }

/* Mode visu : laisse passer la navigation, mais masque visuellement les
   boutons d'opération caisse (commandes, paiement, clôture). Les écritures
   sont déjà bloquées au niveau appendEvent ; ce CSS sert juste à éviter de
   faire cliquer l'utilisateur sur des boutons qui afficheront un toast. */
body.pos-readonly { padding-bottom: 48px; }
body.pos-readonly .btn-pay,
body.pos-readonly .btn-send,
body.pos-readonly .btn-close-z,
body.pos-readonly .order-actions .btn-primary,
body.pos-readonly .payment-actions .btn-primary {
  opacity: 0.45;
  pointer-events: none;
  filter: grayscale(0.4);
}
body.pos-readonly .order-actions::after,
body.pos-readonly .payment-actions::after {
  content: 'Mode visualisation — opération désactivée';
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: #f57c00;
  font-style: italic;
}

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--foreground) 18%, transparent);
  border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--foreground) 30%, transparent);
}

/* ---------- Stub / placeholder ---------- */
.stub {
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 16px;
  height: 100%; color: var(--txt-3);
}
.stub .ico { font-size: 56px; }
.stub h2 { color: var(--foreground); margin: 0; font-weight: 600; }
.stub p { max-width: 540px; text-align: center; line-height: 1.6; color: var(--txt-2); }

/* ---------- Tables data (BO produits, audit, etc.) ---------- */
table.data, .data {
  width: 100%; border-collapse: collapse;
  background: var(--card); border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: var(--shadow-sm);
}
table.data thead, .data thead { background: var(--surface-h); }
table.data th, .data th {
  text-align: left; padding: 12px 16px;
  font-size: 11px; font-weight: 600; color: var(--txt-2);
  text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
}
table.data td, .data td {
  padding: 12px 16px; border-top: 1px solid var(--border);
  font-size: 14px; color: var(--foreground);
}
table.data tr:hover td, .data tr:hover td {
  background: color-mix(in srgb, var(--primary) 6%, transparent);
}
/* #117 : espacement renforcé sur les tableaux de reporting (colonnes étaient
   collées dans des cards étroites). On donne du padding latéral + on impose
   nowrap sur les cellules numériques pour éviter les retours à la ligne. */
table.data th + th, .data th + th,
table.data td + td, .data td + td {
  padding-left: 24px;
}
table.data th[style*="text-align:right"], .data th[style*="text-align:right"],
table.data td[style*="text-align:right"], .data td[style*="text-align:right"],
table.data th[style*="text-align:center"], .data th[style*="text-align:center"],
table.data td[style*="text-align:center"], .data td[style*="text-align:center"] {
  white-space: nowrap;
}

/* ---------- empty-state ---------- */
.empty-state {
  text-align: center; padding: 32px;
  color: var(--txt-3); font-size: 13px;
}
