/* ================================================
   QR Platform — Design System / app.css
   ================================================ */

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

/* ── CSS Variables (Light Theme) ── */
:root {
  --primary:        #6366f1;
  --primary-dark:   #4f46e5;
  --primary-light:  #e0e7ff;
  --secondary:      #8b5cf6;
  --success:        #10b981;
  --danger:         #ef4444;
  --warning:        #f59e0b;
  --info:           #3b82f6;

  --bg:             #f8fafc;
  --bg-card:        #ffffff;
  --bg-sidebar:     #1e1b4b;
  --bg-sidebar-hover: #312e81;

  --text:           #1e293b;
  --text-muted:     #64748b;
  --text-light:     #94a3b8;
  --text-sidebar:   #c7d2fe;
  --text-sidebar-active: #ffffff;

  --border:         #e2e8f0;
  --border-light:   #f1f5f9;

  --shadow-sm:      0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:         0 4px 6px -1px rgba(0,0,0,.08), 0 2px 4px -1px rgba(0,0,0,.04);
  --shadow-md:      0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -2px rgba(0,0,0,.04);
  --shadow-lg:      0 20px 25px -5px rgba(0,0,0,.1), 0 10px 10px -5px rgba(0,0,0,.04);

  --radius-sm:      .375rem;
  --radius:         .75rem;
  --radius-lg:      1rem;
  --radius-xl:      1.5rem;

  --sidebar-w:      260px;
  --navbar-h:       64px;
  --transition:     all .2s ease;
}

/* ── Dark Theme ── */
[data-theme="dark"] {
  --bg:           #0f172a;
  --bg-card:      #1e293b;
  --bg-sidebar:   #0f172a;
  --bg-sidebar-hover: #1e293b;
  --text:         #f1f5f9;
  --text-muted:   #94a3b8;
  --border:       #334155;
  --border-light: #1e293b;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.3);
  --shadow:       0 4px 6px -1px rgba(0,0,0,.3);
  --shadow-md:    0 10px 15px -3px rgba(0,0,0,.4);
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background .3s ease, color .3s ease;
  -webkit-font-smoothing: antialiased;
}

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

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform .3s ease;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  display: flex; align-items: center; gap: .75rem;
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  text-decoration: none;
}

.sidebar-brand .brand-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; color: white;
  box-shadow: 0 4px 12px rgba(99,102,241,.4);
}

.sidebar-brand .brand-name {
  font-size: 1.1rem; font-weight: 700;
  color: white; letter-spacing: -.02em;
}

.sidebar-nav { flex: 1; padding: .75rem 0; }

.nav-section-title {
  font-size: .65rem; font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; color: rgba(199,210,254,.4);
  padding: .75rem 1.25rem .25rem;
}

.sidebar-nav .nav-item { margin: .1rem .75rem; }

.sidebar-nav .nav-link {
  display: flex; align-items: center; gap: .75rem;
  padding: .65rem 1rem;
  color: var(--text-sidebar);
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: .875rem; font-weight: 500;
  transition: var(--transition);
  position: relative;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
  background: var(--bg-sidebar-hover);
  color: var(--text-sidebar-active);
}

.sidebar-nav .nav-link.active::before {
  content: '';
  position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%; border-radius: 2px;
  background: var(--primary);
}

.sidebar-nav .nav-link i { width: 20px; text-align: center; font-size: 1rem; }

.sidebar-nav .nav-badge {
  margin-left: auto;
  background: var(--primary);
  color: white;
  font-size: .65rem; font-weight: 700;
  padding: .15rem .45rem;
  border-radius: 50px;
}

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

.sidebar-user {
  display: flex; align-items: center; gap: .75rem;
  padding: .75rem;
  background: rgba(255,255,255,.06);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.sidebar-user:hover { background: rgba(255,255,255,.1); }

.sidebar-user .user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  font-size: .875rem; font-weight: 700; color: white;
  flex-shrink: 0; overflow: hidden;
}

.sidebar-user .user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-user .user-name { font-size: .8rem; font-weight: 600; color: white; }
.sidebar-user .user-plan { font-size: .7rem; color: var(--text-sidebar); }

/* ── Main Content ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Navbar ── */
.navbar-top {
  height: var(--navbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-sm);
}

.navbar-toggle {
  display: none;
  background: none; border: none;
  font-size: 1.25rem; color: var(--text-muted); cursor: pointer;
}

.navbar-search {
  flex: 1; max-width: 400px;
  position: relative;
}

