/* ============================================================
   PlayCaller App Shell — Navigation (v20260503g)
   Components:
   1. Bottom Tab Bar (4 buttons, each opens sub-section drawer)
   2. Sub-Section Drawers (slide up from bottom nav)
   3. Hamburger Drawer (full-height slide-out from left)
   ============================================================ */

/* ─── Nav Drawer Overlay (backdrop) ────────────────────────── */
.nav-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 1050;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.nav-drawer-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* ─── Hamburger Drawer (slides from left) ──────────────────── */
.app-nav-drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: 320px;
  max-width: 85vw;
  height: 100vh;
  height: 100dvh;
  background: #0D0D0D;
  border-right: 1px solid rgba(209, 176, 107, 0.15);
  z-index: 1060;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.app-nav-drawer.open {
  transform: translateX(0);
}

/* Drawer header */
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(209, 176, 107, 0.12);
  flex-shrink: 0;
  background: #0D0D0D;
  position: sticky;
  top: 0;
  z-index: 1;
}

.drawer-logo {
  font-family: var(--font-display, 'Bebas Neue', sans-serif);
  font-size: 24px;
  font-weight: 700;
  color: #D1B06B;
  letter-spacing: 2px;
  text-decoration: none;
  text-transform: uppercase;
}

.drawer-close-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.6);
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  transition: all 0.2s ease;
}

.drawer-close-btn:hover {
  color: #D1B06B;
  background: rgba(209, 176, 107, 0.12);
  border-color: rgba(209, 176, 107, 0.2);
}

/* Sport pill switcher (inside drawer) */
.sport-pill-switcher {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(209, 176, 107, 0.08);
  margin-bottom: 4px;
}

.sport-pill-group {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 20px;
  padding: 4px;
  width: 100%;
  justify-content: center;
}

.sport-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex: 1;
  padding: 8px 14px;
  border-radius: 16px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.4);
  font-family: var(--font-primary, 'DM Sans', sans-serif);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: all 0.2s ease;
  white-space: nowrap;
  line-height: 1.2;
}

.sport-pill:hover {
  color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.06);
}

.sport-pill-icon {
  font-size: 13px;
  line-height: 1;
  display: inline-block;
  transition: transform 0.2s ease;
}

.sport-pill:hover .sport-pill-icon { transform: scale(1.1); }

/* NFL active (gold) */
.sport-pill[data-sport='NFL'].active {
  background: #D1B06B;
  color: #0D1117;
  font-weight: 700;
  box-shadow: 0 0 12px rgba(209, 176, 107, 0.35);
}

/* MLB active (blue) */
.sport-pill[data-sport='MLB'].active {
  background: #4A90E2;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 0 12px rgba(74, 144, 226, 0.35);
}

/* NBA active (purple) */
.sport-pill[data-sport='NBA'].active {
  background: #635BFF;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 0 12px rgba(99, 91, 255, 0.35);
}

/* Drawer nav content */
.drawer-nav-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0 100px;
}

/* Drawer section headers */
.drawer-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 16px 6px;
  color: #D1B06B;
}

.drawer-section-emoji {
  font-size: 14px;
  flex-shrink: 0;
}

.drawer-section-title {
  font-family: var(--font-mono, 'DM Mono', monospace);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #D1B06B;
}

/* Drawer divider */
.drawer-divider {
  height: 1px;
  background: rgba(209, 176, 107, 0.08);
  margin: 6px 16px;
}

/* Drawer nav list */
.drawer-nav-list {
  padding: 0 8px;
}

/* Drawer nav items */
.drawer-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  text-decoration: none;
  color: rgba(255, 255, 255, 0.65);
  font-family: var(--font-primary, 'DM Sans', sans-serif);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
  cursor: pointer;
  border-left: 3px solid transparent;
}

.drawer-nav-item:hover,
.drawer-nav-item:active {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.drawer-nav-item.active {
  background: rgba(209, 176, 107, 0.12);
  color: #D1B06B;
  border-left-color: #D1B06B;
}

.drawer-nav-item.locked {
  opacity: 0.45;
  cursor: not-allowed;
}

.drawer-nav-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.drawer-nav-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  color: inherit;
}

.drawer-nav-lock {
  font-size: 12px;
  opacity: 0.7;
}

/* ─── Hamburger Button ─────────────────────────────────────── */
.app-shell-hamburger {
  background: transparent;
  border: none;
  color: #D1B06B;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.app-shell-hamburger:hover {
  color: #E8C97B;
  background: rgba(209, 176, 107, 0.1);
}

.app-shell-hamburger.floating {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1040;
  background: #0D0D0D;
  border: 1px solid rgba(209, 176, 107, 0.3);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
}

.app-shell-hamburger.floating:hover {
  background: #1A1A1A;
  border-color: rgba(209, 176, 107, 0.35);
}

