/* Midwest InterHub Performance Hub - iOS Optimized Stylesheet */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Outfit:wght@500;600;700;800&display=swap');

:root {
  --bg-dark: #070a13;
  --bg-dark-accent: #0f1423;
  --glass-bg: rgba(14, 20, 36, 0.72);
  --glass-border: rgba(255, 255, 255, 0.07);
  --glass-border-focus: rgba(0, 242, 254, 0.35);
  
  /* Neons */
  --neon-cyan: #00f2fe;
  --neon-blue: #4facfe;
  --neon-green: #00f5a0;
  --neon-orange: #ff9f0a;
  --neon-red: #ff3b30;
  
  /* Text */
  --text-primary: #ffffff;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  /* Fonts */
  --font-title: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  /* Safe Areas (Optimized for iPhone 14 Pro) */
  --safe-top: env(safe-area-inset-top, 47px);
  --safe-bottom: env(safe-area-inset-bottom, 34px);
}

/* Base Reset & Mobile Container Lock */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-dark);
  color: var(--text-primary);
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Lock viewport size and center on desktop; expand to full screen on iPhone */
#app-container {
  width: 100%;
  max-width: 480px; /* iPhone 14 Pro Max width lock */
  height: 100dvh;
  background-color: var(--bg-dark);
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-left: 1px solid rgba(255, 255, 255, 0.05);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
}

/* Background Gradients */
.glow-bg {
  position: absolute;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.15;
  z-index: 0;
  pointer-events: none;
}

.glow-top {
  background: var(--neon-cyan);
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
}

.glow-bottom {
  background: var(--neon-blue);
  bottom: -100px;
  right: -50px;
}

/* Header Styling with Dynamic Island safe area */
header {
  padding: calc(var(--safe-top) + 12px) 20px 16px;
  background: linear-gradient(180deg, rgba(7, 10, 19, 0.9) 0%, rgba(7, 10, 19, 0.3) 100%);
  border-bottom: 1px solid var(--glass-border);
  z-index: 10;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.header-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 {
  font-family: var(--font-title);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

header p {
  font-size: 11px;
  color: var(--neon-cyan);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 1.5px;
  margin-top: 2px;
}

.team-badge {
  background: rgba(0, 242, 254, 0.1);
  border: 1px solid rgba(0, 242, 254, 0.2);
  color: var(--neon-cyan);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Content Pane Area */
main {
  flex: 1;
  width: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px calc(80px + var(--safe-bottom)); /* Add extra padding so bottom-bar doesn't clip content */
  z-index: 1;
  position: relative;
}

/* Tab Panel States */
.tab-pane {
  display: none;
  animation: fadeIn 0.3s ease-out forwards;
}

.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Tab Bar Navigation (Bottom Sticky) */
.tab-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(64px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(11, 16, 31, 0.92);
  border-top: 1px solid var(--glass-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 50;
}

.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px 16px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.tab-btn i {
  font-size: 20px;
  margin-bottom: 4px;
}

.tab-btn span {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.tab-btn.active {
  color: var(--neon-cyan);
  text-shadow: 0 0 10px rgba(0, 242, 254, 0.35);
}

.tab-btn.active i {
  transform: translateY(-2px);
  color: var(--neon-cyan);
}

/* Search and Filters Bar */
.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.search-input-wrapper {
  flex: 1;
  position: relative;
}

.search-input-wrapper i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
}

.search-input-wrapper input {
  width: 100%;
  background: var(--bg-dark-accent);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 12px 14px 12px 40px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  transition: all 0.2s ease;
}

.search-input-wrapper input:focus {
  outline: none;
  border-color: var(--neon-cyan);
  box-shadow: 0 0 12px rgba(0, 242, 254, 0.15);
}

/* Pill Filter Buttons */
.filters-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin-bottom: 8px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.filters-scroll::-webkit-scrollbar {
  display: none;
}

.filter-pill {
  white-space: nowrap;
  background: var(--bg-dark-accent);
  border: 1px solid var(--glass-border);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-pill.active {
  background: rgba(0, 242, 254, 0.12);
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.1);
}

/* Premium Player Card Layout */
.players-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.player-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.player-card:active {
  transform: scale(0.97);
  background: rgba(14, 20, 36, 0.9);
  border-color: var(--glass-border-focus);
}

.player-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: transparent;
  transition: background-color 0.2s ease;
}

.player-card.has-captaincy::before {
  background: var(--neon-orange);
}

.player-card-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.player-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--bg-dark-accent) 0%, rgba(0, 242, 254, 0.1) 100%);
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-title);
  font-weight: 700;
  color: var(--neon-cyan);
  font-size: 16px;
}