.navbar-search input {
  width: 100%;
  padding: .5rem .75rem .5rem 2.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem; color: var(--text);
  outline: none; transition: var(--transition);
}

.navbar-search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.navbar-search i { position: absolute; left: .875rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); }

.navbar-actions { margin-left: auto; display: flex; align-items: center; gap: .75rem; }

.btn-icon {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer; transition: var(--transition);
  text-decoration: none; font-size: 1rem;
}

.btn-icon:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

/* ── Page Content ── */
.page-content { padding: 2rem 1.5rem; flex: 1; }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem;
}

.page-title { font-size: 1.5rem; font-weight: 700; letter-spacing: -.03em; }
.page-subtitle { font-size: .875rem; color: var(--text-muted); margin-top: .25rem; }

/* Breadcrumb */
.breadcrumb { background: none; padding: 0; margin-bottom: .5rem; }
.breadcrumb-item { font-size: .8rem; color: var(--text-muted); }
.breadcrumb-item a { color: var(--text-muted); text-decoration: none; }
.breadcrumb-item a:hover { color: var(--primary); }
.breadcrumb-item.active { color: var(--text); }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.card:hover { box-shadow: var(--shadow); }
.card-body { padding: 1.5rem; }
.card-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); }
.card-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); background: var(--border-light); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* ── Stat Cards ── */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex; align-items: center; gap: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  position: relative; overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--stat-color, var(--primary));
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  background: var(--stat-bg, var(--primary-light));
  color: var(--stat-color, var(--primary));
  flex-shrink: 0;
}

.stat-value { font-size: 1.75rem; font-weight: 800; letter-spacing: -.04em; }
.stat-label { font-size: .8rem; color: var(--text-muted); font-weight: 500; }
.stat-trend { font-size: .75rem; font-weight: 600; }
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* ── Buttons ── */
.btn { border-radius: var(--radius-sm); font-weight: 600; font-size: .875rem; transition: var(--transition); letter-spacing: -.01em; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); box-shadow: 0 4px 12px rgba(99,102,241,.35); }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: white; }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.75rem; font-size: 1rem; }

/* ── QR Card Grid ── */
.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.25rem; }

.qr-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: var(--transition);
  position: relative;
}

.qr-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--primary); }

