/* ============================================================
   AdScaleLab Dashboard V2 — Glass-morphism Theme
   Aesthetic: dark indigo · cool-blue gradient backdrop ·
              frosted panels · edge-light reflection on hover
   Inspired by: iOS 17 Control Center, macOS Big Sur sidebars
   ============================================================ */

/* ---- Design tokens ---- */
:root {
  /* Dark base with cool blue undertone */
  --bg:           #0A0B1A;
  --bg-deeper:    #06070F;

  /* Glass surfaces — translucent, layered */
  --glass-1:      rgba(20, 22, 40, 0.55);
  --glass-2:      rgba(28, 32, 55, 0.65);
  --glass-3:      rgba(38, 42, 70, 0.75);
  --glass-hi:     rgba(255, 255, 255, 0.04);

  /* Borders - subtle frosted edges */
  --border-1:     rgba(255, 255, 255, 0.08);
  --border-2:     rgba(255, 255, 255, 0.14);
  --border-glow:  rgba(99, 102, 241, 0.3);

  /* Text */
  --ink:          #F0F2FA;
  --ink-2:        #B8BCD0;
  --ink-3:        #7A8099;
  --ink-4:        #4D536A;

  /* Brand */
  --accent:       #6366F1;
  --accent-2:     #818CF8;
  --accent-deep:  #4338CA;
  --accent-soft:  rgba(99, 102, 241, 0.15);
  --accent-glow:  rgba(99, 102, 241, 0.32);

  /* Semantic */
  --success:      #10B981;
  --success-tint: rgba(16, 185, 129, 0.15);
  --warn:         #F59E0B;
  --warn-tint:    rgba(245, 158, 11, 0.15);
  --danger:       #EF4444;
  --danger-tint:  rgba(239, 68, 68, 0.15);
  --info:         #38BDF8;
  --info-tint:    rgba(56, 189, 248, 0.15);

  /* Typography */
  --font-display: 'Instrument Serif', Georgia, serif;
  --font-body:    'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:    'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;

  /* Radii */
  --r-sm:         8px;
  --r:            12px;
  --r-lg:         18px;
  --r-xl:         24px;

  /* Shadows */
  --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-deep:  0 24px 64px -12px rgba(0, 0, 0, 0.6);
  --shadow-glow:  0 0 60px rgba(99, 102, 241, 0.18);

  /* Easings */
  --ease:         cubic-bezier(0.22, 1, 0.36, 1);
  --ease-bounce:  cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Layout */
  --sidebar-w:    260px;
  --topbar-h:     68px;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
  overflow-x: hidden;
}

a { color: var(--accent-2); text-decoration: none; transition: color 0.15s var(--ease); }
a:hover { color: var(--ink); }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3, h4 { margin: 0; font-weight: 500; letter-spacing: -0.01em; }
p { margin: 0; }
img, svg { display: block; max-width: 100%; }
table { border-collapse: collapse; width: 100%; }
[hidden] { display: none !important; }
::selection { background: var(--accent); color: #fff; }

.mono { font-family: var(--font-mono); font-size: 0.93em; }
.muted { color: var(--ink-3); }

/* ============================================================
   GLASS BACKDROP — blurred gradient mesh behind everything
   ============================================================ */
.app-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.app-backdrop::before {
  content: '';
  position: absolute;
  inset: -10%;
  background:
    radial-gradient(ellipse 60% 50% at 15% 0%, rgba(56, 100, 255, 0.45), transparent 60%),
    radial-gradient(ellipse 70% 60% at 85% 30%, rgba(168, 85, 247, 0.35), transparent 60%),
    radial-gradient(ellipse 50% 50% at 50% 100%, rgba(56, 189, 248, 0.30), transparent 60%),
    radial-gradient(ellipse 40% 40% at 100% 100%, rgba(99, 102, 241, 0.40), transparent 70%);
  filter: blur(80px) saturate(1.1);
  animation: meshDrift 24s var(--ease) infinite alternate;
}
.app-backdrop::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(0deg, transparent 0, transparent 39px, rgba(255,255,255,0.012) 40px),
    repeating-linear-gradient(90deg, transparent 0, transparent 39px, rgba(255,255,255,0.012) 40px);
}
@keyframes meshDrift {
  0%   { transform: translate(0,    0)    rotate(0deg);   }
  100% { transform: translate(-3%, -2%)   rotate(2deg);   }
}

/* ============================================================
   SIDEBAR (glass)
   ============================================================ */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  z-index: 20;
  background: var(--glass-1);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border-right: 1px solid var(--border-1);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s var(--ease);
  box-shadow: 1px 0 0 rgba(255,255,255,0.04);
}

.sidebar-brand {
  padding: 20px 22px;
  border-bottom: 1px solid var(--border-1);
}
.sidebar-brand a {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.sidebar-brand-logo {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(99,102,241,0.35);
}

.sidebar-section {
  padding: 14px 12px 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-4);
}

