/* styles.css - Custom styling and themes for Golf Foursome Betting App */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@500;700;800&display=swap');

:root {
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  /* Default Sunlight (Light) Mode Tokens */
  --bg-main: #f0f7f3;
  --bg-card: #ffffff;
  --bg-card-gold: #fefce8;
  --bg-nav: rgba(255, 255, 255, 0.95);
  --bg-header: rgba(255, 255, 255, 0.96);
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-subtle: #64748b;
  --border-main: #cbd5e1;
  --border-green: rgba(16, 185, 129, 0.35);
  --balance-bg: #f8fafc;
  --balance-border: #e2e8f0;
  --table-border: #e2e8f0;
  --sticky-col-bg: #ffffff;
  --sticky-col-shadow: rgba(0, 0, 0, 0.08);

  /* Safe Area Inset Variables with Fallbacks */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

html.dark {
  /* Clubhouse (Dark) Mode Tokens */
  --bg-main: #070c0a;
  --bg-card: rgba(13, 27, 21, 0.85);
  --bg-card-gold: rgba(28, 22, 11, 0.85);
  --bg-nav: rgba(7, 12, 10, 0.9);
  --bg-header: rgba(7, 13, 10, 0.92);
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  --border-main: rgba(52, 211, 153, 0.18);
  --border-green: rgba(52, 211, 153, 0.25);
  --balance-bg: rgba(15, 23, 42, 0.6);
  --balance-border: rgba(30, 41, 59, 0.8);
  --table-border: rgba(52, 211, 153, 0.15);
  --sticky-col-bg: #0c2016;
  --sticky-col-shadow: rgba(0, 0, 0, 0.35);
}

html {
  box-sizing: border-box;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-y;
  transition: background-color 0.25s ease, color 0.25s ease;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  padding-left: var(--sal);
  padding-right: var(--sar);
  padding-bottom: calc(5.5rem + var(--sab));
  overflow-x: hidden;
  overflow-y: visible;
}

/* Header Safe Area Handling */
header {
  padding-top: max(0.625rem, calc(0.5rem + var(--sat))) !important;
  width: 100%;
  box-sizing: border-box;
}

/* Bottom Navigation Bar Safe Area Handling */
nav.glass-nav {
  padding-bottom: max(0.625rem, calc(0.375rem + var(--sab))) !important;
}

/* Custom Scrollbar for touch-friendly horizontal and vertical lists */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.1);
  border-radius: 9999px;
}
html.dark ::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.6);
}
::-webkit-scrollbar-thumb {
  background: rgba(16, 185, 129, 0.35);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(16, 185, 129, 0.55);
}

/* Touch friendly momentum horizontal scrolling */
.overflow-x-auto,
.overflow-y-auto {
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

/* Hide scrollbar utility for clean mobile swipe bars */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Panels & Cards */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-green);
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.07);
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.glass-panel-gold {
  background: var(--bg-card-gold);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(245, 158, 11, 0.35);
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.07);
}

.glass-nav {
  background: var(--bg-nav);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-green);
}

/* ========================================================= */
/* AUTHENTIC GOLF SCORECARD & STICKY MOBILE PLAYER COLUMN     */
/* ========================================================= */
.golf-scorecard-table {
  border-collapse: separate;
  border-spacing: 0;
  font-family: var(--font-mono);
  width: 100%;
}

.golf-scorecard-table th,
.golf-scorecard-table td {
  border-right: 1px solid var(--table-border);
  border-bottom: 1px solid var(--table-border);
  white-space: nowrap;
}

.golf-scorecard-table th:last-child,
.golf-scorecard-table td:last-child {
  border-right: none;
}

/* Sticky First Column for Mobile Horizontal Swiping across 18 holes */
.golf-scorecard-table th:first-child,
.golf-scorecard-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 10;
  background-color: var(--sticky-col-bg);
  box-shadow: 3px 0 6px -1px var(--sticky-col-shadow);
}

.golf-scorecard-table thead tr th:first-child {
  z-index: 20;
}

.scorecard-cell {
  position: relative;
  min-width: 34px;
  height: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.score-mark {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  font-weight: 800;
  font-size: 13px;
  border-radius: 4px;
}

/* Authentic Golf Scorecard Shapes */
.score-circle {
  border-radius: 9999px;
  border: 2px solid #059669;
  color: #047857;
  background: rgba(16, 185, 129, 0.18);
  font-weight: 900;
}

html.dark .score-circle {
  border: 1.8px solid #10b981;
  color: #34d399;
  background: rgba(16, 185, 129, 0.25);
}

.score-double-circle {
  border-radius: 9999px;
  border: 3px double #d97706;
  color: #b45309;
  background: rgba(245, 158, 11, 0.22);
  font-weight: 900;
}

html.dark .score-double-circle {
  border: 2.5px double #f59e0b;
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.25);
}

.score-square {
  border-radius: 4px;
  border: 2px solid #2563eb;
  color: #1d4ed8;
  background: rgba(37, 99, 235, 0.15);
  font-weight: 800;
}

html.dark .score-square {
  border: 1.5px solid #38bdf8;
  color: #7dd3fc;
  background: rgba(56, 189, 248, 0.18);
}

.score-double-square {
  border-radius: 4px;
  border: 3px double #e11d48;
  color: #be123c;
  background: rgba(225, 29, 72, 0.18);
  font-weight: 900;
}

html.dark .score-double-square {
  border: 2.5px double #f43f5e;
  color: #fda4af;
  background: rgba(244, 63, 94, 0.25);
}

.score-par-mark {
  color: var(--text-main);
  font-weight: 700;
}