.qr-card-img {
  background: var(--border-light);
  padding: 1.5rem;
  display: flex; align-items: center; justify-content: center;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.qr-card-img img { width: 120px; height: 120px; object-fit: contain; }

.qr-card-badge {
  position: absolute; top: .75rem; right: .75rem;
  font-size: .65rem; font-weight: 700; padding: .2rem .5rem;
  border-radius: 50px;
}

.qr-card-favorite {
  position: absolute; top: .75rem; left: .75rem;
  background: none; border: none; cursor: pointer;
  font-size: 1.1rem; color: var(--text-light);
  transition: var(--transition);
}

.qr-card-favorite.active,
.qr-card-favorite:hover { color: var(--warning); }

.qr-card-body { padding: 1rem; }
.qr-card-title { font-size: .9rem; font-weight: 600; margin-bottom: .25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qr-card-url { font-size: .75rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qr-card-scans { font-size: .75rem; color: var(--text-muted); display: flex; align-items: center; gap: .25rem; margin-top: .5rem; }

.qr-card-actions {
  padding: .75rem 1rem;
  border-top: 1px solid var(--border);
  display: flex; gap: .5rem;
}

.qr-card-actions .btn { flex: 1; padding: .35rem; font-size: .78rem; }

/* ── Tables ── */
.table-modern thead th {
  background: var(--border-light);
  font-size: .75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted);
  border: none; padding: .75rem 1rem;
}

.table-modern tbody td { padding: .875rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: .875rem; }
.table-modern tbody tr:last-child td { border-bottom: none; }
.table-modern tbody tr:hover { background: var(--border-light); }

/* ── Badges ── */
.badge-active { background: rgba(16,185,129,.15); color: #059669; }
.badge-inactive { background: rgba(239,68,68,.1); color: #dc2626; }
.badge-free { background: rgba(148,163,184,.15); color: var(--text-muted); }
.badge-pro { background: rgba(99,102,241,.15); color: var(--primary); }

/* ── Forms ── */
.form-control, .form-select {
  background: var(--bg);
  border: 1.5px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: .6rem .875rem;
  font-size: .9rem;
  transition: var(--transition);
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
  background: var(--bg-card);
  outline: none; color: var(--text);
}

.form-label { font-size: .85rem; font-weight: 600; margin-bottom: .4rem; color: var(--text); }

/* Color picker inline */
.color-picker-group {
  display: flex; align-items: center; gap: .5rem;
}

.color-preview {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  cursor: pointer; overflow: hidden;
}

.color-preview input[type="color"] {
  width: 200%; height: 200%;
  margin: -50%; border: none; cursor: pointer;
}

/* ── Charts ── */
.chart-container { position: relative; }
.chart-container canvas { max-height: 280px; }

/* ── Pagination ── */
.pagination .page-link {
  color: var(--text-muted);
  border-color: var(--border);
  background: var(--bg-card);
  font-size: .85rem;
  transition: var(--transition);
}

.pagination .page-link:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.pagination .page-item.active .page-link { background: var(--primary); border-color: var(--primary); }

/* ── Alerts / Flash ── */
.flash-message {
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .875rem; font-weight: 500;
  display: flex; align-items: center; gap: .75rem;
}

.flash-success { background: rgba(16,185,129,.1); color: #059669; border-left: 3px solid #10b981; }
.flash-error   { background: rgba(239,68,68,.1);  color: #dc2626; border-left: 3px solid #ef4444; }
.flash-info    { background: rgba(59,130,246,.1);  color: #2563eb; border-left: 3px solid #3b82f6; }

/* ── Dark Mode Toggle ── */
.theme-toggle {
  background: none; border: 1px solid var(--border);
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-muted);
  transition: var(--transition); font-size: 1rem;
}

.theme-toggle:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

/* ── Responsive ── */
@media (max-width: 992px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main-content { margin-left: 0; }
  .navbar-toggle { display: flex; align-items: center; justify-content: center; }
  .sidebar-overlay { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 999; opacity: 0; pointer-events: none; transition: opacity .3s; }
  .sidebar-overlay.show { opacity: 1; pointer-events: all; }
}

@media (max-width: 576px) {
  .page-content { padding: 1.25rem 1rem; }
  .qr-grid { grid-template-columns: 1fr; }
  .stat-card { padding: 1.25rem; }
}

/* ── Animations ── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50%       { opacity: .7; }
}

.fade-in-up { animation: fadeInUp .4s ease both; }
.fade-in-up:nth-child(2) { animation-delay: .05s; }
.fade-in-up:nth-child(3) { animation-delay: .1s; }
.fade-in-up:nth-child(4) { animation-delay: .15s; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Auth Layout ── */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 40%, #4c1d95 100%);
  padding: 2rem;
  position: relative;
  overflow: hidden;
}

.auth-wrapper::before {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%239C92AC' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.auth-card {
  background: rgba(255,255,255,.97);
  border-radius: var(--radius-xl);
  box-shadow: 0 25px 50px rgba(0,0,0,.25);
  width: 100%; max-width: 440px;
  padding: 2.5rem;
  position: relative; z-index: 1;
  animation: fadeInUp .5s ease;
}

[data-theme="dark"] .auth-card {
  background: #1e293b;
}

.auth-logo {
  display: flex; align-items: center; justify-content: center;
  gap: .75rem; margin-bottom: 2rem;
}

.auth-logo-icon {
  width: 48px; height: 48px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; color: white;
  box-shadow: 0 8px 20px rgba(99,102,241,.4);
}

.auth-title { font-size: 1.5rem; font-weight: 800; text-align: center; letter-spacing: -.03em; }
.auth-subtitle { font-size: .875rem; color: var(--text-muted); text-align: center; margin-bottom: 2rem; }

/* ── Misc ── */
.cursor-pointer { cursor: pointer; }
.text-primary-custom { color: var(--primary) !important; }
.bg-primary-custom { background: var(--primary) !important; }
.fw-700 { font-weight: 700 !important; }
.fs-13 { font-size: .8125rem !important; }
.gap-10 { gap: .625rem !important; }

.qr-preview-box {
  background: white;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  min-height: 240px; padding: 1.5rem;
}

.qr-preview-box img { max-width: 200px; max-height: 200px; }

/* Folder pill */
.folder-pill {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .25rem .65rem;
  border-radius: 50px;
  font-size: .75rem; font-weight: 600;
  background: rgba(99,102,241,.1);
  color: var(--primary);
}

/* Install page */
.install-wrapper {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; background: var(--bg); padding: 2rem;
}

.install-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 2.5rem;
  max-width: 520px; width: 100%;
  box-shadow: var(--shadow-lg);
}
