/* ============================================================
   QR Manager — Styles complets
   Dark theme : Indigo + Cyan sur fond graphite
   ============================================================ */

/* ---------- Google Fonts import (avec fallback système) --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ---------- Variables CSS ---------------------------------- */
:root {
  --bg:          #0f1117;
  --bg2:         #161b27;
  --bg3:         #1e2535;
  --border:      #2a3347;
  --text:        #e2e8f0;
  --text2:       #8899b4;
  --text3:       #556380;
  --primary:     #6366f1;
  --primary-h:   #818cf8;
  --primary-d:   #4f46e5;
  --accent:      #06b6d4;
  --accent-h:    #22d3ee;
  --success:     #10b981;
  --warning:     #f59e0b;
  --danger:      #ef4444;
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 4px 24px rgba(0,0,0,.5);
  --shadow-lg:   0 8px 48px rgba(0,0,0,.7);
  --trans:       .2s cubic-bezier(.4,0,.2,1);
}

/* ---------- Reset ----------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: #0f1117;
  background-color: var(--bg);
  color: #e2e8f0;
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary-h); text-decoration: none; transition: color var(--trans); }
a:hover { color: var(--accent-h); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ---------- Scrollbar ------------------------------------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ---------- Layout ---------------------------------------- */
.container { max-width: 1280px; margin: 0 auto; padding: 0 24px; }
.page-wrap  { padding: 32px 0 64px; }

/* ---------- Navbar ---------------------------------------- */
.navbar {
  background: #161b27;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.3px;
}
.brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #fff;
  flex-shrink: 0;
}
.navbar-nav { display: flex; align-items: center; gap: 4px; }
.nav-link {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  font-size: .875rem;
  font-weight: 500;
  transition: all var(--trans);
  display: inline-block;
}
.nav-link:hover { background: var(--bg3); color: var(--text); }
.nav-link.active { background: var(--bg3); color: var(--text); }

/* ---------- Cards ----------------------------------------- */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color var(--trans);
}
.card:hover { border-color: #3d4f6b; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 10px;
}
.card-title { font-size: 1rem; font-weight: 600; color: var(--text); }

/* ---------- Stat cards ------------------------------------ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}
@media (max-width: 900px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .stat-grid { grid-template-columns: 1fr; } }

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform var(--trans), box-shadow var(--trans);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.stat-icon.indigo  { background: rgba(99,102,241,.15); }
.stat-icon.cyan    { background: rgba(6,182,212,.15); }
.stat-icon.green   { background: rgba(16,185,129,.15); }
.stat-icon.orange  { background: rgba(245,158,11,.15); }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; color: var(--text); }
.stat-label {
  font-size: .75rem;
  color: var(--text2);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

/* ---------- Buttons --------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--trans);
  user-select: none;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover {
  background: var(--primary-h);
  border-color: var(--primary-h);
  color: #fff;
}
.btn-outline {
  background: transparent;
  color: var(--text2);
  border-color: var(--border);
}
.btn-outline:hover {
  background: var(--bg3);
  color: var(--text);
  border-color: var(--text3);
}
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; color: #fff; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-accent { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 600; }
.btn-accent:hover { background: var(--accent-h); color: #000; }
.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-lg { padding: 13px 28px; font-size: 1rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }

/* ---------- Forms ----------------------------------------- */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block;
  margin-bottom: 7px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color var(--trans), box-shadow var(--trans);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.2);
}
.form-control::placeholder { color: var(--text3); }
.form-control[type="file"] { padding: 8px 12px; cursor: pointer; }
.form-hint { font-size: .8rem; color: var(--text3); margin-top: 5px; }

/* ---------- Table ----------------------------------------- */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
table { width: 100%; border-collapse: collapse; min-width: 600px; }
thead th {
  background: var(--bg3);
  padding: 12px 16px;
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}
tbody tr {
  border-top: 1px solid var(--border);
  transition: background var(--trans);
}
tbody tr:hover { background: var(--bg3); }
tbody td { padding: 14px 16px; vertical-align: middle; font-size: .875rem; }

.td-code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  font-size: .78rem;
  color: var(--accent);
  background: rgba(6,182,212,.1);
  padding: 3px 8px;
  border-radius: 4px;
  display: inline-block;
}
.td-url {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text2);
  display: block;
}
.td-date { color: var(--text3); font-size: .8rem; white-space: nowrap; }
.td-scans { font-weight: 700; color: var(--primary-h); }
.td-actions { display: flex; gap: 6px; flex-wrap: nowrap; align-items: center; }

/* ---------- Badge ----------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-primary { background: rgba(99,102,241,.2); color: var(--primary-h); }
.badge-success { background: rgba(16,185,129,.2); color: var(--success); }
.badge-warning { background: rgba(245,158,11,.2); color: var(--warning); }
.badge-danger  { background: rgba(239,68,68,.2);  color: var(--danger); }
.badge-cyan    { background: rgba(6,182,212,.2);  color: var(--accent); }

/* ---------- Search ---------------------------------------- */
.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  align-items: center;
  flex-wrap: wrap;
}
.search-bar .form-control { max-width: 400px; }

/* ---------- Pagination ------------------------------------ */
.pagination {
  display: flex;
  gap: 4px;
  margin-top: 20px;
  justify-content: center;
  flex-wrap: wrap;
}
.page-link {
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: .875rem;
  cursor: pointer;
  transition: all var(--trans);
  text-decoration: none;
  display: inline-block;
}
.page-link:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-link.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-link.disabled { opacity: .4; pointer-events: none; }

