/* ============================================================
   FILE: 08-custom.css  –  Layout & component overrides
   Fixes the visual issues from the screenshot
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

:root {
  --font-sans: 'Space Grotesk', 'Segoe UI', sans-serif;
  --font-mono: 'DM Mono', monospace;

  /* Refined palette */
  --bg-base:     #080e1a;
  --bg-surface:  #101828;
  --bg-elevated: #172033;
  --bg-card:     #1a2540;
  --border:      rgba(255,255,255,0.07);
  --border-active: rgba(99,179,237,0.4);

  --primary:       #3b82f6;
  --primary-light: #60a5fa;
  --secondary:     #10b981;
  --warning:       #f59e0b;
  --danger:        #ef4444;

  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #4b5563;
  --text-accent:    #63b3ed;

  --gold:   #fbbf24;
  --silver: #9ca3af;
  --bronze: #b45309;
}

/* ── Reset noisy default margin ─────────────────────────────── */
* { box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
}

/* ── App shell: single-column flow, no fixed sidebar ────────── */
.app-shell {
  display: block;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 60px;
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────────────── */
header {
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 20px;
}

header h1 {
  font-size: clamp(1.3rem, 3vw, 1.8rem);
  font-weight: 700;
  background: linear-gradient(135deg, #63b3ed, #68d391);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
  margin-bottom: 6px;
}

header p {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* ── Mode tabs ──────────────────────────────────────────────── */
.mode-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.mode-tab {
  padding: 8px 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-tab:hover { color: var(--text-primary); border-color: var(--border-active); }
.mode-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ── Setup panel ────────────────────────────────────────────── */
#setup-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  align-items: end;
}

.field-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-row label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.field-row select,
.field-row input[type="file"],
.field-row input[type="text"],
.field-row input[type="number"] {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  padding: 9px 12px;
  width: 100%;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

.field-row select {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  padding-right: 34px;
}

.field-row select:focus,
.field-row input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

.radio-group {
  flex-direction: row;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: none;
  font-size: 0.875rem;
  cursor: pointer;
}

.analyze-row {
  grid-column: 1 / -1;
}

#analyze-button {
  width: 100%;
  padding: 12px 24px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
  letter-spacing: 0.3px;
}

#analyze-button:hover { opacity: 0.9; transform: translateY(-1px); }
#analyze-button:active { transform: translateY(0); }
#analyze-button:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.hidden { display: none !important; }

/* ── Output panel / dashboard grid ─────────────────────────── */
#output-panel { display: block; }

#dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

@media (max-width: 750px) {
  #dashboard-grid { grid-template-columns: 1fr; }
  #setup-panel { grid-template-columns: 1fr; }
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}

.card-title, .card h3 {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

/* ── Points table ────────────────────────────────────────────── */
.pts-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  overflow: hidden;
}

.pts-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
  margin: 0;
}

.pts-search-input {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  padding: 6px 12px;
  width: 140px;
  transition: border-color 0.15s;
}

.pts-search-input:focus { outline: none; border-color: var(--primary); }

.table-scroll { overflow-x: auto; }

.pts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.pts-table thead tr {
  border-bottom: 1px solid var(--border);
}

.pts-table th {
  padding: 8px 10px;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  white-space: nowrap;
}

.pts-table td {
  padding: 10px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--text-secondary);
  white-space: nowrap;
}

.pts-table tbody tr:last-child td { border-bottom: none; }

.pts-table tbody tr:hover td {
  background: rgba(255,255,255,0.03);
  color: var(--text-primary);
}

/* Qualification zone highlight */
.pts-table tbody tr.qualify-row td { color: var(--text-primary); }
.pts-table tbody tr.qualify-row { border-left: 2px solid var(--secondary); }

/* Qualifying teams */
.pts-table tbody tr.qualifying {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.08), transparent);
  border-left: 4px solid var(--secondary);
}

.pts-table tbody tr.qualifying:hover {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.15), transparent);
}

/* Eliminated teams */
.pts-table tbody tr.eliminated {
  opacity: 0.6;
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.05), transparent);
  border-left: 4px solid var(--danger);
}

.pts-table tbody tr.eliminated:hover {
  opacity: 0.8;
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.12), transparent);
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

tr.rank-gold   .rank-badge { background: rgba(251,191,36,0.15); color: var(--gold); }
tr.rank-silver .rank-badge { background: rgba(156,163,175,0.15); color: var(--silver); }
tr.rank-bronze .rank-badge { background: rgba(180,83,9,0.15); color: var(--bronze); }