/* ─── User Chip (floating, top-right) ─────────────────────── */
.app-shell-user-chip {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 1040;
  display: flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.app-shell-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #D1B06B, #A8834A);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #0D0D0D;
  overflow: hidden;
  border: 2px solid rgba(209, 176, 107, 0.4);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.app-shell-avatar:hover,
.app-shell-user-chip:hover .app-shell-avatar {
  transform: scale(1.06);
  border-color: rgba(209, 176, 107, 0.8);
}

.app-shell-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.app-shell-tier-badge {
  font-size: 15px;
  line-height: 1;
  display: none;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.5));
}

.app-shell-tier-badge.autopilot { display: block; color: #5BC85B; }
.app-shell-tier-badge.playmaker { display: block; color: #D1B06B; }
.app-shell-tier-badge.analyst   { display: block; color: #9BAAD1; }

/* ─── Drawer user line (injected after .drawer-header) ─────── */
.drawer-user-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px 10px;
  border-bottom: 1px solid rgba(209, 176, 107, 0.08);
  background: #0D0D0D;
}

.drawer-user-name {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.65);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-user-tier {
  font-size: 11px;
  font-weight: 600;
  color: #D1B06B;
  background: rgba(209, 176, 107, 0.12);
  border: 1px solid rgba(209, 176, 107, 0.2);
  padding: 2px 7px;
  border-radius: 12px;
  flex-shrink: 0;
}

/* ─── Bottom Navigation Bar ────────────────────────────────── */
/* CRITICAL: Fixed to BOTTOM, full-width, ALL pages, ALL viewports.
   z-index 1001 keeps nav above page-level modals (e.g. showdown setup at z-index 1000).
   !important used to override any stale cached styles or page-level overrides. */
.bottom-nav-bar {
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  top: auto !important;
  height: 64px;
  background: #0D0D0D;
  border-top: 1px solid rgba(209, 176, 107, 0.12);
  z-index: 1001 !important;
  display: flex !important;
  align-items: stretch;
  width: 100%;
  box-sizing: border-box;
}

/* Wrapper also needs to not interfere */
#bottom-nav-container {
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  top: auto !important;
  z-index: 1001 !important;
  width: 100%;
}

.bottom-nav-inner {
  display: flex;
  width: 100%;
  height: 100%;
}

.bottom-nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: rgba(255, 255, 255, 0.5);
  font-family: var(--font-mono, 'DM Mono', monospace);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.6px;
  transition: color 0.2s ease;
  position: relative;
  cursor: pointer;
  padding: 8px 2px;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  /* Reset button defaults */
  background: transparent;
  border: none;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.bottom-nav-tab:hover,
.bottom-nav-tab:active {
  color: rgba(255, 255, 255, 0.8);
}

/* Active tab: gold highlight */
.bottom-nav-tab.active {
  color: #D1B06B;
}

.bottom-nav-tab.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 2.5px;
  background: #D1B06B;
  border-radius: 0 0 2px 2px;
}

/* Drawer-open state: gold background pulse on the tapped tab */
.bottom-nav-tab[aria-expanded="true"] {
  color: #D1B06B;
  background: rgba(209, 176, 107, 0.1);
}

.bottom-nav-tab[aria-expanded="true"]::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 2.5px;
  background: #D1B06B;
  border-radius: 0 0 2px 2px;
}

.bottom-nav-tab-icon {
  font-size: 22px;
  line-height: 1;
}

.bottom-nav-tab-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.6px;
  white-space: nowrap;
}

/* ─── Mobile-responsive sizing (375px+) ───────────────────── */
@media (max-width: 480px) {
  .bottom-nav-tab {
    padding: 6px 1px;
    gap: 2px;
  }
  .bottom-nav-tab-icon {
    font-size: 20px;
  }
  .bottom-nav-tab-label {
    font-size: 9px;
    letter-spacing: 0.4px;
  }
}

/* Landscape mobile — shorter nav */
@media (max-height: 500px) {
  .bottom-nav-bar {
    height: 52px;
  }
  .bottom-nav-tab {
    min-height: 44px;
    gap: 1px;
  }
  .bottom-nav-tab-icon {
    font-size: 18px;
  }
  .bottom-nav-tab-label {
    font-size: 8px;
  }
}

/* ─── Nudge toast positioning (above bottom nav) ──────────── */
.pc-nudge-toast {
  bottom: 80px !important;
}

/* ─── Safe area insets for notched phones ──────────────────── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .bottom-nav-bar,
  #bottom-nav-container {
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav-bar {
    height: calc(64px + env(safe-area-inset-bottom));
  }
}

/* ─── Bottom Sub-Section Drawer ────────────────────────────── */
/* Sits above the nav bar (z-index 1002), below hamburger (1040/1060).
   Slides up from behind the bottom nav on button tap.            */

