/* ===================================================================
   LINK GATEWAY — Premium Dark Design System
   =================================================================== */
:root {
  color-scheme: dark;
  --bg-base: #060c18;
  --bg-surface: #0d1526;
  --bg-card: rgba(15, 23, 42, 0.85);
  --bg-hover: rgba(30, 41, 59, 0.6);
  --border: rgba(148, 163, 184, 0.12);
  --border-bright: rgba(148, 163, 184, 0.25);
  --text-1: #f1f5f9;
  --text-2: #94a3b8;
  --text-3: #64748b;
  --blue: #3b82f6;
  --blue-dark: #1d4ed8;
  --blue-glow: rgba(59, 130, 246, 0.3);
  --indigo: #6366f1;
  --purple: #8b5cf6;
  --cyan: #06b6d4;
  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --pink: #ec4899;
  --r-xl: 1.25rem;
  --r-lg: 1rem;
  --r-md: .75rem;
  --r-sm: .5rem;
  --shadow: 0 4px 24px rgba(0,0,0,.35);
  --shadow-lg: 0 16px 48px rgba(0,0,0,.45);
  --transition: .2s ease;
}

/* ── BASE ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-base);
  background-image:
    radial-gradient(ellipse 80% 50% at 20% 0%, rgba(59,130,246,.12) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(139,92,246,.08) 0%, transparent 60%);
  background-attachment: fixed;
  color: var(--text-1);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ── CARD ──────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.card:hover { border-color: var(--border-bright); box-shadow: var(--shadow-lg); }
.card > h2, .card > h3 { margin-bottom: 1rem; }

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

.sidebar {
  width: 268px;
  min-height: 100vh;
  position: fixed;
  inset: 0 auto 0 0;
  background: rgba(6, 12, 24, 0.96);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0 0 1rem;
  z-index: 1040;
  transition: transform .3s ease;
}

.sidebar-brand {
  padding: 1.4rem 1.25rem 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: .5rem;
}

.sidebar-brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--blue), var(--indigo));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  box-shadow: 0 4px 16px var(--blue-glow);
}

.sidebar-brand-name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-1);
  line-height: 1.2;
}

.sidebar-brand-sub {
  font-size: .72rem;
  color: var(--text-3);
  margin-top: 1px;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: .5rem 1rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar-label {
  color: var(--text-3);
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: .85rem .75rem .35rem;
}

.sidebar-nav .nav-link {
  color: var(--text-2);
  border-radius: var(--r-md);
  padding: .65rem .85rem;
  font-size: .875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: .65rem;
  transition: background var(--transition), color var(--transition), transform .15s;
}

.sidebar-nav .nav-link .nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
}

.sidebar-nav .nav-link:hover {
  background: rgba(59, 130, 246, .1);
  color: var(--text-1);
  transform: translateX(2px);
}

.sidebar-nav .nav-link.active {
  background: linear-gradient(135deg, rgba(59,130,246,.25), rgba(99,102,241,.15));
  color: #fff;
  border: 1px solid rgba(59,130,246,.3);
  box-shadow: 0 2px 12px rgba(59,130,246,.2);
}

.sidebar-nav .nav-link.active .nav-icon { filter: drop-shadow(0 0 6px var(--blue)); }

.sidebar-footer {
  padding: .75rem 1rem 0;
  border-top: 1px solid var(--border);
}

.user-card {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: .9rem;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--blue));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

/* ── MAIN PANEL ────────────────────────────────────────────────── */
.main-panel {
  min-height: 100vh;
  margin-left: 268px;
  width: calc(100% - 268px);
  display: flex;
  flex-direction: column;
}

.mobile-topbar { display: none; }

.content-wrap {
  max-width: 1320px;
  width: 100%;
}