.team-cell { font-weight: 600; }
.team-name { color: var(--text-primary); }

.pts-col { font-weight: 700; }
.pts-positive { color: var(--primary-light) !important; }
.nrr-col { font-family: var(--font-mono); font-size: 0.8rem; }
.wins-col { color: var(--secondary); font-weight: 600; }

.pts-updated {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 12px;
  text-align: right;
}

/* ── Fixtures panel ──────────────────────────────────────────── */
.fixtures-card {
  margin-bottom: 16px;
}

.fixtures-card:last-child { margin-bottom: 0; }

.fixture-title {
  font-size: 0.9rem;
  color: var(--text-primary);
  margin-bottom: 12px;
  font-weight: 500;
}

.fixture-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fixture-controls select,
.fixture-controls input {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  padding: 8px 12px;
  width: 100%;
  transition: border-color 0.15s;
}

.fixture-controls select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  padding-right: 34px;
}

.fixture-controls select:focus,
.fixture-controls input:focus {
  outline: none;
  border-color: var(--primary);
}

.score-inputs {
  display: grid;
  grid-template-columns: 1fr 80px 1fr 80px;
  gap: 8px;
}

@media (max-width: 500px) { .score-inputs { grid-template-columns: 1fr 1fr; } }

.btn, .btn-primary, .btn-warning, .btn-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn { background: var(--bg-elevated); color: var(--text-primary); border: 1px solid var(--border); }
.btn:hover { border-color: var(--border-active); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); transform: translateY(-1px); }

.btn-warning { background: var(--warning); color: #000; }
.btn-warning:hover { opacity: 0.9; }

.btn-sm { padding: 4px 10px; font-size: 0.75rem; }
.btn-secondary { background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-success { background: var(--secondary); color: #fff; }

.submit-match {
  align-self: flex-start;
  padding: 10px 20px;
  font-size: 0.875rem;
}

/* Read-only fixture notice */
.readonly-fixture { opacity: 0.9; }

.fixture-notice {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.result-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.result-done { background: rgba(100,116,139,0.2); color: var(--text-secondary); }
.result-win  { background: rgba(16,185,129,0.15); color: var(--secondary); }
.result-tie  { background: rgba(245,158,11,0.15); color: var(--warning); }

.readonly-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Completed list */
.completed-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.completed-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.completed-list li:last-child { border-bottom: none; }

.match-info {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.match-info strong { color: var(--text-primary); }

/* ── Result tabs ─────────────────────────────────────────────── */
#result-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.tab-button {
  padding: 7px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.tab-button:hover { color: var(--text-primary); border-color: var(--border-active); }
.tab-button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Result blocks ───────────────────────────────────────────── */
.result-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
}

.result-block h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text-primary);
}

.result-block p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  line-height: 1.5;
}

.result-block pre {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  white-space: pre-wrap;
  line-height: 1.6;
  margin-top: 12px;
}

.result-block ul {
  margin: 12px 0;
  padding-left: 20px;
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.8;
}

.error-block {
  border-color: rgba(239,68,68,0.3);
  background: rgba(239,68,68,0.05);
  color: var(--danger);
}

.small-label { font-size: 0.8rem; color: var(--text-muted); }

.muted { color: var(--text-muted); font-size: 0.875rem; }

/* ── Page error banner ───────────────────────────────────────── */
.page-error {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: 10px;
  color: var(--danger);
  padding: 14px 18px;
  font-size: 0.875rem;
  margin-bottom: 20px;
}

/* ── Sidebar toggle (mobile only) ───────────────────────────── */
.sidebar-toggle { display: none; }
.sidebar-overlay { display: none; }

/* ── Builder panel ───────────────────────────────────────────── */
#builder-panel .card {
  margin-bottom: 16px;
}

#builder-panel .card h2, #builder-panel .card h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.input-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-group input,
.input-group select {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  padding: 9px 12px;
  width: 100%;
}

.team-input {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  padding: 8px 12px;
  width: 100%;
  margin-bottom: 8px;
}

/* Reset Results button */
#reset-results-button {
  width: 100%;
  margin-top: 8px;
  padding: 10px 24px;
  background: transparent;
  color: var(--text-muted, #8899aa);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--border, #2a3a50);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

#reset-results-button:hover {
  background: rgba(255, 80, 80, 0.08);
  border-color: #ff5050;
  color: #ff6060;
}
