/* ==========================================================================
   PPR Draft Assistant - Modern Mobile-First Stylesheet
   ========================================================================== */

/* --- CSS Variables & Design Tokens --- */
:root {
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --bg-input: #0f172a;
  --border-color: #334155;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-inverse: #0f172a;

  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --accent-gold: #f59e0b;
  --accent-green: #10b981;
  --accent-red: #ef4444;

  /* Position Base Colors */
  --pos-qb: #ef4444;  /* Red */
  --pos-rb: #3b82f6;  /* Blue */
  --pos-wr: #10b981;  /* Green */
  --pos-te: #f59e0b;  /* Orange/Gold */
  --pos-k:  #8b5cf6;  /* Purple */
  --pos-def:#64748b;  /* Slate */

  /* Touch & Spacing Standards */
  --min-touch-target: 44px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

/* --- Base Reset & Typography --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden; /* Prevents whole-page horizontal scrolling/zooming */
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  padding-bottom: 80px; /* Space for sticky mobile navigation */
}

/* --- Position Theme Full-Field Styling --- */
.pos-QB {
  background-color: rgba(239, 68, 68, 0.25) !important;
  border: 1px solid var(--pos-qb) !important;
  color: #fca5a5 !important;
}

.pos-RB {
  background-color: rgba(59, 130, 246, 0.25) !important;
  border: 1px solid var(--pos-rb) !important;
  color: #93c5fd !important;
}

.pos-WR {
  background-color: rgba(16, 185, 129, 0.25) !important;
  border: 1px solid var(--pos-wr) !important;
  color: #6ee7b7 !important;
}

.pos-TE {
  background-color: rgba(245, 158, 11, 0.25) !important;
  border: 1px solid var(--pos-te) !important;
  color: #fcd34d !important;
}

.pos-K {
  background-color: rgba(139, 92, 246, 0.25) !important;
  border: 1px solid var(--pos-k) !important;
  color: #c4b5fd !important;
}

.pos-DEF {
  background-color: rgba(100, 116, 139, 0.25) !important;
  border: 1px solid var(--pos-def) !important;
  color: #cbd5e1 !important;
}

.pos-OTHER {
  background-color: rgba(148, 163, 184, 0.15) !important;
  border: 1px solid var(--border-color) !important;
  color: var(--text-main) !important;
}

/* --- Sticky Draft Banner (Top) --- */
.top-status-bar {
  position: sticky;
  top: 0;
  z-index: 900;
  background-color: var(--bg-card);
  border-bottom: 2px solid var(--border-color);
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  width: 100%;
}

.status-clock {
  display: flex;
  flex-direction: column;
}

.status-clock .pick-number {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--accent-gold);
  line-height: 1.1;
}

.status-clock .team-on-clock {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.my-turn-card {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background-color: rgba(255, 255, 255, 0.05);
  font-size: 0.85rem;
  font-weight: 600;
}

.my-turn-card.active {
  background-color: var(--accent-green);
  color: var(--text-inverse);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.75; }
  100% { opacity: 1; }
}

/* --- Main Layout Grid --- */
.app-container {
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
  margin: 0 auto;
  padding: 16px;
  overflow-x: hidden;
}

.setup-panel {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  width: 100%;
}

.setup-panel.hidden {
  display: none;
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 16px;
  align-items: start;
  width: 100%;
}

/* Fix CSS grid overflow issue so child elements can scroll horizontally */
.analytics-section {
  min-width: 0;
  width: 100%;
}

/* --- Controls & Inputs --- */
input, select, button {
  font-family: inherit;
  font-size: 0.95rem;
}

input[type="text"], select {
  width: 100%;
  height: var(--min-touch-target);
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 0 12px;
}

button {
  min-height: var(--min-touch-target);
  padding: 0 16px;
  border: none;
  border-radius: var(--radius-sm);
  background-color: var(--primary);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease;
}

button:hover {
  background-color: var(--primary-hover);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- Filter & Search Controls --- */
.controls-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.filter-row {
  display: flex;
  gap: 8px;
}

/* --- Player Rankings List --- */
.rankings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 75vh;
  overflow-y: auto;
  padding-right: 4px;
}

.player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  gap: 12px;
}

.player-row.drafted {
  opacity: 0.35;
  filter: grayscale(80%);
}

.player-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.rank-badge {
  font-weight: 800;
  font-size: 0.9rem;
  min-width: 28px;
  text-align: center;
}

.player-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.player-name {
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-meta {
  font-size: 0.8rem;
  opacity: 0.85;
}

.player-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.adp-badge {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 0.75rem;
  line-height: 1.2;
}

.adp-value {
  font-weight: 700;
  font-size: 0.9rem;
}

.draft-btn {
  min-height: 38px;
  padding: 0 14px;
  font-size: 0.85rem;
}

/* --- Run Tracker Cards --- */
.run-tracker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
  width: 100%;
}

.run-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
}

.run-card.warning { border-color: var(--accent-gold); }
.run-card.active  { border-color: var(--accent-red); }

.run-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.run-card-header h3 {
  font-size: 0.95rem;
}

.run-status {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background-color: var(--border-color);
}

.run-card.warning .run-status { background-color: var(--accent-gold); color: #000; }
.run-card.active .run-status { background-color: var(--accent-red); color: #fff; }

.run-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
  font-size: 0.75rem;
}

.run-metric span {
  display: block;
  color: var(--text-muted);
}

/* --- Draft Board Container (Smooth Horizontal Touch Scroll) --- */
.table-responsive {
  width: 100%;
  max-width: 100%;
  overflow-x: scroll !important;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 20px;
}

.draft-board-table {
  width: 1000px !important;
  min-width: 1000px !important;
  border-collapse: separate;
  border-spacing: 2px;
  font-size: 0.75rem;
  text-align: center;
}

.draft-board-table th, 
.draft-board-table td {
  padding: 6px 4px;
  width: 95px !important;
  min-width: 95px !important;
}

.draft-board-table th {
  background-color: var(--bg-input);
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.pick-cell {
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.pick-cell span {
  display: block;
  font-size: 0.7rem;
  opacity: 0.85;
}

.pick-cell.pick-current {
  outline: 2px solid var(--accent-gold);
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
}

/* --- Roster Cards & Position Slots --- */
.rosters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 16px;
  width: 100%;
}

.roster-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
}

.roster-card h3 {
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 6px;
  margin-bottom: 8px;
}

.roster-slot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  margin-bottom: 4px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
}

.roster-slot b {
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 4px;
  background-color: rgba(0, 0, 0, 0.3);
  text-transform: uppercase;
}

/* --- Mobile Navigation Bar --- */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background-color: var(--bg-card);
  border-top: 1px solid var(--border-color);
  z-index: 1000;
  justify-content: space-around;
  align-items: center;
  width: 100%;
}

.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.75rem;
  background: none;
  border: none;
  padding: 0;
  min-height: 100%;
  flex: 1;
}

.nav-tab.active {
  color: var(--primary);
  font-weight: 700;
}

/* --- Mobile Responsive Section Switching --- */
@media (max-width: 768px) {
  .mobile-nav {
    display: flex;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  /* Hide sections by default on mobile */
  .rankings-section,
  .analytics-section,
  #rostersSection {
    display: none;
    width: 100%;
  }

  /* Active section class toggled by mobile nav */
  .rankings-section.mobile-active,
  .analytics-section.mobile-active,
  #rostersSection.mobile-active {
    display: block !important;
  }

  .player-row {
    padding: 12px 10px;
  }

  .draft-btn {
    min-height: var(--min-touch-target);
    padding: 0 18px;
    font-size: 0.9rem;
  }
}
