/**
 * FlashBet responsive layout — desktop full-bleed + executive mobile UI.
 */

/* ---- App shell ---- */
html {
  scroll-behavior: smooth;
}

body.sp-theme {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

body.sp-theme .site-top-chrome {
  position: sticky;
  top: 0;
  z-index: 1100;
  flex-shrink: 0;
  padding-top: env(safe-area-inset-top, 0px);
}

body.sp-theme header {
  position: relative;
  top: auto;
}

body.sp-theme > .main,
body.sp-theme > .container,
body.sp-theme > .auth-page-surface {
  flex: 1;
  width: 100%;
}

body.sp-theme footer {
  flex-shrink: 0;
  margin-top: auto;
}

/* ---- Desktop: edge-to-edge full viewport ---- */
@media (min-width: 1024px) {
  body.sp-theme:not(.game-page) .main {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    grid-template-columns: 220px minmax(0, 1fr) 320px;
    gap: 0;
    align-items: stretch;
    box-sizing: border-box;
    min-height: calc(100dvh - var(--sp-chrome-h, 108px));
  }

  body.sp-theme:not(.game-page) .betslip {
    display: block;
  }

  body.sp-theme:not(.game-page) .mobile-betslip {
    display: none;
  }

  body.sp-theme.page-live .container,
  body.sp-theme.page-cashier .container,
  body.sp-theme.page-mybets .container {
    width: 100%;
    max-width: 100%;
    padding-left: clamp(16px, 2.5vw, 40px);
    padding-right: clamp(16px, 2.5vw, 40px);
    box-sizing: border-box;
  }

  body.sp-theme:not(.game-page) .content {
    min-height: 0;
    border-radius: 0;
  }

  body.sp-theme:not(.game-page) .betslip {
    position: sticky;
    top: var(--sp-chrome-h, 108px);
    max-height: calc(100dvh - var(--sp-chrome-h, 108px));
    overflow: hidden;
    border-radius: 0;
  }

  body.sp-theme:not(.game-page) aside.sports-sidebar {
    top: var(--sp-chrome-h, 108px);
    max-height: calc(100dvh - var(--sp-chrome-h, 108px));
    border-radius: 0;
  }

  body.sp-theme .banner-slider {
    --banner-height: clamp(180px, 18vh, 240px);
  }
}

@media (min-width: 1440px) {
  body.sp-theme:not(.game-page) .main {
    grid-template-columns: 240px minmax(0, 1fr) 340px;
  }
}

/* ---- Tablet ---- */
@media (min-width: 769px) and (max-width: 1023px) {
  body.sp-theme:not(.game-page) .main {
    width: 100%;
    max-width: 100%;
    padding: 16px;
    grid-template-columns: 200px minmax(0, 1fr);
  }

  body.sp-theme:not(.game-page) .mobile-betslip {
    display: flex;
    bottom: 24px;
    right: 20px;
  }

  body.sp-theme:not(.game-page) .betslip-drawer {
    max-width: 420px;
    left: auto;
    right: 16px;
    bottom: 16px;
    border-radius: 16px;
    transform: translateY(calc(100% + 24px));
    max-height: min(80dvh, 640px);
  }

  body.sp-theme:not(.game-page) .betslip-drawer.open {
    transform: translateY(0);
  }
}

/* ---- Mobile executive UI ---- */
@media (max-width: 768px) {
  body.sp-theme.has-mobile-nav {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }

  body.sp-theme header {
    padding: 10px 14px;
    gap: 8px;
    flex-wrap: nowrap;
  }

  body.sp-theme header a.logo.logo--image .site-logo-img {
    height: 26px;
    max-width: 92px;
  }

  body.sp-theme header a.logo {
    font-size: 1.25rem;
    flex-shrink: 0;
  }

  body.sp-theme .user-info {
    gap: 8px;
    margin-left: auto;
    justify-content: flex-end;
  }

  body.sp-theme .user-info > span:first-child {
    display: none;
  }

  body.sp-theme .top-actions {
    display: none;
  }

  body.sp-theme .guest-header-actions .guest-tagline {
    display: none;
  }

  body.sp-theme .guest-header-actions {
    gap: 8px;
    margin-left: auto;
  }

  body.sp-theme .guest-header-actions .btn-login,
  body.sp-theme .guest-header-actions .btn-register {
    padding: 8px 14px;
    font-size: 0.8125rem;
    min-height: 40px;
  }

  body.sp-theme .balance {
    font-size: 0.75rem;
    padding: 6px 10px;
    white-space: nowrap;
  }

  /* Hide desktop nav — bottom nav replaces it */
  body.sp-theme.has-mobile-nav .site-top-chrome > nav:not(.mobile-bottom-nav) {
    display: none;
  }

  body.sp-theme:not(.game-page) .main {
    padding: 10px 12px 16px;
    gap: 12px;
  }

  body.sp-theme:not(.game-page) .content {
    padding: 14px 12px;
    border-radius: 14px;
    min-height: auto;
  }

  body.sp-theme .banner-slider {
    --banner-height: 140px;
    border-radius: 12px;
  }

  body.sp-theme .featured-card {
    min-width: 88px;
    height: 88px;
    border-radius: 12px;
  }

  body.sp-theme .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 4px;
    margin-bottom: 12px;
  }

  body.sp-theme .tabs::-webkit-scrollbar {
    display: none;
  }

  body.sp-theme .tabs span {
    flex-shrink: 0;
    padding: 10px 14px;
    font-size: 0.8125rem;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
  }

  body.sp-theme .filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
    margin-bottom: 12px;
  }

  body.sp-theme .filters::-webkit-scrollbar {
    display: none;
  }

  body.sp-theme .filters button {
    flex-shrink: 0;
    min-height: 36px;
    padding: 8px 14px;
  }

  body.sp-theme .match-row {
    padding: 12px 10px;
    border-radius: 10px;
    margin-bottom: 8px;
    border: 1px solid var(--sp-border);
    border-bottom: 1px solid var(--sp-border);
  }

  body.sp-theme .match-odds .odds {
    padding: 12px 4px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9375rem;
  }

  /* Bottom nav handles betslip — hide redundant FAB on phones */
  body.sp-theme.has-mobile-nav .mobile-betslip {
    display: none !important;
  }

  body.sp-theme .betslip-drawer {
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    max-height: 85dvh;
    border-radius: 20px 20px 0 0;
  }

  body.sp-theme footer {
    padding: 20px 16px calc(72px + env(safe-area-inset-bottom, 0px));
    font-size: 0.6875rem;
  }

  body.sp-theme.page-live .container,
  body.sp-theme.page-cashier .container,
  body.sp-theme.page-mybets .container {
    padding: 12px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  body.sp-theme .match-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  body.sp-theme .match-info {
    width: 100%;
  }

  body.sp-theme .match-odds {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  body.sp-theme .featured-wrapper {
    margin-left: -4px;
    margin-right: -4px;
  }

  body.sp-theme .featured-scroll {
    padding-left: 4px;
    padding-right: 4px;
  }
}

/* Sports drawer nav — match desktop sidebar colours */
.sports-drawer-nav .sport {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  padding: 12px 16px;
  font-size: 0.875rem;
  color: #8b96a2;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: inherit;
  border-left: 3px solid transparent;
}

.sports-drawer-nav .sport:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.sports-drawer-nav .sport.active {
  color: #fff;
  font-weight: 700;
  background: transparent;
  border-left-color: transparent;
}

/* Mobile sports strip */
.mobile-sports-bar {
  display: none;
}

@media (max-width: 768px) {
  body.sp-theme:not(.game-page) .mobile-sports-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    grid-column: 1 / -1;
  }

  .mobile-sports-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 2px 0;
  }

  .mobile-sports-scroll::-webkit-scrollbar {
    display: none;
  }

  .mobile-sport-chip {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    min-height: 40px;
    border-radius: 999px;
    border: 1px solid var(--sp-border);
    background: var(--sp-surface);
    color: var(--sp-ink-muted);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    -webkit-appearance: none;
    appearance: none;
  }

  .mobile-sport-chip {
    gap: 6px;
  }

  .mobile-sports-more {
    flex-shrink: 0;
    min-height: 40px;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid var(--sp-gold);
    background: var(--sp-gold-soft);
    color: var(--sp-green-deep);
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }

  .mobile-sports-more i {
    font-size: 0.75rem;
    color: var(--sp-green-dark);
  }
}

