/* ── APEX SHARED STYLES ─────────────────────────────────────
   Loaded by all app pages. Contains:
   - CSS variables / reset
   - Sidebar + nav
   - User card + menu
   - Upgrade button
   - Layout primitives (.main)
   - Shared animations
──────────────────────────────────────────────────────────── */

:root {
  --bg: #F7F6F3;
  --surface: #FFFFFF;
  --border: #E8E5DF;
  --border-strong: #D4CFC6;
  --text-primary: #1A1814;
  --text-secondary: #6B6560;
  --text-tertiary: #9E9890;
  --accent-green: #16A34A;
  --accent-amber: #D97706;
  --accent-red: #DC2626;
  --accent-blue: #2563EB;
  --sidebar-width: 240px;
  --radius: 10px;
  --radius-sm: 6px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
}

/* ── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 25;
  overflow-y: auto;
  padding-top: env(safe-area-inset-top);
}

/* ── MOBILE NAV (hamburger + slide-in drawer) ────────────────
   Below 768px the sidebar is off-canvas by default (transform,
   not display:none, so it can still slide in) and a hamburger
   button + backdrop are shown to open/close it. Above 768px
   these are hidden entirely and the sidebar behaves as normal. */
.mobile-nav-toggle {
  display: none;
  position: fixed;
  top: calc(env(safe-area-inset-top) + 14px);
  left: 16px;
  z-index: 30;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.mobile-nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 19;
}
body.mobile-nav-open .mobile-nav-backdrop { display: block; }
body.mobile-nav-open .sidebar { transform: translateX(0); }
body.mobile-nav-open .mobile-nav-toggle { display: none; }  /* hide the floating hamburger while the drawer is open */
body.mobile-nav-open .mobile-page-header-btn, body.mobile-nav-open .topbar-menu-btn { visibility: hidden; }  /* same for any page-embedded hamburger */

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  text-decoration: none;
  color: var(--text-primary);
}

.logo-mark {
  width: 34px; height: 34px;
  background: var(--text-primary);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  image-rendering: crisp-edges;
}
.logo-mark svg { width: 24px; height: 24px; }
.logo-name {
  font-family: 'DM Serif Display', serif;
  font-size: 17px;
  letter-spacing: -0.3px;
}

.sidebar-nav { padding: 12px 10px; flex: 1; }

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  padding: 8px 10px 6px;
}

.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text-secondary);
  transition: all 0.15s;
  text-decoration: none;
  margin-bottom: 1px;
}
.nav-item:hover { background: var(--bg); color: var(--text-primary); }
.nav-item.active { background: var(--bg); color: var(--text-primary); font-weight: 500; }
.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; opacity: 0.7; }
.nav-item.active svg { opacity: 1; }

.nav-badge {
  margin-left: auto;
  font-size: 11px;
  background: var(--text-primary);
  color: white;
  padding: 1px 7px;
  border-radius: 20px;
}
.nav-badge.subtle {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-tertiary);
}

