@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ── CSS Variables ──────────────────────────────────────────────── */
:root {
  --primary:       #6366f1;
  --primary-dark:  #4f46e5;
  --primary-light: #818cf8;
  --secondary:     #8b5cf6;
  --success:       #10b981;
  --warning:       #f59e0b;
  --danger:        #ef4444;
  --info:          #06b6d4;

  --bg:            #0f0f1a;
  --bg-card:       #1a1a2e;
  --bg-elevated:   #242438;
  --border:        rgba(255,255,255,.08);
  --border-strong: rgba(255,255,255,.15);

  --text:          #f8fafc;
  --text-muted:    #94a3b8;
  --text-dim:      #64748b;

  --radius:        12px;
  --radius-sm:     8px;
  --radius-lg:     18px;
  --radius-xl:     24px;
  --shadow:        0 4px 24px rgba(0,0,0,.4);
  --shadow-lg:     0 8px 40px rgba(0,0,0,.5);

  --bg-card-hover: rgba(255,255,255,.04);
  --sidebar-w:     260px;
  --transition:    0.2s ease;
}

/* ── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--primary-light); text-decoration: none; }
a:hover { color: var(--primary); }
img { max-width: 100%; height: auto; display: block; }
button, input, select, textarea { font-family: inherit; }

/* ── Typography ─────────────────────────────────────────────────── */
h1 { font-size: clamp(1.75rem, 4vw, 2.75rem); font-weight: 800; line-height: 1.2; }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 700; }
h3 { font-size: 1.25rem; font-weight: 600; }
h4 { font-size: 1.05rem; font-weight: 600; }
p  { color: var(--text-muted); }

/* ── Containers ─────────────────────────────────────────────────── */
.container      { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }
.container-sm   { max-width: 720px;  margin: 0 auto; padding: 0 1.5rem; }
.container-xs   { max-width: 480px;  margin: 0 auto; padding: 0 1.5rem; }

/* ── Cards ──────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.card-hover:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow); }
.card-title { font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: 1.25rem; display: flex; align-items: center; gap: .6rem; }
.card-glass {
  background: rgba(255,255,255,.04);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
}

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .65rem 1.4rem;
  font-size: .9rem; font-weight: 600;
  border: none; border-radius: var(--radius); cursor: pointer;
  transition: all var(--transition); white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff; box-shadow: 0 4px 14px rgba(99,102,241,.4);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(99,102,241,.55); color: #fff; }
.btn-outline {
  background: transparent; color: var(--text);
  border: 1px solid var(--border-strong);
}
.btn-outline:hover { background: var(--bg-elevated); border-color: var(--primary); color: var(--primary-light); }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: .45rem 1rem; font-size: .82rem; }
.btn-lg { padding: .85rem 2rem; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

/* ── Forms ──────────────────────────────────────────────────────── */
.form-group  { display: flex; flex-direction: column; gap: .45rem; margin-bottom: 1.25rem; }
.form-label  { font-size: .85rem; font-weight: 600; color: var(--text-muted); }
.form-hint   { font-size: .78rem; color: var(--text-dim); margin-top: .2rem; }
.form-control, .form-input {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: .7rem 1rem;
  font-size: .9rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
  font-family: inherit;
}
.form-control:focus, .form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.2);
}
.form-control::placeholder, .form-input::placeholder { color: var(--text-dim); }
textarea.form-control, textarea.form-input { resize: vertical; min-height: 100px; }
select.form-control, select.form-input { cursor: pointer; }
input[type=file].form-input { padding: .55rem .75rem; cursor: pointer; }