/* ---------- Modal ----------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn .2s ease;
}
@keyframes modalIn {
  from { transform: scale(.95) translateY(10px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.modal-close {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 1.3rem;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all var(--trans);
}
.modal-close:hover { background: var(--bg3); color: var(--text); }
.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
  flex-wrap: wrap;
}

/* ---------- QR Preview ------------------------------------ */
.qr-preview-wrap {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}
.qr-canvas-box {
  background: #fff;
  border-radius: 10px;
  padding: 12px;
  display: inline-block;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
  line-height: 0;
}
.qr-code-label {
  font-family: monospace;
  font-size: .85rem;
  color: var(--accent);
  background: rgba(6,182,212,.12);
  padding: 4px 12px;
  border-radius: 4px;
  display: inline-block;
}
.qr-redirect-url { font-size: .8rem; color: var(--text3); word-break: break-all; }

/* ---------- Hero ------------------------------------------ */
.hero { text-align: center; padding: 64px 0 48px; }
.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(99,102,241,.12);
  border: 1px solid rgba(99,102,241,.3);
  color: var(--primary-h);
  font-size: .78rem;
  font-weight: 600;
  padding: 5px 16px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 20px;
}
.hero-title {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -.04em;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--text) 40%, var(--primary-h));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: var(--text); /* fallback */
}
.hero-sub {
  color: var(--text2);
  font-size: 1rem;
  max-width: 520px;
  margin: 0 auto 36px;
}

/* ---------- Generator grid -------------------------------- */
.generator-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  max-width: 960px;
  margin: 0 auto;
}
@media (max-width: 720px) { .generator-grid { grid-template-columns: 1fr; } }

/* ---------- Admin two-col layout -------------------------- */
.admin-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 960px) { .admin-grid { grid-template-columns: 1fr; } }

/* ---------- Spinner --------------------------------------- */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Alert ----------------------------------------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 20px;
  line-height: 1.5;
}
.alert-success { background: rgba(16,185,129,.12); border: 1px solid rgba(16,185,129,.3); color: #34d399; }
.alert-danger   { background: rgba(239,68,68,.12);  border: 1px solid rgba(239,68,68,.3);  color: #f87171; }
.alert-info     { background: rgba(6,182,212,.12);  border: 1px solid rgba(6,182,212,.3);  color: var(--accent-h); }

/* ---------- Charts ---------------------------------------- */
.chart-wrap { position: relative; height: 240px; width: 100%; }
.chart-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.chart-tab {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  transition: all var(--trans);
}
.chart-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- Top list -------------------------------------- */
.top-list { list-style: none; }
.top-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.top-list li:last-child { border-bottom: none; }
.top-rank {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  color: var(--text2);
  flex-shrink: 0;
}
.top-rank.gold   { background: rgba(245,158,11,.2); color: var(--warning); }
.top-rank.silver { background: rgba(148,163,184,.2); color: #94a3b8; }
.top-rank.bronze { background: rgba(180,84,4,.2); color: #cd7f32; }
.top-label { flex: 1; font-size: .85rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-count { font-weight: 700; color: var(--primary-h); font-size: .875rem; flex-shrink: 0; }

/* ---------- Progress bar ---------------------------------- */
.progress-bar-wrap {
  background: var(--bg3);
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
  margin-top: 5px;
}
.progress-bar {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width .6s ease;
}

/* ---------- Copy button ----------------------------------- */
.copy-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text3);
  padding: 3px 9px;
  border-radius: 4px;
  cursor: pointer;
  font-size: .72rem;
  transition: all var(--trans);
  white-space: nowrap;
  flex-shrink: 0;
}
.copy-btn:hover { border-color: var(--accent); color: var(--accent); }
.copy-btn.copied { border-color: var(--success); color: var(--success); }

/* ---------- Device donut ---------------------------------- */
.device-bar { display: flex; gap: 20px; justify-content: center; margin-top: 12px; }
.device-item { text-align: center; }
.device-icon { font-size: 1.5rem; }
.device-pct  { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.device-name { font-size: .72rem; color: var(--text3); }

/* ---------- Empty state ----------------------------------- */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text3); }
.empty-state .icon { font-size: 2.5rem; margin-bottom: 12px; opacity: .35; }
.empty-state p { max-width: 300px; margin: 0 auto; font-size: .9rem; }

/* ---------- Footer ---------------------------------------- */
.footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
  margin-top: 64px;
  text-align: center;
  color: var(--text3);
  font-size: .8rem;
}

/* ---------- Animations ------------------------------------ */
.fade-in { animation: fadeIn .35s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Responsive misc ------------------------------- */
@media (max-width: 600px) {
  .container { padding: 0 16px; }
  .hero { padding: 36px 0 24px; }
  .navbar .container { height: 56px; }
  .modal { padding: 20px; }
  .page-wrap { padding: 20px 0 48px; }
  .td-actions .btn span.btn-label { display: none; }
}

/* ---------- QR mini dans la liste (80×80) ----------------- */
.qr-mini-wrap {
  width: 80px;
  height: 80px;
  background: #fff;
  border-radius: 6px;
  padding: 4px;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.qr-mini-wrap img,
.qr-mini-wrap canvas { width: 72px !important; height: 72px !important; }

/* ---------- Info box (edit page) -------------------------- */
.info-box {
  background: rgba(6,182,212,.08);
  border: 1px solid rgba(6,182,212,.25);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: .875rem;
  color: var(--text2);
  margin-bottom: 20px;
}
.info-box strong { color: var(--accent-h); }

/* ---------- Inline flex util ------------------------------ */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.flex-wrap { flex-wrap: wrap; }
.w-full { width: 100%; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
