/* ============================================================
   DashAdvisr — Base Stylesheet
   Shared across all pages: variables, reset, body, nav, auth gate.
   Every HTML file links to this.
   ============================================================ */

/* ── GOOGLE FONTS (also declared in <link> in HTML) ──────── */
/* Loaded via HTML <link> for performance. Declared here for reference:
   Instrument Serif (headings), Inter (body) */

/* ── CSS VARIABLES ─────────────────────────────────────────── */
:root {
  /* Brand: Deep Navy + Trust Blue primary, Teal secondary (Brand Spec v6.0) */
  --navy:         #1a2332;
  --ink:          #0d1117;
  --ink-soft:     #374151;
  --ink-muted:    #6b7280;
  --bg:           #F0F4F8;
  --surface:      #ffffff;
  /* Primary: Trust Blue — proven in fintech (Stripe, Square, PayPal) */
  --accent:       #2563EB;
  --accent-deep:  #1D4ED8;
  --accent-soft:  #DBEAFE;
  --accent-glow:  rgba(37,99,235,0.15);
  /* Secondary: Teal — data viz, success states, growth indicators */
  --teal:         #00A699;
  --teal-deep:    #008F84;
  --teal-soft:    #e0f7f4;
  --green:        #059669;
  --green-soft:   #d1fae5;
  --amber:        #d97706;
  --amber-soft:   #fef3c7;
  --red:          #dc2626;
  --red-soft:     #fee2e2;
  --purple:       #7c3aed;
  --purple-soft:  #ede9fe;
  --border:       rgba(37,99,235,0.09);
  --tile-bg:      rgba(255,255,255,0.72);
  --tile-border:  rgba(255,255,255,0.90);
  --radius:       20px;
  --radius-sm:    12px;
  --nav-h:        64px;
}

/* ── PAGE LOADING BAR ────────────────────────────────────────── */
#page-loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent, #2563EB), var(--teal, #00A699));
  z-index: 99999;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  opacity: 0;
}
#page-loading-bar.active { opacity: 1; }

/* ── SCREEN-READER ONLY ──────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

html { height: 100%; overflow-x: hidden; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── FOCUS STYLES ────────────────────────────────────────── */
button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent, #2563EB);
  outline-offset: 2px;
}

/* ── ANCHOR RESET ─────────────────────────────────────────── */
/* Prevent browser-default blue/purple underlined links (90s look) */
a {
  color: inherit;
  text-decoration: none;
}
a:visited { color: inherit; }

/* ── NOISE TEXTURE OVERLAY ──────────────────────────────────── */
/* Subtle grain effect that makes the glassmorphism look premium */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.025'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

/* ── BACKGROUND GRADIENT ────────────────────────────────────── */
/* Blue/purple/green radial blobs — gives the frosted-glass look depth */
.bg-gradient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 60% 50% at 20% 20%, rgba(37,99,235,0.08) 0%, transparent 100%),
    radial-gradient(ellipse 50% 40% at 80% 75%, rgba(59,130,246,0.06) 0%, transparent 100%),
    radial-gradient(ellipse 40% 40% at 60% 10%, rgba(29,78,216,0.05) 0%, transparent 100%);
}

/* ── AUTH GATE ──────────────────────────────────────────────── */
/* Full-screen overlay shown while we check if user is logged in.
   Hidden as soon as session is confirmed, so users never see a flash. */
#auth-gate {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
}

.gate-logo {
  font-family: 'Instrument Serif', serif;
  font-size: 24px;
  color: var(--ink);
  letter-spacing: -0.3px;
}
.gate-logo span { color: var(--accent); }

.gate-spinner {
  width: 22px;
  height: 22px;
  border: 2px solid rgba(37,99,235,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── iOS SAFE AREA INSETS ──────────────────────────────────── */
main, .page-content, .tile-grid {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── NAVIGATION ─────────────────────────────────────────────── */
nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  background: var(--theme-nav-bg, rgba(239, 246, 255, 0.84));
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--theme-nav-border, rgba(37,99,235,0.10));
}

.logo {
  font-family: 'Instrument Serif', serif;
  font-size: 20px;
  color: var(--navy);
  letter-spacing: -0.3px;
  text-decoration: none;
}
.logo span { color: var(--accent); }

/* Secondary nav links (+ Performer, Connect Square, Admin QA) */
.nav-links {
  display: flex;
  gap: 4px;
  margin-left: 16px;
}
.nav-link {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-muted);
  text-decoration: none;
  transition: all 0.15s;
}
.nav-link:hover { background: rgba(0,0,0,0.05); color: var(--ink); }

/* Right side: badge + user chip + sign out */
.nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-soft);
  border: 1px solid rgba(37,99,235,0.15);
  border-radius: 100px;
  padding: 5px 12px 5px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}
.nav-badge .dot {
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 50%;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px 5px 5px;
  background: var(--tile-bg);
  border: 1px solid var(--tile-border);
  border-radius: 100px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.user-avatar {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.user-email {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-signout {
  padding: 7px 16px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 100px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.btn-signout:hover { border-color: var(--red); color: var(--red); }

/* ── MAIN CONTENT AREA ──────────────────────────────────────── */
main {
  position: relative;
  z-index: 1;
  padding: calc(var(--nav-h) + 32px) 32px 40px;
  max-width: 1200px;
  margin: 0 auto;
}

/* ── PAGE HEADER ─────────────────────────────────────────────── */
.page-header { margin-bottom: 32px; }
.page-header .greeting {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-muted);
  margin-bottom: 4px;
}
.page-header h1 {
  font-family: 'Instrument Serif', serif;
  font-size: clamp(28px, 3vw, 38px);
  letter-spacing: -1px;
  color: var(--ink);
  line-height: 1.1;
}
.page-header h1 em { font-style: italic; color: var(--accent); }

/* ── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  main { padding-left: 16px; padding-right: 16px; }
  nav  { padding: 0 16px; }
  .user-email  { display: none; }
  .nav-links   { display: none; }
  .nav-right   { gap: 8px; }
}

/* ── MOBILE SAFARI LINK FIX ──────────────────────────────────── */
/* Safari on iOS sometimes ignores generic a resets for dynamically injected
   content. This catches any remaining blue/underlined links in the app shell. */
@media (max-width: 768px) {
  a, a:link, a:visited, a:active {
    -webkit-tap-highlight-color: transparent;
  }
  /* Force all links inside the app shell to inherit (no 90s blue) */
  main a:not([class]),
  .sidebar a:not([class]),
  nav a:not([class]) {
    color: inherit;
    text-decoration: none;
  }
}
