/* ============================================================
   DATAZAD QR & NFC Manager - Design System
   SaaS Premium · Light / Dark · Responsive
   ============================================================ */

:root {
  --primary: #4361ee;
  --primary-600: #3a56d4;
  --primary-soft: rgba(67, 97, 238, .12);
  --sidebar-w: 264px;
  --sidebar-w-collapsed: 78px;

  --bg-body: #f1f4f9;
  --bg-surface: #ffffff;
  --bg-surface-2: #f8fafc;
  --border-color: #e5e9f2;
  --text-color: #1e293b;
  --text-muted: #64748b;
  --shadow-card: 0 1px 3px rgba(15, 23, 42, .06), 0 8px 24px -12px rgba(15, 23, 42, .12);
  --shadow-hover: 0 4px 8px rgba(15, 23, 42, .06), 0 16px 32px -12px rgba(67, 97, 238, .22);
  --radius: 14px;
  --sidebar-bg: #111827;
  --sidebar-text: #9ca3af;
  --sidebar-text-active: #ffffff;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --info: #0ea5e9;
}

[data-theme="dark"] {
  --bg-body: #0b1220;
  --bg-surface: #141c2e;
  --bg-surface-2: #0f172a;
  --border-color: #223049;
  --text-color: #e2e8f0;
  --text-muted: #94a3b8;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, .4), 0 8px 24px -12px rgba(0, 0, 0, .5);
  --shadow-hover: 0 4px 8px rgba(0, 0, 0, .4), 0 16px 32px -12px rgba(0, 0, 0, .6);
  --sidebar-bg: #0a0f1c;
  --sidebar-text: #8b96ad;
  --sidebar-text-active: #ffffff;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  background: var(--bg-body);
  color: var(--text-color);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: .925rem;
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s ease, color .25s ease;
}

/* ---------- Wrapper ---------- */
.app-wrapper { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: width .25s ease, transform .25s ease;
}
body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
.sidebar-brand {
  display: flex; align-items: center; gap: .65rem;
  padding: 1.1rem 1.1rem .9rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand-mark {
  width: 40px; height: 40px; flex: 0 0 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #4361ee, #7209b7);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: .95rem;
  box-shadow: 0 6px 16px -6px rgba(67,97,238,.6);
}
.sidebar-logo { width: 40px; height: 40px; object-fit: contain; border-radius: 10px; }
.brand-text strong { display: block; color: #fff; font-size: .95rem; line-height: 1.1; }
.brand-text small { font-size: .7rem; color: var(--sidebar-text); }
body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .sidebar-footer,
body.sidebar-collapsed .nav-link span,
body.sidebar-collapsed .nav-section { display: none; }
body.sidebar-collapsed .sidebar-brand { justify-content: center; padding-inline: .5rem; }
body.sidebar-collapsed .sidebar-nav { overflow: visible; }
body.sidebar-collapsed .nav-link { justify-content: center; }
.sidebar-close { color: #fff; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem .6rem 1rem; scrollbar-width: thin; }
.nav-section {
  font-size: .66rem; text-transform: uppercase; letter-spacing: .08em;
  color: #6b7280; padding: 1rem .75rem .4rem; font-weight: 700;
}
.nav-link {
  display: flex; align-items: center; gap: .7rem;
  padding: .58rem .75rem; margin-bottom: 2px;
  border-radius: 10px; color: var(--sidebar-text);
  text-decoration: none; font-weight: 500; font-size: .88rem;
  transition: background .18s ease, color .18s ease;
  position: relative;
}
.nav-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.nav-link:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-link.active {
  color: var(--sidebar-text-active);
  background: linear-gradient(90deg, rgba(67,97,238,.35), rgba(67,97,238,.08));
}
.nav-link.active::before {
  content: ""; position: absolute; inset-inline-start: -0.6rem; top: 20%; bottom: 20%;
  width: 3px; border-radius: 3px; background: var(--primary);
}
.sidebar-footer {
  padding: .9rem 1rem; border-top: 1px solid rgba(255,255,255,.06);
  background: rgba(0,0,0,.18);
}

/* ---------- Main ---------- */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex; flex-direction: column; min-height: 100vh;
  transition: margin-left .25s ease;
}
body.sidebar-collapsed .main-content { margin-left: var(--sidebar-w-collapsed); }

.topbar {
  position: sticky; top: 0; z-index: 1030;
  display: flex; align-items: center; gap: .5rem;
  padding: .7rem 1.25rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(8px);
}
.breadcrumb-top { font-size: .82rem; }

.topbar-search { position: relative; }
.topbar-search i { position: absolute; inset-inline-start: .7rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: .85rem; }
.topbar-search input { padding-inline-start: 2rem; width: 230px; background: var(--bg-surface-2); border-color: var(--border-color); }

.page-content { flex: 1; padding: 1.35rem 1.25rem 2rem; max-width: 1500px; width: 100%; margin-inline: auto; }
.main-footer {
  padding: .8rem 1.25rem; display: flex; justify-content: space-between; align-items: center;
  font-size: .78rem; color: var(--text-muted); border-top: 1px solid var(--border-color);
  background: var(--bg-surface);
}

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 1035; }

/* ---------- Boutons & icônes ---------- */
.btn-icon {
  width: 38px; height: 38px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-surface-2); color: var(--text-color);
  border: 1px solid var(--border-color); font-size: 1rem;
}
.btn-icon:hover { color: var(--primary); border-color: var(--primary); }
[data-theme="dark"] .theme-ico-dark { display: none; }
[data-theme="light"] .theme-ico-light { display: none; }