/* ── Alerts ─────────────────────────────────────────────────────── */
.alert {
  padding: 1rem 1.25rem; border-radius: var(--radius);
  font-size: .9rem; font-weight: 500;
  display: flex; align-items: flex-start; gap: .75rem;
  margin-bottom: 1rem;
}
.alert-success { background: rgba(16,185,129,.12); border: 1px solid rgba(16,185,129,.25); color: #6ee7b7; }
.alert-error   { background: rgba(239,68,68,.12);  border: 1px solid rgba(239,68,68,.25);  color: #fca5a5; }
.alert-info    { background: rgba(6,182,212,.12);  border: 1px solid rgba(6,182,212,.25);  color: #67e8f9; }
.alert-warning { background: rgba(245,158,11,.12); border: 1px solid rgba(245,158,11,.25); color: #fcd34d; }

/* ── Tables ─────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); }
table       { width: 100%; border-collapse: collapse; }
thead th    { background: var(--bg-elevated); padding: .9rem 1.25rem; text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); }
tbody td    { padding: .9rem 1.25rem; border-top: 1px solid var(--border); font-size: .9rem; }
tbody tr:hover td { background: var(--bg-elevated); }

/* ── Badge ──────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .25rem .75rem; border-radius: 999px;
  font-size: .75rem; font-weight: 600; line-height: 1;
}
.badge-success { background: rgba(16,185,129,.15); color: #6ee7b7; }
.badge-danger  { background: rgba(239,68,68,.15);  color: #fca5a5; }
.badge-warning { background: rgba(245,158,11,.15); color: #fcd34d; }
.badge-info    { background: rgba(6,182,212,.15);  color: #67e8f9; }
.badge-purple  { background: rgba(139,92,246,.15); color: #c4b5fd; }

/* ── Stat Cards ─────────────────────────────────────────────────── */
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.5rem;
  display: flex; flex-direction: column; gap: .5rem;
  transition: all var(--transition);
}
.stat-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-icon  { width: 48px; height: 48px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; font-size: 1.4rem; }
.stat-value { font-size: 2rem; font-weight: 800; color: var(--text); }
.stat-label { font-size: .83rem; color: var(--text-muted); }

/* ── Sidebar ────────────────────────────────────────────────────── */
.layout-sidebar { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: .75rem;
}
.sidebar-brand-logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; color: #fff; font-weight: 800;
}
.sidebar-brand-name { font-weight: 800; font-size: 1.1rem; }
.sidebar-nav { flex: 1; padding: 1rem .75rem; }
.nav-section { margin-bottom: 1.5rem; }
.nav-section-title { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--text-dim); padding: 0 .5rem; margin-bottom: .5rem; }
.nav-link {
  display: flex; align-items: center; gap: .75rem;
  padding: .65rem .85rem; border-radius: var(--radius);
  color: var(--text-muted); font-size: .88rem; font-weight: 500;
  transition: all var(--transition); margin-bottom: 2px;
}
.nav-link:hover, .nav-link.active {
  background: rgba(99,102,241,.12); color: var(--primary-light);
}
.nav-link.active { font-weight: 600; }
.nav-icon { font-size: 1.1rem; width: 20px; text-align: center; }
.sidebar-footer { padding: 1rem .75rem; border-top: 1px solid var(--border); }

/* ── Main Content ───────────────────────────────────────────────── */
.main-content {
  flex: 1; margin-left: var(--sidebar-w);
  padding: 2rem; min-width: 0;
}
.page-header { margin-bottom: 2rem; }
.page-title  { font-size: 1.6rem; font-weight: 800; }
.page-subtitle { color: var(--text-muted); font-size: .9rem; margin-top: .25rem; }
.page-actions { margin-top: 1rem; display: flex; gap: .75rem; flex-wrap: wrap; }

/* ── Grid ───────────────────────────────────────────────────────── */
.grid { display: grid; gap: 1.5rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ── Gradient text ──────────────────────────────────────────────── */
.gradient-text {
  background: linear-gradient(135deg, var(--primary-light), #a78bfa);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

/* ── Auth pages ─────────────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, rgba(99,102,241,.18) 0%, transparent 60%),
              linear-gradient(180deg, #0f0f1a 0%, #0a0a14 100%);
  padding: 2rem;
}
.auth-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 2.5rem;
  width: 100%; max-width: 440px;
  box-shadow: 0 24px 80px rgba(0,0,0,.5);
}
.auth-logo {
  display: flex; align-items: center; gap: .75rem; margin-bottom: 2rem;
}
.auth-logo-icon {
  width: 46px; height: 46px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; color: #fff; font-weight: 900;
}
.auth-title { font-size: 1.5rem; font-weight: 800; margin-bottom: .4rem; }
.auth-subtitle { color: var(--text-muted); font-size: .88rem; }
.auth-back-link {
  display: flex; align-items: center; gap: .5rem;
  font-size: .83rem; color: var(--text-dim);
  margin-bottom: 2rem; transition: color var(--transition);
}
.auth-back-link:hover { color: var(--primary-light); }

/* ── Utilities ──────────────────────────────────────────────────── */
.flex        { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .5rem; }  .gap-2 { gap: 1rem; }  .gap-3 { gap: 1.5rem; }
.mt-1 { margin-top: .5rem; }  .mt-2 { margin-top: 1rem; }  .mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.text-small  { font-size: .83rem; }
.w-full { width: 100%; }
.d-none { display: none; }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1024px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; } /* Force single column earlier for multi-column grids */
}

@media (max-width: 768px) {
  /* Sidebar Layout Adjustments */
  .layout-sidebar { flex-direction: column; }
  .sidebar { 
    transform: translateX(-100%); 
    transition: transform .3s cubic-bezier(0.4, 0, 0.2, 1); 
    width: 280px;
    box-shadow: 20px 0 50px rgba(0,0,0,0.5);
  }
  .sidebar.open { transform: translateX(0); }
  
  /* Sidebar Overlay (To close sidebar by clicking outside) */
  .sidebar-overlay-active::after {
    content: '';
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 90;
  }

  .main-content { 
    margin-left: 0; 
    padding: 1rem; 
    overflow-x: hidden;
  }
  
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  
  /* Typography & Spacing */
  .page-header { margin-bottom: 1.5rem; text-align: center; }
  .page-actions { justify-content: center; }
  .page-title { font-size: 1.4rem; }

  /* Table Adjustments */
  .table-wrap { border-radius: var(--radius); }
  
  /* Utilities */
  .hide-on-mobile { display: none !important; }
}

/* Animations Update */
.animate-fade-in { animation: fadeInUp .4s ease both; }
@keyframes fadeInUp { from { opacity:0; transform:translateY(16px); } to { opacity:1; transform:none; } }

/* ── Empty State ─────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 4rem 2rem;
  background: var(--bg-card); border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}
.empty-icon {
  width: 80px; height: 80px; border-radius: 50%;
  background: rgba(99,102,241,.1); border: 1px solid rgba(99,102,241,.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; margin: 0 auto 1.5rem; color: var(--primary-light);
}
.empty-state h3 { font-size: 1.15rem; font-weight: 700; margin-bottom: .5rem; }
.empty-state p  { color: var(--text-muted); font-size: .9rem; margin-bottom: 1.5rem; }

/* ── Animations ─────────────────────────────────────────────────── */
@keyframes fadeInUp { from { opacity:0; transform:translateY(16px); } to { opacity:1; transform:none; } }
@keyframes pulse    { 0%,100%{opacity:1;} 50%{opacity:.6;} }
@keyframes spin     { to { transform: rotate(360deg); } }

.animate-fade-in { animation: fadeInUp .4s ease both; }
.spinner { width: 24px; height: 24px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }

/* ── QR preview ─────────────────────────────────────────────────── */
.qr-preview-box {
  background: #fff; border-radius: var(--radius-lg); padding: 1.5rem;
  display: flex; align-items: center; justify-content: center;
  max-width: 280px; margin: 1.5rem auto 0;
}
.qr-preview-box img { width: 100%; height: auto; }

/* ── Modal ──────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.85);
  backdrop-filter: blur(8px); z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem; opacity: 0; pointer-events: none;
  transition: opacity .25s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal-content {
  background: var(--bg-card); border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl); width: 100%; max-width: 420px;
  padding: 2.5rem; position: relative; text-align: center;
  transform: translateY(20px); transition: transform .25s ease;
}
.modal-overlay.open .modal-content { transform: none; }
.modal-close {
  position: absolute; top: 1.25rem; right: 1.25rem;
  background: transparent; border: none; color: var(--text-dim);
  font-size: 1.5rem; cursor: pointer; line-height: 1;
}
.modal-qr-img {
  background: #fff; padding: 1.5rem; border-radius: var(--radius-lg);
  display: inline-block; margin: 1.5rem 0;
}
.modal-qr-img img { width: 220px; height: 220px; display: block; }