/* ── TOP USERBAR ───────────────────────────────────────────────── */
.top-userbar {
  position: sticky;
  top: 0;
  z-index: 1045;
  background: rgba(6, 12, 24, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: .7rem 0;
}

/* ── STAT CARDS ────────────────────────────────────────────────── */
.stat-card {
  min-height: 130px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -10%;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: currentColor;
  opacity: .04;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  margin-bottom: .75rem;
}

.stat-label {
  color: var(--text-2);
  font-size: .82rem;
  font-weight: 500;
  margin-bottom: .25rem;
}

.stat {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.1;
  background: linear-gradient(135deg, #60a5fa, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-sub {
  color: var(--text-3);
  font-size: .75rem;
  margin-top: .3rem;
}

/* Stat color variants */
.stat-blue .stat-icon { background: rgba(59,130,246,.15); color: var(--blue); }
.stat-blue .stat { background: linear-gradient(135deg, #60a5fa, #93c5fd); -webkit-background-clip: text; background-clip: text; }
.stat-purple .stat-icon { background: rgba(139,92,246,.15); color: var(--purple); }
.stat-purple .stat { background: linear-gradient(135deg, #a78bfa, #c4b5fd); -webkit-background-clip: text; background-clip: text; }
.stat-green .stat-icon { background: rgba(16,185,129,.15); color: var(--green); }
.stat-green .stat { background: linear-gradient(135deg, #34d399, #6ee7b7); -webkit-background-clip: text; background-clip: text; }
.stat-amber .stat-icon { background: rgba(245,158,11,.15); color: var(--amber); }
.stat-amber .stat { background: linear-gradient(135deg, #fbbf24, #fcd34d); -webkit-background-clip: text; background-clip: text; }
.stat-cyan .stat-icon { background: rgba(6,182,212,.15); color: var(--cyan); }
.stat-cyan .stat { background: linear-gradient(135deg, #22d3ee, #67e8f9); -webkit-background-clip: text; background-clip: text; }
.stat-pink .stat-icon { background: rgba(236,72,153,.15); color: var(--pink); }
.stat-pink .stat { background: linear-gradient(135deg, #f472b6, #f9a8d4); -webkit-background-clip: text; background-clip: text; }

/* ── TABLE ─────────────────────────────────────────────────────── */
.table { --bs-table-bg: transparent; --bs-table-hover-bg: rgba(59,130,246,.06); }
.table thead th {
  color: var(--text-3);
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  border-bottom: 1px solid var(--border-bright);
  padding: .75rem .9rem;
}
.table tbody td {
  border-color: var(--border);
  padding: .75rem .9rem;
  vertical-align: middle;
}
.table-scroll { overflow-x: auto; border-radius: var(--r-md); }
.link-url, .destination-url { word-break: break-all; font-size: .825rem; color: var(--blue); }
.link-url:hover, .destination-url:hover { color: #93c5fd; }

/* ── BADGES ────────────────────────────────────────────────────── */
.badge:not([class*="text-bg"]):not(.on):not(.off) {
  background: rgba(51,65,85,.7);
  color: #e2e8f0;
  border: 1px solid var(--border-bright);
}
.badge.on { background: rgba(4,120,87,.25) !important; color: #6ee7b7; border: 1px solid rgba(16,185,129,.3); }
.badge.off { background: rgba(159,18,57,.25) !important; color: #fca5a5; border: 1px solid rgba(239,68,68,.3); }

/* ── FORMS ─────────────────────────────────────────────────────── */
.form-control, .form-select {
  background: rgba(15, 23, 42, 0.7) !important;
  border-color: var(--border-bright) !important;
  color: var(--text-1) !important;
  border-radius: var(--r-md) !important;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus, .form-select:focus {
  background: rgba(15, 23, 42, 0.9) !important;
  border-color: var(--blue) !important;
  box-shadow: 0 0 0 3px var(--blue-glow) !important;
  color: var(--text-1) !important;
}
.form-label { color: var(--text-2); font-size: .855rem; font-weight: 500; }
.form-control::placeholder { color: var(--text-3) !important; }
.form-select option { background: #0d1526; }

/* ── BUTTONS ───────────────────────────────────────────────────── */
.btn { border-radius: var(--r-md); font-weight: 500; transition: all var(--transition); }
.btn-primary {
  background: linear-gradient(135deg, var(--blue), var(--indigo));
  border: none;
  box-shadow: 0 4px 16px var(--blue-glow);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  box-shadow: 0 6px 24px var(--blue-glow);
  transform: translateY(-1px);
}
.btn-outline-light { border-color: var(--border-bright); color: var(--text-2); }
.btn-outline-light:hover { background: var(--bg-hover); border-color: var(--border-bright); color: var(--text-1); }
.btn-outline-info { border-color: rgba(6,182,212,.4); color: var(--cyan); }
.btn-outline-info:hover { background: rgba(6,182,212,.1); border-color: var(--cyan); color: var(--cyan); }

/* ── MISC ──────────────────────────────────────────────────────── */
.muted { color: var(--text-3); }
.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.25rem; }
.row-actions .btn { white-space: nowrap; }
.auth-card { max-width: 500px; margin-left: auto; margin-right: auto; border-radius: var(--r-xl); padding: 2rem; }
.landing { max-width: 680px; margin: 4rem auto; text-align: center; }
.landing h1 { font-size: 2.2rem; }
pre { white-space: pre-wrap; background: rgba(11,18,32,.8); border: 1px solid var(--border); border-radius: var(--r-md); padding: 1rem; overflow: auto; }
code { color: #93c5fd; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 1rem; }
.full { grid-column: 1 / -1; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.stat-card { min-height: 130px; }
.mobile-user { line-height: 1.2; }
.mobile-user .small { white-space: nowrap; }

/* ── ALERT ─────────────────────────────────────────────────────── */
.alert { border-radius: var(--r-lg); border: 1px solid var(--border-bright); }
.alert-success { background: rgba(16,185,129,.1); border-color: rgba(16,185,129,.3); color: #6ee7b7; }
.alert-danger { background: rgba(239,68,68,.1); border-color: rgba(239,68,68,.3); color: #fca5a5; }
.alert-info { background: rgba(6,182,212,.1); border-color: rgba(6,182,212,.3); color: #67e8f9; }

/* ── LAYOUT VARIANTS ───────────────────────────────────────────── */
.layout-public .main-panel, .layout-auth .main-panel { margin-left: 0; width: 100%; }
.layout-public .content-wrap, .layout-auth .content-wrap { max-width: 1320px; }
.layout-public .landing { margin-top: 2rem; }
.layout-public .mobile-topbar { display: none !important; }
.layout-auth .app-shell { display: block; min-height: auto; }
.auth-content-wrap { padding-top: 2rem !important; }

/* ── MOBILE TOPBAR ─────────────────────────────────────────────── */
.mobile-topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .65rem 1rem;
}

.hamburger {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-md);
  background: rgba(30,41,59,.5);
  border: 1px solid var(--border);
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.hamburger:hover { background: rgba(59,130,246,.15); color: var(--text-1); }

/* ── OFFCANVAS ─────────────────────────────────────────────────── */
.offcanvas.text-bg-dark {
  background: rgba(6, 12, 24, 0.98) !important;
  backdrop-filter: blur(24px);
  border-right: 1px solid var(--border);
}

/* ── DASHBOARD FILTER ──────────────────────────────────────────── */
.dashboard-filter .form-select, .dashboard-filter .form-control {
  min-width: 160px;
}

/* ── NAVBAR BRAND ──────────────────────────────────────────────── */
.navbar-brand { line-height: 1.1; }

/* ── SCROLLBAR ─────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(148,163,184,.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(148,163,184,.35); }

/* ── ANIMATIONS ────────────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.card { animation: fadeInUp .3s ease both; }
.card:nth-child(2) { animation-delay: .05s; }
.card:nth-child(3) { animation-delay: .1s; }

/* ── RESPONSIVE ────────────────────────────────────────────────── */
@media (max-width: 991.98px) {
  .sidebar { display: none; }
  .main-panel { margin-left: 0; width: 100%; }
  .mobile-topbar { display: block; }
  .content-wrap { padding-top: 1rem !important; }
}
@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .section-head { display: block; }
  
  /* Make mobile topbar smaller */
  .mobile-topbar-inner { padding: .4rem .5rem; gap: .5rem; }
  .mobile-topbar-inner .fw-bold { font-size: .85rem !important; }
  .hamburger { width: 32px; height: 32px; font-size: .8rem; }
  .mobile-topbar-inner .btn { padding: .2rem .4rem !important; font-size: .7rem !important; }
}