.sidebar-bottom {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── UPGRADE BUTTON ──────────────────────────────────────── */
.upgrade-btn {
  display: flex; align-items: center; gap: 7px;
  width: 100%; padding: 8px 10px; margin-bottom: 6px;
  color: white;
  border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 600; letter-spacing: .01em;
  text-decoration: none; cursor: pointer;
  transition: opacity .15s, transform .1s;
  box-sizing: border-box;
  background: linear-gradient(135deg, #1e3a8a, #3b82f6, #6366f1, #1e40af, #1e3a8a);
  background-size: 300% 300%;
  animation: badgeMonthlyShift 6s ease infinite;
}
.upgrade-btn.pass-btn {
  background: linear-gradient(135deg, #78350f, #d97706, #fbbf24, #b45309, #92400e, #d97706);
  background-size: 400% 400%;
  animation: badgePassShimmer 5s ease infinite;
}
.upgrade-btn:hover { opacity: .88; transform: translateY(-1px); }
.upgrade-btn svg { flex-shrink: 0; }

/* ── USER CARD ───────────────────────────────────────────── */
.user-card {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
  transition: background .15s;
}
.user-card:hover { background: var(--bg); }

.user-avatar {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: white;
  flex-shrink: 0;
  overflow: hidden;
}
.user-name { font-size: 13px; font-weight: 500; }
.user-plan { font-size: 11px; color: var(--text-tertiary); }

/* Plan rings */
.user-avatar-wrap { position: relative; flex-shrink: 0; }
.plan-ring { position: absolute; inset: -2px; border-radius: 50%; pointer-events: none; }

/* Free — warm-gray dashed ring, no glow */
.plan-ring-free {
  border: 1.5px dashed #B8B3AA;
}

/* Pro (monthly) — solid blue with outer glow */
.plan-ring-monthly {
  border: 2px solid #2563EB;
  box-shadow: 0 0 0 2.5px rgba(37, 99, 235, 0.14), 0 0 10px rgba(37, 99, 235, 0.28);
}

/* Recruiting Pass — gold gradient, unchanged */
.plan-ring-pass {
  border: 2px solid transparent;
  background: linear-gradient(var(--surface), var(--surface)) padding-box,
              linear-gradient(135deg, #D97706, #FCD34D, #D97706) border-box;
}

.plan-icon {
  position: absolute; bottom: -3px; right: -3px;
  width: 14px; height: 14px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 8px; border: 1.5px solid var(--surface);
}
.plan-icon-free    { background: #8C8680; color: white; }
.plan-icon-monthly { background: #2563EB; color: white; }
.plan-icon-pass    { background: #D97706; color: white; }

/* ── USER MENU POPUP ─────────────────────────────────────── */
.user-menu {
  position: absolute; bottom: calc(100% + 10px); left: 0; right: 0;
  background: white; border: 1px solid var(--border);
  border-radius: 14px; box-shadow: 0 12px 36px rgba(0,0,0,.13), 0 2px 8px rgba(0,0,0,.06);
  overflow: hidden; z-index: 200;
  min-width: 220px;
  animation: menuPop .18s cubic-bezier(0.16,1,0.3,1) both;
}
@keyframes menuPop {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header: avatar + name + email */
.menu-header {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 13px;
}
.menu-header-avatar {
  width: 40px; height: 40px; flex-shrink: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 600; color: white;
  position: relative; cursor: pointer; overflow: hidden;
}
.menu-header-avatar img.av-photo {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  border-radius: 50%; object-fit: cover;
}
.menu-avatar-edit-overlay {
  position: absolute; inset: 0; border-radius: 50%;
  background: rgba(0,0,0,0.42);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.18s;
  z-index: 2;
}
.menu-header-avatar:hover .menu-avatar-edit-overlay { opacity: 1; }
.menu-header-text { flex: 1; min-width: 0; }
.menu-user-name {
  font-size: 13.5px; font-weight: 600; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 2px;
}
.menu-user-email {
  font-size: 11.5px; color: var(--text-tertiary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.menu-plan-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 600; margin-top: 5px;
  padding: 2px 8px; border-radius: 20px; letter-spacing: .01em;
}
.badge-free    { background: #EFEDE9; color: #78736C; border: 1px solid #C4C0B8; }
.badge-monthly {
  background: linear-gradient(135deg, #1e3a8a, #3b82f6, #6366f1, #1e40af, #1e3a8a);
  background-size: 300% 300%;
  animation: badgeMonthlyShift 6s ease infinite;
  color: white;
}
.badge-pass {
  background: linear-gradient(135deg, #78350f, #d97706, #fbbf24, #b45309, #92400e, #d97706);
  background-size: 400% 400%;
  animation: badgePassShimmer 5s ease infinite;
  color: white;
}
@keyframes badgeMonthlyShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes badgePassShimmer {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Member since line */
.menu-member-since {
  font-family: 'DM Serif Display', serif;
  font-style: italic;
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 3px;
  letter-spacing: .01em;
}

/* Items */
.menu-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 18px; font-size: 13px; color: var(--text-primary);
  cursor: pointer; text-decoration: none;
  transition: background .1s;
  font-family: 'DM Sans', sans-serif;
}
.menu-item:hover { background: var(--bg); }
.menu-item svg { width: 15px; height: 15px; flex-shrink: 0; opacity: .55; }
.menu-item-info {
  cursor: default; color: var(--text-secondary); font-size: 12.5px;
}
.menu-item-info:hover { background: transparent; }
.menu-item-info svg { opacity: .4; }
.menu-item-danger { color: #DC2626; }
.menu-item-danger svg { opacity: .65; }
.menu-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ── MAIN CONTENT AREA ───────────────────────────────────── */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  padding: 40px 44px;
  max-width: calc(100vw - var(--sidebar-width));
}

/* ── SHARED ANIMATIONS ───────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-1 { animation: fadeUp .4s ease both; }
.fade-2 { animation: fadeUp .4s ease .08s both; }
.fade-3 { animation: fadeUp .4s ease .16s both; }

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease;
    width: 260px;
  }
  .main {
    margin-left: 0;
    padding: 24px 20px;
    padding-top: calc(env(safe-area-inset-top) + 60px); /* room for hamburger button */
    max-width: 100vw;
  }
  .mobile-nav-toggle { display: flex; }

  /* Reusable fixed page header for pages without a bespoke one (dashboard,
     performance, feed, etc.). Pages with their own custom header (like
     practice-screen) skip this and manage it themselves. */
  .mobile-page-header {
    display: flex;
    align-items: center;
    gap: 10px;
    position: fixed;
    top: 0; left: 0; right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 10px 14px;
    padding-top: calc(env(safe-area-inset-top) + 10px);
    z-index: 20;
  }
  .mobile-page-header-btn {
    width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
    color: var(--text-primary);
  }
  .mobile-page-header-title {
    font-weight: 600;
    font-size: 15px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
  }
  /* Pages that include a .mobile-page-header need extra top clearance, and their
     own floating hamburger hidden since the header has its own copy. */
  body:has(.mobile-page-header) .main { padding-top: calc(env(safe-area-inset-top) + 56px) !important; }
  body:has(.mobile-page-header) .mobile-nav-toggle { display: none; }
}