.bottom-subnav-backdrop {
  position: fixed;
  inset: 0;
  bottom: 64px; /* don't cover nav bar */
  z-index: 1001; /* same level as nav — captures outside taps */
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  -webkit-backdrop-filter: blur(1px);
  backdrop-filter: blur(1px);
}

@supports (bottom: env(safe-area-inset-bottom)) {
  .bottom-subnav-backdrop {
    bottom: calc(64px + env(safe-area-inset-bottom));
  }
}

.bottom-subnav-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.bottom-subnav-drawer {
  position: fixed;
  bottom: 64px; /* sits just above the nav bar */
  left: 0;
  right: 0;
  z-index: 1002;
  background: #0D0D0D;
  border-top: 1px solid rgba(209, 176, 107, 0.2);
  border-left: none;
  border-right: none;
  border-radius: 16px 16px 0 0;
  box-shadow:
    0 -8px 40px rgba(0, 0, 0, 0.75),
    0 -1px 0 rgba(209, 176, 107, 0.08);
  transform: translateY(100%);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  max-height: 60vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@supports (bottom: env(safe-area-inset-bottom)) {
  .bottom-subnav-drawer {
    bottom: calc(64px + env(safe-area-inset-bottom));
  }
}

.bottom-subnav-drawer.open {
  transform: translateY(0);
  pointer-events: auto;
}

/* Drag handle */
.subnav-drawer-handle-wrap {
  display: flex;
  justify-content: center;
  padding: 10px 0 4px;
}

.subnav-drawer-handle {
  width: 36px;
  height: 4px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

/* Section header inside sub-drawer */
.subnav-drawer-header {
  padding: 4px 20px 12px;
  border-bottom: 1px solid rgba(209, 176, 107, 0.08);
}

.subnav-drawer-section-name {
  font-family: var(--font-mono, 'DM Mono', monospace);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #D1B06B;
}

/* Sub-section items list */
.subnav-drawer-list {
  padding: 6px 0 16px;
}

.subnav-drawer-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 52px;
  padding: 0 20px;
  text-decoration: none;
  color: rgba(255, 255, 255, 0.75);
  font-family: var(--font-primary, 'DM Sans', sans-serif);
  font-size: 15px;
  font-weight: 500;
  transition: background 0.12s ease, color 0.12s ease;
  cursor: pointer;
  border-left: 3px solid transparent;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.subnav-drawer-item:hover,
.subnav-drawer-item:active {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.subnav-drawer-item.active {
  color: #D1B06B;
  background: rgba(209, 176, 107, 0.08);
  border-left-color: #D1B06B;
}

.subnav-item-icon {
  font-size: 20px;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
  line-height: 1;
}

.subnav-item-label {
  flex: 1;
  font-weight: 500;
}

/* Gold dot indicator for active item */
.subnav-item-active-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #D1B06B;
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(209, 176, 107, 0.6);
}

/* ─── Floating AI Chat Widget (FAB) ────────────────────────── */
.ai-chat-fab {
  position: fixed;
  bottom: calc(64px + 16px); /* sit above bottom nav */
  right: 16px;
  z-index: 110;
  text-decoration: none;
  display: block;
  -webkit-tap-highlight-color: transparent;
}

@supports (bottom: env(safe-area-inset-bottom)) {
  .ai-chat-fab {
    bottom: calc(64px + env(safe-area-inset-bottom) + 16px);
  }
}

.ai-chat-fab-inner {
  display: flex;
  align-items: center;
  gap: 7px;
  background: #0D0D0D;
  border: 1px solid rgba(209, 176, 107, 0.45);
  border-radius: 28px;
  padding: 11px 16px 11px 13px;
  box-shadow:
    0 0 0 1px rgba(209, 176, 107, 0.08),
    0 4px 20px rgba(0, 0, 0, 0.55),
    0 0 24px rgba(209, 176, 107, 0.08);
  color: #D1B06B;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, transform 0.15s ease;
  cursor: pointer;
}

.ai-chat-fab:hover .ai-chat-fab-inner,
.ai-chat-fab:focus .ai-chat-fab-inner {
  background: #1A1A1A;
  border-color: rgba(209, 176, 107, 0.7);
  box-shadow:
    0 0 0 1px rgba(209, 176, 107, 0.15),
    0 6px 28px rgba(0, 0, 0, 0.65),
    0 0 32px rgba(209, 176, 107, 0.14);
  transform: translateY(-1px);
}

.ai-chat-fab:active .ai-chat-fab-inner {
  transform: translateY(0);
}

.ai-chat-fab-icon {
  flex-shrink: 0;
  color: #D1B06B;
}

.ai-chat-fab-label {
  font-family: var(--font-mono, 'DM Mono', monospace);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.6px;
  color: #D1B06B;
  white-space: nowrap;
}