/* Sports drawer (mobile) */
.sports-drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.sports-drawer-overlay.open {
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
}

.sports-drawer {
  width: min(300px, 88vw);
  max-width: 100%;
  background: #1a1f2e;
  color: #8b96a2;
  display: flex;
  flex-direction: column;
  box-shadow: 8px 0 32px rgba(0, 0, 0, 0.35);
  animation: fbSlideIn 0.25s ease;
}

@keyframes fbSlideIn {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

.sports-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: #1a1f2e;
  color: #fff;
}

.sports-drawer-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.sports-drawer-close {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  line-height: 1;
}

.sports-drawer-nav {
  overflow-y: auto;
  flex: 1;
  padding: 8px 0;
  -webkit-overflow-scrolling: touch;
}

.sports-drawer-nav .sport {
  width: 100%;
}

/* Bottom navigation */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  body.sp-theme.has-mobile-nav .mobile-bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1150;
    background: #fff;
    border-top: 1px solid var(--sp-border);
    box-shadow: 0 -4px 24px rgba(0, 94, 38, 0.1);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
    justify-content: space-around;
    align-items: stretch;
    gap: 2px;
  }

  .mobile-bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 4px;
    min-height: 52px;
    border: none;
    background: transparent;
    color: var(--sp-ink-muted);
    text-decoration: none;
    font-size: 0.625rem;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    position: relative;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-bottom-nav-item.active,
  .mobile-bottom-nav-item:active {
    color: var(--sp-green-dark);
    background: transparent;
  }

  .mobile-nav-badge {
    position: absolute;
    top: 4px;
    right: calc(50% - 22px);
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: linear-gradient(135deg, #ffb81c, #f7941d);
    color: #005e26;
    font-size: 0.5625rem;
    font-weight: 800;
    font-style: normal;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
  }
}

/* Auth pages mobile */
@media (max-width: 768px) {
  body.sp-theme .auth-page-surface {
    padding: 16px 12px 24px;
    min-height: auto;
  }

  body.sp-theme .auth-page-surface .login-container,
  body.sp-theme .auth-page-surface .register-container {
    padding: 24px 20px;
    border-radius: 16px;
  }
}

/* Game pages: compact chrome on mobile — bottom nav + sticky game strip */
@media (max-width: 768px) {
  body.sp-theme.game-page {
    --sp-chrome-h: 52px;
  }

  body.sp-theme.game-page.has-mobile-nav {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }

  /* Same as other pages: hide crowded top nav; use game-categories + bottom nav */
  body.sp-theme.game-page.has-mobile-nav .site-top-chrome > nav:not(.mobile-bottom-nav) {
    display: none;
  }

  body.sp-theme.game-page .mobile-bottom-nav {
    display: flex;
  }
}
