/* ============================================================
   QR VENTE — Design System
   Palette : encre #0F172A · indigo signature #6366F1 · vert #10B981
   Typo : Manrope (display) + Inter (UI)
   ============================================================ */

:root {
  --ink:        #0F172A;
  --ink-soft:   #1E293B;
  --indigo:     #6366F1;
  --indigo-d:   #4F46E5;
  --green:      #10B981;
  --amber:      #F59E0B;
  --red:        #EF4444;
  --bg:         #F8FAFC;
  --card:       #FFFFFF;
  --border:     #E2E8F0;
  --text:       #1E293B;
  --text-muted: #64748B;

  --font-display: 'Manrope', sans-serif;
  --font-body: 'Inter', sans-serif;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, .08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .12);
}

* { box-sizing: border-box; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, .display-font {
  font-family: var(--font-display);
  color: var(--ink);
  letter-spacing: -0.01em;
}

a { text-decoration: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ============================================================
   LAYOUT SHELL
   ============================================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 264px;
  background: var(--ink);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1040;
  transition: transform .25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.brand-mark {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--indigo), #818CF8);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 1.05rem; }
.brand-sub { font-size: .72rem; color: #94A3B8; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
}

.nav-section {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #64748B;
  font-weight: 700;
  padding: 16px 12px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: #CBD5E1;
  font-size: .9rem;
  font-weight: 500;
  margin-bottom: 2px;
  transition: background .15s, color .15s;
}
.nav-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.active {
  background: rgba(99,102,241,.18);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--indigo);
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.app-main {
  flex: 1;
  margin-left: 264px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* TOPBAR */
.topbar {
  height: 68px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 1020;
}
.topbar-title { font-size: 1.15rem; font-weight: 800; margin: 0; flex: 1; }
.btn-burger {
  display: none;
  border: none; background: none; font-size: 1.4rem; color: var(--ink);
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.btn-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  color: var(--ink-soft);
}
.notif-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--red);
  color: #fff;
  font-size: .62rem;
  font-weight: 700;
  min-width: 18px; height: 18px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
  border: 2px solid #fff;
}
.notif-dropdown { width: 340px; max-height: 420px; overflow-y: auto; padding: 6px; }
.notif-item { display: flex; gap: 10px; padding: 10px; border-radius: var(--radius-sm); }
.notif-item:hover { background: var(--bg); }
.notif-item .notif-icon {
  width: 34px; height: 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: .95rem;
}

.user-chip {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 12px;
  padding: 6px 10px;
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--indigo);
  color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.user-info { flex-direction: column; line-height: 1.1; text-align: left; }
.user-name { font-size: .82rem; font-weight: 700; color: var(--ink); }
.user-role { font-size: .7rem; color: var(--text-muted); }

.app-content {
  padding: 24px;
  flex: 1;
}

@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .btn-burger { display: block; }
}

/* ============================================================
   COMPONENTS
   ============================================================ */
.card-stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.card-stat .stat-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  margin-bottom: 12px;
}
.card-stat .stat-value {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.1;
}
.card-stat .stat-label { font-size: .82rem; color: var(--text-muted); margin-top: 2px; }
.card-stat .stat-trend { font-size: .78rem; font-weight: 700; margin-top: 8px; }

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.panel-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-header h2, .panel-header h5 { margin: 0; font-size: 1.02rem; font-weight: 800; }
.panel-body { padding: 20px; }

.btn-brand {
  background: var(--indigo);
  border-color: var(--indigo);
  color: #fff;
  font-weight: 700;
  border-radius: 10px;
}
.btn-brand:hover { background: var(--indigo-d); border-color: var(--indigo-d); color: #fff; }

.btn-soft {
  background: #EEF2FF;
  border: 1px solid #E0E7FF;
  color: var(--indigo-d);
  font-weight: 700;
  border-radius: 10px;
}
.btn-soft:hover { background: #E0E7FF; color: var(--indigo-d); }

.badge-stock-ok { background: #DCFCE7; color: #15803D; font-weight: 700; }
.badge-stock-faible { background: #FEF3C7; color: #B45309; font-weight: 700; }
.badge-stock-rupture { background: #FEE2E2; color: #B91C1C; font-weight: 700; }

.table-app { font-size: .88rem; }
.table-app thead th {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom-width: 1px;
  font-weight: 700;
}
.table-app td { vertical-align: middle; }

.form-label { font-size: .85rem; font-weight: 600; color: var(--ink-soft); }
.form-control, .form-select {
  border-radius: 9px;
  border-color: var(--border);
  font-size: .9rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

/* ============================================================
   SIGNATURE — Viseur de scan (utilisé sur login, scanner, cards QR)
   ============================================================ */
.scan-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: 380px;
  margin: 0 auto;
  border-radius: 18px;
  overflow: hidden;
  background: #000;
}
.scan-frame video, .scan-frame canvas { width: 100%; height: 100%; object-fit: cover; }
.scan-corner {
  position: absolute;
  width: 34px; height: 34px;
  border: 3px solid var(--green);
  opacity: .9;
}
.scan-corner.tl { top: 14px; left: 14px; border-right: none; border-bottom: none; border-radius: 8px 0 0 0; }
.scan-corner.tr { top: 14px; right: 14px; border-left: none; border-bottom: none; border-radius: 0 8px 0 0; }
.scan-corner.bl { bottom: 14px; left: 14px; border-right: none; border-top: none; border-radius: 0 0 0 8px; }
.scan-corner.br { bottom: 14px; right: 14px; border-left: none; border-top: none; border-radius: 0 0 8px 0; }
.scan-line {
  position: absolute;
  left: 14px; right: 14px;
  height: 2px;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: scanmove 2.1s ease-in-out infinite;
}
@keyframes scanmove {
  0%, 100% { top: 16%; }
  50% { top: 84%; }
}

/* AUTH PAGES */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  background-image: radial-gradient(circle at 20% 20%, rgba(99,102,241,.25), transparent 45%),
                     radial-gradient(circle at 80% 80%, rgba(16,185,129,.18), transparent 45%);
  padding: 20px;
}
.auth-card {
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  padding: 36px 32px;
}

/* SCANNER PAGES */
.scan-result-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--card);
}

/* Print invoice helper (screen preview) */
.invoice-preview {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  font-size: .9rem;
}

/* Utility */
.text-indigo { color: var(--indigo); }
.bg-indigo-soft { background: #EEF2FF; }
.cursor-pointer { cursor: pointer; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state i { font-size: 2.4rem; color: #CBD5E1; margin-bottom: 12px; display: block; }