.sidebar-nav {
  flex: 1;
  padding: 6px 10px;
  overflow-y: auto;
}

.sidebar-nav a, .sidebar-nav .nav-disabled {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  color: var(--ink-2);
  margin-bottom: 2px;
  transition: all 0.18s var(--ease);
  overflow: hidden;
}
.sidebar-nav a svg, .sidebar-nav .nav-disabled svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--ink-3); }
.sidebar-nav a:hover { background: var(--glass-hi); color: var(--ink); }
.sidebar-nav a:hover svg { color: var(--ink-2); }

.sidebar-nav a.is-active {
  background: var(--accent-soft);
  color: var(--accent-2);
  box-shadow: inset 0 0 0 1px var(--border-glow);
}
.sidebar-nav a.is-active svg { color: var(--accent-2); }
.sidebar-nav a.is-active::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 12px var(--accent);
}

.sidebar-nav .nav-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.sidebar-nav .nav-disabled .soon-pill {
  margin-left: auto;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--font-mono);
  background: var(--glass-2);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--ink-4);
}

.sidebar-nav-network-icon {
  width: 26px; height: 26px;
  border-radius: 6px;
  background: rgba(255,255,255,0.06);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  padding: 3px;
}
.sidebar-nav-network-icon img {
  width: 100%; height: 100%;
  object-fit: contain;
}

/* Your manager card — shown above sidebar-footer when a manager is assigned */
.sidebar-manager-card {
  margin: 14px;
  padding: 12px 14px;
  background: var(--glass-2);
  border: 1px solid var(--border-glow);
  border-radius: var(--r-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar-manager-eyebrow {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-2);
  margin-bottom: 2px;
}
.sidebar-manager-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 4px;
}
.sidebar-manager-link {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-3);
  text-decoration: none;
  padding: 3px 0;
  word-break: break-all;
  transition: color 0.15s var(--ease);
}
.sidebar-manager-link:hover { color: var(--accent-2); }

.sidebar-footer {
  border-top: 1px solid var(--border-1);
  padding: 14px;
  background: var(--glass-2);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-1);
  margin-bottom: 10px;
}
.sidebar-user-avatar {
  width: 36px; height: 36px;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  color: #fff;
  box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}
.sidebar-user-meta { min-width: 0; flex: 1; }
.sidebar-user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-email {
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  font-size: 13px;
  color: var(--ink-3);
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all 0.18s var(--ease);
}
.sidebar-logout svg { width: 16px; height: 16px; }
.sidebar-logout:hover { color: var(--danger); background: var(--danger-tint); }

/* ============================================================
   TOPBAR + MAIN
   ============================================================ */
.app-main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--topbar-h);
  padding: 0 32px;
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--glass-1);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border-bottom: 1px solid var(--border-1);
}
.topbar-burger {
  display: none;
  width: 40px; height: 40px;
  background: var(--glass-2);
  border: 1px solid var(--border-1);
  border-radius: var(--r-sm);
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
}
.topbar-burger span { width: 16px; height: 1.5px; background: var(--ink-2); }
.topbar-title {
  font-family: var(--font-display);
  font-size: 28px;
  letter-spacing: -0.025em;
  color: var(--ink);
  flex: 1;
  font-weight: 400;
}
.topbar-actions { display: flex; gap: 8px; }

.app-content {
  padding: 32px 36px 80px;
  max-width: 1400px;
}

/* ============================================================
   GLASS PANELS — primary container
   ============================================================ */
.glass {
  position: relative;
  background: var(--glass-2);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid var(--border-1);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-glass);
  overflow: hidden;
}
.glass::before {
  /* Top edge highlight — like light catching glass */
  content: '';
  position: absolute;
  top: 0; left: 10%; right: 10%;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(255,255,255,0.25), transparent);
  pointer-events: none;
}

/* Hover reflection effect — cursor moving over glass catches light */
.glass-interactive {
  transition: transform 0.3s var(--ease), border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
  cursor: pointer;
}
.glass-interactive::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(
    600px circle at var(--mx, 50%) var(--my, 50%),
    rgba(255,255,255,0.06),
    transparent 40%
  );
  opacity: 0;
  transition: opacity 0.3s var(--ease);
  pointer-events: none;
}
.glass-interactive:hover {
  border-color: var(--border-2);
  transform: translateY(-2px);
  box-shadow: var(--shadow-deep), var(--shadow-glow);
}
.glass-interactive:hover::after {
  opacity: 1;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 500;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.18s var(--ease);
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-full { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn-lg { padding: 13px 20px; font-size: 14.5px; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(99,102,241,0.3);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-2);
  box-shadow: 0 6px 20px rgba(99,102,241,0.5);
  transform: translateY(-1px);
}

.btn-glass {
  background: var(--glass-2);
  color: var(--ink);
  border-color: var(--border-1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.btn-glass:hover:not(:disabled) {
  background: var(--glass-3);
  border-color: var(--border-2);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-2);
  border-color: var(--border-1);
}
.btn-ghost:hover:not(:disabled) {
  color: var(--ink);
  background: var(--glass-hi);
  border-color: var(--border-2);
}

.btn-outline {
  background: transparent;
  color: var(--ink);
  border-color: var(--border-2);
}
.btn-outline:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-2);
}