.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover, .btn-primary:focus { background: var(--primary-600); border-color: var(--primary-600); }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); }

/* ---------- Cartes ---------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}
.card-header {
  background: transparent; border-bottom: 1px solid var(--border-color);
  padding: 1rem 1.25rem; font-weight: 700;
}
.card-body { padding: 1.25rem; }
.card-title { font-size: 1rem; font-weight: 700; }
.card-stat {
  border: 0; overflow: hidden; position: relative;
  transition: transform .2s ease, box-shadow .2s ease;
}
.card-stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.card-stat .stat-icon {
  width: 46px; height: 46px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 1.3rem;
}
.stat-value { font-size: 1.55rem; font-weight: 800; line-height: 1.2; }
.stat-label { font-size: .78rem; color: var(--text-muted); font-weight: 600; }
.stat-trend { font-size: .75rem; font-weight: 600; }

.bg-soft-primary { background: rgba(67,97,238,.12); color: #4361ee; }
.bg-soft-success { background: rgba(22,163,74,.12); color: #16a34a; }
.bg-soft-warning { background: rgba(217,119,6,.12); color: #d97706; }
.bg-soft-danger { background: rgba(220,38,38,.12); color: #dc2626; }
.bg-soft-info { background: rgba(14,165,233,.12); color: #0ea5e9; }
.bg-soft-purple { background: rgba(139,92,246,.12); color: #8b5cf6; }

/* ---------- Tableaux ---------- */
.table { --bs-table-bg: transparent; --bs-table-color: var(--text-color); }
.table thead th {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); border-bottom-width: 1px; white-space: nowrap;
}
.table td { vertical-align: middle; }
.table-hover tbody tr:hover { background: var(--bg-surface-2); }

.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #7209b7);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem; flex-shrink: 0;
}
.avatar-sm { width: 32px; height: 32px; font-size: .75rem; }

/* ---------- Badges ---------- */
.badge { font-weight: 600; padding: .4em .65em; border-radius: 8px; font-size: .72rem; }

/* ---------- Formulaires ---------- */
.form-control, .form-select {
  background: var(--bg-surface);
  border-color: var(--border-color);
  color: var(--text-color);
  border-radius: 10px;
  padding: .5rem .75rem;
  font-size: .9rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 .2rem rgba(67,97,238,.15);
  background: var(--bg-surface);
  color: var(--text-color);
}
.form-label { font-weight: 600; font-size: .8rem; color: var(--text-muted); }
.form-text { color: var(--text-muted); }

/* ---------- Animations ---------- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in-up { animation: fadeInUp .35s ease both; }
.stagger > * { animation: fadeInUp .35s ease both; }
.stagger > *:nth-child(1) { animation-delay: .02s; }
.stagger > *:nth-child(2) { animation-delay: .06s; }
.stagger > *:nth-child(3) { animation-delay: .10s; }
.stagger > *:nth-child(4) { animation-delay: .14s; }
.stagger > *:nth-child(5) { animation-delay: .18s; }
.stagger > *:nth-child(6) { animation-delay: .22s; }

/* ---------- Éléments divers ---------- */
.dropdown-menu {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
}
.dropdown-item { color: var(--text-color); }
.dropdown-item:hover { background: var(--bg-surface-2); color: var(--primary); }
.dropdown-item.active { background: var(--primary); }

.alert { border-radius: 12px; border: 0; }

.empty-state {
  text-align: center; padding: 3rem 1rem; color: var(--text-muted);
}
.empty-state i { font-size: 3rem; opacity: .35; display: block; margin-bottom: .75rem; }

.qr-frame { border: 1px solid var(--border-color); border-radius: 12px; padding: .5rem; background: #fff; display: inline-block; }
.qr-frame img { max-width: 200px; height: auto; border-radius: 6px; }

.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
@media (max-width: 575.98px) { .toolbar .btn, .toolbar form { flex: 1 1 100%; } }

.page-title { font-size: 1.35rem; font-weight: 800; margin: 0; }
.page-subtitle { font-size: .82rem; color: var(--text-muted); }

/* Print */
@media print {
  .sidebar, .topbar, .main-footer, .no-print { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-content { padding: 0; }
  body { background: #fff; }
}

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-w) !important; }
  body.sidebar-collapsed .sidebar { width: var(--sidebar-w) !important; transform: translateX(0); }
  body.sidebar-collapsed .brand-text, body.sidebar-collapsed .sidebar-footer,
  body.sidebar-collapsed .nav-link span, body.sidebar-collapsed .nav-section { display: revert; }
  body.sidebar-collapsed .sidebar-brand { justify-content: flex-start; padding-inline: 1.1rem; }
  body.sidebar-collapsed .sidebar-nav { overflow-y: auto; }
  body.sidebar-collapsed .nav-link { justify-content: flex-start; }
  .main-content { margin-left: 0 !important; }
  .sidebar-overlay.show { display: block; }
}
[dir="rtl"] .sidebar { inset: 0 0 0 auto; }
[dir="rtl"] .main-content { margin-right: var(--sidebar-w); margin-left: 0; }
[dir="rtl"] .sidebar-overlay { inset: 0; }

/* Toast */
.toast-container { z-index: 2000; }