.stroke-dot-indicator {
  position: absolute;
  top: 1px;
  right: 2px;
  font-size: 10px;
  line-height: 1;
  color: #d97706;
  letter-spacing: -1px;
  font-weight: 900;
}

html.dark .stroke-dot-indicator {
  color: #fbbf24;
}

/* ========================================================= */
/* MOBILE TOUCH CONTROLS & GLOVE-FRIENDLY HIT TARGETS        */
/* ========================================================= */
.touch-btn,
.hole-pill-btn,
.nav-tab-btn,
button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.1s ease, background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.touch-btn:active {
  transform: scale(0.94);
}

/* HIGH VISIBILITY SCORE PRESET BUTTONS (Course Sunlight View) */
.btn-score-birdie {
  background: #059669 !important;
  color: #ffffff !important;
  border: 2px solid #34d399 !important;
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.25);
}
.btn-score-birdie:hover {
  background: #047857 !important;
}
.btn-score-birdie.is-selected {
  background: #10b981 !important;
  border: 3px solid #ffffff !important;
  outline: 3px solid #059669 !important;
  box-shadow: 0 4px 14px rgba(5, 150, 105, 0.5) !important;
  transform: scale(1.05);
}

.btn-score-par {
  background: #2563eb !important;
  color: #ffffff !important;
  border: 2px solid #60a5fa !important;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}
.btn-score-par:hover {
  background: #1d4ed8 !important;
}
.btn-score-par.is-selected {
  background: #3b82f6 !important;
  border: 3px solid #ffffff !important;
  outline: 3px solid #1d4ed8 !important;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.5) !important;
  transform: scale(1.05);
}

.btn-score-bogey {
  background: #d97706 !important;
  color: #ffffff !important;
  border: 2px solid #fbbf24 !important;
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.25);
}
.btn-score-bogey:hover {
  background: #b45309 !important;
}
.btn-score-bogey.is-selected {
  background: #f59e0b !important;
  border: 3px solid #ffffff !important;
  outline: 3px solid #b45309 !important;
  box-shadow: 0 4px 14px rgba(217, 119, 6, 0.5) !important;
  transform: scale(1.05);
}

.btn-score-double {
  background: #e11d48 !important;
  color: #ffffff !important;
  border: 2px solid #f43f5e !important;
  box-shadow: 0 2px 8px rgba(225, 29, 72, 0.25);
}
.btn-score-double:hover {
  background: #be123c !important;
}
.btn-score-double.is-selected {
  background: #f43f5e !important;
  border: 3px solid #ffffff !important;
  outline: 3px solid #be123c !important;
  box-shadow: 0 4px 14px rgba(225, 29, 72, 0.5) !important;
  transform: scale(1.05);
}

/* Stepper Buttons (- and +) */
.btn-stepper-dark {
  background: #0f172a !important;
  color: #ffffff !important;
  border: 2px solid #334155 !important;
}
html.dark .btn-stepper-dark {
  background: #1e293b !important;
  color: #f8fafc !important;
  border: 2px solid #475569 !important;
}

/* Hide spin buttons on number inputs */
input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { 
  -webkit-appearance: none; 
  margin: 0; 
}
input[type=number] {
  -moz-appearance: textfield;
}

/* Subtle, legible placeholder ghost text for fast name entry */
input::placeholder {
  color: #64748b;
  opacity: 0.75;
  font-style: normal;
  font-weight: 500;
}
.dark input::placeholder {
  color: #94a3b8;
  opacity: 0.65;
}

/* Smooth Tab transitions */
.tab-content {
  display: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.tab-content.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

/* ========================================================= */
/* MOBILE BOTTOM SHEETS & RESPONSIVE MODAL DIALOGS           */
/* ========================================================= */
.modal-active {
  display: flex !important;
}

.modal-hidden {
  display: none !important;
}

@media (max-width: 640px) {
  /* Transform modals to bottom sheets on mobile devices */
  .mobile-bottom-sheet {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  
  .mobile-bottom-sheet-card {
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    border-top-left-radius: 1.75rem !important;
    border-top-right-radius: 1.75rem !important;
    max-height: 88dvh !important;
    width: 100% !important;
    max-width: 100% !important;
    padding-bottom: calc(1.5rem + var(--sab)) !important;
    animation: slideUpSheet 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }

  .sheet-pull-handle {
    width: 36px;
    height: 4px;
    border-radius: 9999px;
    background-color: rgba(148, 163, 184, 0.4);
    margin: 0 auto 10px auto;
  }
}

@keyframes slideUpSheet {
  from {
    transform: translateY(100%);
    opacity: 0.6;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Screen Wake Lock Active Beacon */
.wakelock-active {
  background-color: rgba(16, 185, 129, 0.25) !important;
  color: #10b981 !important;
  border-color: rgba(16, 185, 129, 0.5) !important;
}
.wakelock-pulse {
  animation: wakePulse 2s infinite;
}
@keyframes wakePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.9); }
}

/* ========================================================= */
/* GOLF CART PHONE MOUNT LANDSCAPE OPTIMIZATION             */
/* ========================================================= */
@media (max-height: 520px) and (orientation: landscape) {
  body {
    padding-bottom: calc(4.2rem + var(--sab));
  }
  header {
    padding-top: 4px !important;
    padding-bottom: 4px !important;
  }
  header .max-w-4xl {
    gap: 4px;
  }
  #balance-card-p1, #balance-card-p2, #balance-card-p3, #balance-card-p4 {
    padding: 2px 4px !important;
  }
  nav.glass-nav {
    padding-top: 4px !important;
    padding-bottom: max(4px, var(--sab)) !important;
  }
  nav.glass-nav i {
    width: 18px;
    height: 18px;
  }
  nav.glass-nav span {
    font-size: 9px;
  }
}