.btn-danger {
  background: var(--danger-tint);
  color: #fca5a5;
  border-color: rgba(239,68,68,0.3);
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

/* ============================================================
   FORMS
   ============================================================ */
.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  margin-bottom: 7px;
}
.field label .hint {
  font-weight: 400;
  color: var(--ink-3);
  font-size: 12px;
  margin-left: 4px;
}

.input, select.input, textarea.input {
  width: 100%;
  background: var(--glass-2);
  border: 1px solid var(--border-1);
  border-radius: var(--r-sm);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14.5px;
  padding: 11px 14px;
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease), background 0.18s var(--ease);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.input:focus, select.input:focus, textarea.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--glass-3);
}
.input::placeholder { color: var(--ink-4); }

/* Style dropdown options - browser native menus default to white-on-black which clashes with our dark theme */
select.input option { background: #1a1d33; color: var(--ink); padding: 6px; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-hint { font-size: 12px; color: var(--ink-3); margin-top: 6px; }

.checkbox {
  display: flex; align-items: center; gap: 10px;
  font-size: 13.5px;
  color: var(--ink-2);
  cursor: pointer;
}
.checkbox input {
  appearance: none; -webkit-appearance: none;
  width: 18px; height: 18px;
  border: 1px solid var(--border-2);
  border-radius: 4px;
  background: var(--glass-2);
  position: relative;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}
.checkbox input:checked { background: var(--accent); border-color: var(--accent); }
.checkbox input:checked::after {
  content: ''; position: absolute; top: 2px; left: 6px;
  width: 4px; height: 9px;
  border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--r);
  font-size: 13.5px;
  line-height: 1.55;
  margin-bottom: 20px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.alert svg { flex-shrink: 0; width: 18px; height: 18px; margin-top: 1px; }
.alert-err  { background: var(--danger-tint); border: 1px solid rgba(239,68,68,0.3); color: #FCA5A5; }
.alert-ok   { background: var(--success-tint); border: 1px solid rgba(16,185,129,0.3); color: #6EE7B7; }
.alert-info { background: var(--accent-soft); border: 1px solid var(--border-glow); color: var(--accent-2); }
.alert-warn { background: var(--warn-tint); border: 1px solid rgba(245,158,11,0.3); color: #FCD34D; }

/* ============================================================
   STATUS PILLS
   ============================================================ */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 11px;
  font-size: 11.5px;
  font-weight: 500;
  font-family: var(--font-mono);
  background: var(--glass-3);
  color: var(--ink-2);
  border: 1px solid var(--border-1);
}
.pill-active             { background: var(--success-tint); color: #6EE7B7; border-color: rgba(16,185,129,0.3); }
.pill-pending            { background: var(--warn-tint);    color: #FCD34D; border-color: rgba(245,158,11,0.3); }
.pill-suspended          { background: var(--danger-tint);  color: #FCA5A5; border-color: rgba(239,68,68,0.3); }
.pill-closed             { background: var(--glass-3);      color: var(--ink-3); }
.pill-fulfilled          { background: var(--success-tint); color: #6EE7B7; border-color: rgba(16,185,129,0.3); }
.pill-payment-verified   { background: var(--accent-soft);  color: var(--accent-2); border-color: var(--border-glow); }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise   { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pop    { 0% { transform: scale(0.6); opacity: 0; } 60% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .app-backdrop::before { animation: none; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
    --sidebar-w: 280px;
  }
  .sidebar.is-open { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .topbar-burger { display: flex; }
  .app-content { padding: 24px 20px 64px; }
  .field-row { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .topbar { padding: 0 18px; }
  .topbar-title { font-size: 22px; }
  .app-content { padding: 20px 16px 48px; }
}

/* ============================================================
   THEMED SCROLLBARS
   Replaces the default white/grey browser scrollbar (notably in
   the sidebar nav when there are many networks) with a subtle
   dark, indigo-tinted bar that blends into the glass theme.
   ============================================================ */

/* Firefox */
.sidebar-nav,
.app-content,
.modal-body,
.scroll-themed {
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 102, 241, 0.35) transparent;
}

/* WebKit / Chromium / Safari */
.sidebar-nav::-webkit-scrollbar,
.app-content::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
.scroll-themed::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.sidebar-nav::-webkit-scrollbar-track,
.app-content::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track,
.scroll-themed::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb,
.app-content::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb,
.scroll-themed::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.30);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover,
.app-content::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover,
.scroll-themed::-webkit-scrollbar-thumb:hover {
  background: rgba(129, 140, 248, 0.50);
  border: 2px solid transparent;
  background-clip: padding-box;
}