.player-info h3 {
  font-family: var(--font-title);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.player-role-badge {
  font-size: 10px;
  color: var(--neon-orange);
  background: rgba(255, 159, 10, 0.1);
  border: 1px solid rgba(255, 159, 10, 0.15);
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 700;
}

.player-styles {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
  display: flex;
  gap: 8px;
}

.player-styles span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.player-styles i {
  font-size: 10px;
  color: var(--text-muted);
}

.player-stats-preview {
  display: flex;
  gap: 12px;
}

.stat-bubble {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.stat-bubble-val {
  font-family: var(--font-title);
  font-size: 15px;
  font-weight: 800;
  color: var(--text-primary);
}

.stat-bubble-val.runs {
  color: var(--neon-green);
}

.stat-bubble-val.wkts {
  color: var(--neon-cyan);
}

.stat-bubble-label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-top: 1px;
}

/* Interactive Team Sheet (Batting 11 Tab) */
.builder-split {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sheet-section-title {
  font-family: var(--font-title);
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sheet-section-title span.count {
  font-size: 12px;
  background: rgba(0, 242, 254, 0.12);
  color: var(--neon-cyan);
  padding: 2px 10px;
  border-radius: 12px;
  font-weight: 700;
}

.lineup-list {
  background: rgba(14, 20, 36, 0.4);
  border: 1px dashed var(--glass-border);
  border-radius: 20px;
  padding: 12px;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lineup-list.active-filled {
  border-style: solid;
  border-color: rgba(0, 242, 254, 0.15);
}

.lineup-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 40px 20px;
  gap: 8px;
}

.lineup-placeholder i {
  font-size: 32px;
  color: rgba(255, 255, 255, 0.05);
}

/* Selectable Lineup Card */
.lineup-row {
  background: var(--bg-dark-accent);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.2s ease;
}

.lineup-row-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.batting-order-num {
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, var(--neon-cyan) 0%, var(--neon-blue) 100%);
  color: var(--bg-dark);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 12px;
}

.lineup-name {
  font-family: var(--font-title);
  font-size: 14px;
  font-weight: 700;
}

.lineup-style {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.remove-lineup-btn {
  background: none;
  border: none;
  color: var(--neon-red);
  font-size: 18px;
  padding: 8px;
  cursor: pointer;
}

/* Pool of Players for Selector */
.pool-scroll {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pool-row {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s ease;
}

.pool-row.selected {
  opacity: 0.45;
  border-style: dashed;
  background: rgba(0, 0, 0, 0.2);
}

.pool-row-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pool-info h4 {
  font-family: var(--font-title);
  font-size: 14px;
  font-weight: 700;
}

.pool-style {
  font-size: 11px;
  color: var(--text-secondary);
}

.add-lineup-btn {
  background: rgba(0, 242, 254, 0.1);
  border: 1px solid rgba(0, 242, 254, 0.2);
  color: var(--neon-cyan);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.add-lineup-btn:active {
  transform: scale(0.85);
  background: var(--neon-cyan);
  color: var(--bg-dark);
}

/* Insights Dashboard Tab */
.insights-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.insight-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.insight-card-header {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.insight-card-value {
  font-family: var(--font-title);
  font-size: 24px;
  font-weight: 800;
  color: var(--neon-cyan);
  margin-top: 8px;
}

.insight-card-value.green {
  color: var(--neon-green);
}

.insight-card-value.orange {
  color: var(--neon-orange);
}

.insight-card-sub {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Suggested batting order toggle alert card */
.suggestion-banner {
  background: linear-gradient(135deg, rgba(0, 242, 254, 0.1) 0%, rgba(79, 172, 254, 0.1) 100%);
  border: 1px solid rgba(0, 242, 254, 0.2);
  border-radius: 16px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  cursor: pointer;
}

.suggestion-banner i {
  font-size: 24px;
  color: var(--neon-cyan);
}

.suggestion-banner-text h4 {
  font-family: var(--font-title);
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
}

.suggestion-banner-text p {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* iOS Bottom Sliding Performance Sheet */
.bottom-sheet-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.bottom-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 85dvh;
  background: var(--bg-dark);
  border-top: 1px solid var(--glass-border-focus);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  z-index: 101;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.94, 0.6, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
}

.bottom-sheet.open {
  transform: translateY(0);
}

/* Drag Handle */
.bottom-sheet-handle {
  width: 40px;
  height: 5px;
  background: var(--text-muted);
  border-radius: 3px;
  margin: 10px auto 14px;
  opacity: 0.5;
  flex-shrink: 0;
}

/* Sheet Title & Profile Header */
.sheet-header {
  padding: 0 20px 16px;
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}

.sheet-profile-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sheet-profile-row h2 {
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: 800;
}

.sheet-profile-styles {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Scrollable performance details */
.sheet-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px;
}

/* Quick KPI Grid in Sheet */
.stats-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}

.stats-summary-card {
  background: var(--bg-dark-accent);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 10px;
  text-align: center;
}

.stats-summary-val {
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: 800;
}

.stats-summary-val.runs {
  color: var(--neon-green);
}

.stats-summary-val.wkts {
  color: var(--neon-cyan);
}

.stats-summary-label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 700;
  margin-top: 2px;
}

/* Match Log Tables */
.sheet-section-heading {
  font-family: var(--font-title);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sheet-section-heading i {
  color: var(--neon-cyan);
}

.match-log-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.match-log-row {
  background: rgba(14, 20, 36, 0.5);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.15s ease;
}

.match-log-row:active {
  background: rgba(0, 242, 254, 0.05);
  border-color: var(--glass-border-focus);
}

.match-row-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.match-row-opp {
  font-family: var(--font-title);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.match-row-meta {
  font-size: 10px;
  color: var(--text-muted);
}

.match-row-result-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  margin-top: 2px;
}

.match-row-result-badge.win {
  background: rgba(0, 245, 160, 0.1);
  color: var(--neon-green);
}

.match-row-result-badge.loss {
  background: rgba(255, 59, 48, 0.1);
  color: var(--neon-red);
}

.match-row-result-badge.tie {
  background: rgba(0, 242, 254, 0.1);
  color: var(--neon-cyan);
}

.match-row-right {
  text-align: right;
  display: flex;
  align-items: center;
  gap: 14px;
}

.match-row-score {
  font-family: var(--font-title);
  font-size: 15px;
  font-weight: 800;
}

.score-details {
  font-size: 10px;
  color: var(--text-secondary);
}

.scorecard-chevron {
  color: var(--text-muted);
  font-size: 12px;
}

/* Empty Match state inside bottom sheet */
.empty-log-state {
  text-align: center;
  padding: 24px;
  border: 1px dashed var(--glass-border);
  border-radius: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Dynamic Close Button for Sheet */
.sheet-close-btn {
  background: var(--bg-dark-accent);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Custom Webkit scrollbar for premium touch desktop preview */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}
