/* ============================================================
   PADELHUB - STYLES
   ============================================================ */

:root {
  --primary: #1a6b3c;
  --primary-dark: #134f2d;
  --primary-light: #e8f5ee;
  --accent: #f0a500;
  --accent-dark: #c98900;
  --danger: #d93025;
  --danger-light: #fce8e6;
  --text: #1c1c1e;
  --text-muted: #6e6e73;
  --border: #d1d1d6;
  --bg: #f5f5f7;
  --card-bg: #ffffff;
  --header-bg: #0d3d22;
  --gold: #ffd700;
  --silver: #c0c0c0;
  --bronze: #cd7f32;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.14);
  --transition: 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- HEADER ---- */
header {
  background: var(--header-bg);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #fff;
  flex-shrink: 0;
}
.logo-icon { font-size: 1.6rem; }
.logo-text {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}
#main-nav {
  display: flex;
  gap: 4px;
  flex: 1;
}
.nav-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.75);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  transition: var(--transition);
}
.nav-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-btn.active { background: rgba(255,255,255,0.15); color: #fff; }
.admin-toggle-btn {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: var(--transition);
  flex-shrink: 0;
}
.admin-toggle-btn:hover { background: var(--accent-dark); }
.admin-toggle-btn.logged-in { background: var(--danger); color: #fff; }

/* ---- MAIN ---- */
main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  padding: 32px 24px;
}

/* ---- VIEWS ---- */
.view { display: none; }
.view.active { display: block; }

/* ---- HERO ---- */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 56px 48px;
  margin-bottom: 40px;
  text-align: center;
}
.hero h1 { font-size: 2.4rem; font-weight: 800; margin-bottom: 12px; }
.hero p { font-size: 1.1rem; opacity: 0.9; margin-bottom: 28px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---- TOURNAMENT CARDS ---- */
.tournaments-preview h2 { font-size: 1.4rem; margin-bottom: 16px; }
.tournament-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.tournament-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
  transition: var(--transition);
}
.tournament-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.tournament-card h3 { font-size: 1.1rem; margin-bottom: 6px; }
.tournament-card .meta { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 10px; }
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.status-registration { background: #e3f2fd; color: #1565c0; }
.status-active { background: #e8f5e9; color: #2e7d32; }
.status-completed { background: #f3e5f5; color: #6a1b9a; }

/* ---- VIEW HEADER ---- */
.view-header {
  margin-bottom: 28px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.view-header h1 { font-size: 1.8rem; font-weight: 700; flex: 1; }
.view-header p { color: var(--text-muted); width: 100%; margin-top: -8px; }

/* ---- TABS ---- */
.tab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.tab-btn {
  background: transparent;
  border: none;
  padding: 10px 18px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.tab-btn:hover { color: var(--primary); background: var(--primary-light); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ---- CARDS ---- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card h2 { font-size: 1.2rem; margin-bottom: 18px; color: var(--text); }
.card h3 { font-size: 1rem; margin-bottom: 10px; color: var(--text); }
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 768px) {
  .two-col { grid-template-columns: 1fr; }
}

/* ---- FORMS ---- */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  color: var(--text);
  background: #fff;
  transition: var(--transition);
  outline: none;
}
.form-group input:focus,
.form-group select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,107,60,0.12); }
.form-group input[readonly] { background: var(--bg); color: var(--text-muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.form-feedback {
  margin-top: 10px;
  font-size: 0.9rem;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  display: none;
}
.form-feedback.success { display: block; background: var(--primary-light); color: var(--primary-dark); }
.form-feedback.error { display: block; background: var(--danger-light); color: var(--danger); }
.hint { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 12px; }
hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1.5px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }
.btn-accent { background: var(--accent); color: #000; }
.btn-accent:hover:not(:disabled) { background: var(--accent-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b71c1c; }
.btn-outline { background: transparent; color: #fff; border: 2px solid rgba(255,255,255,0.6); }
.btn-outline:hover { background: rgba(255,255,255,0.1); border-color: #fff; }
.btn-sm { padding: 6px 14px; font-size: 0.85rem; }
.btn-lg { padding: 14px 28px; font-size: 1.05rem; }
.btn-icon { padding: 6px 10px; font-size: 1rem; }

/* ---- TABLES ---- */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
thead th {
  background: var(--primary);
  color: #fff;
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
thead th:first-child { border-radius: var(--radius-sm) 0 0 0; }
thead th:last-child { border-radius: 0 var(--radius-sm) 0 0; }
tbody tr { border-bottom: 1px solid var(--border); transition: var(--transition); }
tbody tr:hover { background: var(--primary-light); }
tbody td { padding: 10px 14px; vertical-align: middle; }
tbody tr:last-child { border-bottom: none; }

/* Standings highlights */
.rank-1 { background: linear-gradient(90deg, rgba(255,215,0,0.15) 0%, transparent 100%); }
.rank-2 { background: linear-gradient(90deg, rgba(192,192,192,0.15) 0%, transparent 100%); }
.rank-3 { background: linear-gradient(90deg, rgba(205,127,50,0.15) 0%, transparent 100%); }
.rank-1:hover { background: linear-gradient(90deg, rgba(255,215,0,0.25) 0%, transparent 100%); }
.rank-2:hover { background: linear-gradient(90deg, rgba(192,192,192,0.25) 0%, transparent 100%); }
.rank-3:hover { background: linear-gradient(90deg, rgba(205,127,50,0.25) 0%, transparent 100%); }

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.85rem;
}
.rank-badge-1 { background: var(--gold); color: #000; }
.rank-badge-2 { background: var(--silver); color: #000; }
.rank-badge-3 { background: var(--bronze); color: #fff; }
.rank-badge-other { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

/* ---- FIXTURES ---- */
.round-header {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 16px 0 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.fixture-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.fixture-item:last-child { border-bottom: none; }
.fixture-teams {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
}
.fixture-team { font-weight: 600; font-size: 0.95rem; }
.fixture-vs {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}
.fixture-score {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.set-score {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
}
.set-score.tiebreak { background: #fff3e0; border-color: var(--accent); }
.fixture-status {
  font-size: 0.8rem;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
}
.fixture-status.pending { background: #f5f5f5; color: var(--text-muted); }
.fixture-status.played { background: var(--primary-light); color: var(--primary-dark); }

/* ---- MODALS ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease;
}
.modal-wide { max-width: 640px; }
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(-10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal h2 { font-size: 1.2rem; margin-bottom: 8px; }
.modal-sub { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 16px; }
.modal input { width: 100%; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 0.95rem; margin-bottom: 8px; outline: none; }
.modal input:focus { border-color: var(--primary); }
.modal-error { color: var(--danger); font-size: 0.88rem; min-height: 20px; margin-bottom: 8px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* Score entry modal */
.score-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 20px;
}
.score-entry-team { font-weight: 700; font-size: 1rem; }
.score-entry-vs { color: var(--text-muted); font-size: 0.85rem; }
.sets-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.set-entry { text-align: center; }
.set-entry label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.set-inputs { display: flex; align-items: center; gap: 6px; justify-content: center; }
.set-inputs input {
  width: 52px;
  padding: 8px;
  text-align: center;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  outline: none;
}
.set-inputs input:focus { border-color: var(--primary); }
.set-inputs .sep { font-weight: 700; color: var(--text-muted); }
.tiebreak-note {
  font-size: 0.82rem;
  color: var(--text-muted);
  background: #fff3e0;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 12px;
}
.score-preview {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.9rem;
  color: var(--text-muted);
  min-height: 40px;
}

/* ---- ADMIN LISTS ---- */
.list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.list-item:last-child { border-bottom: none; }
.list-item-info { flex: 1; min-width: 0; }
.list-item-title { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item-sub { font-size: 0.82rem; color: var(--text-muted); margin-top: 2px; }
.list-item-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Application items */
.application-item {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}
.application-item .app-team { font-weight: 700; font-size: 1rem; margin-bottom: 4px; }
.application-item .app-meta { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 10px; }
.application-item .app-actions { display: flex; gap: 8px; }
.app-status-pending { border-left: 4px solid var(--accent); }
.app-status-approved { border-left: 4px solid var(--primary); }
.app-status-rejected { border-left: 4px solid var(--danger); }

/* ---- EMPTY STATES ---- */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.95rem; }

/* ---- FOOTER ---- */
footer {
  background: var(--header-bg);
  color: rgba(255,255,255,0.5);
  text-align: center;
  padding: 20px;
  font-size: 0.85rem;
  margin-top: auto;
}

/* ---- REGISTRATION CLOSED NOTICE ---- */
.registration-closed-notice {
  background: #fff3e0;
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  color: #c84b00;
  font-weight: 600;
  font-size: 0.95rem;
  margin-top: 8px;
}

/* ---- CUSTOM RULES SUB-OPTIONS ---- */
.custom-sub-option {
  background: #fffbf0;
  border: 1px dashed var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
}

/* ---- KNOCKOUT BRACKET ---- */
.knockout-section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 28px 0 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--primary);
}
.knockout-section-header h3 {
  font-size: 1.1rem;
  color: var(--primary-dark);
  font-weight: 700;
  margin: 0;
}
.ko-round-label {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #fff;
  background: var(--primary);
  padding: 3px 10px;
  border-radius: 20px;
}
.ko-round-label.final      { background: var(--gold); color: #000; }
.ko-round-label.third-place { background: var(--bronze); color: #fff; }
.ko-round-label.semifinal  { background: var(--primary); }
.ko-round-label.quarterfinal { background: #5c7a6a; }
.ko-match.match-third { border-color: var(--bronze); background: #fdf5ef; }
.ko-match {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  background: #fff;
  flex-wrap: wrap;
}
.ko-match.match-played { border-color: var(--primary); background: var(--primary-light); }
.ko-match.match-final  { border-color: var(--gold); background: #fffdf0; }
.ko-slot {
  flex: 1;
  min-width: 120px;
  font-weight: 600;
  font-size: 0.95rem;
}
.ko-slot.tbd { color: var(--text-muted); font-style: italic; font-weight: 400; }
.ko-slot.winner { color: var(--primary-dark); }
.ko-vs { color: var(--text-muted); font-size: 0.8rem; font-weight: 700; flex-shrink: 0; }
.ko-score { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.ko-seed {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ---- RULE TYPE TOGGLE ---- */
.rule-type-toggle {
  display: flex;
  gap: 0;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.rule-type-btn {
  flex: 1;
  padding: 9px 14px;
  border: none;
  background: #fff;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition);
  border-right: 1.5px solid var(--border);
}
.rule-type-btn:last-child { border-right: none; }
.rule-type-btn:hover { background: var(--bg); color: var(--text); }
.rule-type-btn.active { background: var(--primary); color: #fff; font-weight: 600; }

/* ---- STANDARD RULES SUMMARY ---- */
.rules-summary {
  background: var(--primary-light);
  border: 1px solid rgba(26,107,60,0.2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 4px;
}
.rules-summary-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.rule-chip {
  background: #fff;
  border: 1px solid rgba(26,107,60,0.25);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--primary-dark);
  white-space: nowrap;
}

/* ---- CUSTOM RULES PANEL ---- */
.custom-rules-panel {
  background: #fffbf0;
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 4px;
}
.rules-preview {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 8px;
  min-height: 36px;
  line-height: 1.6;
}

/* Tournament card rules badge */
.rules-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: 6px;
  vertical-align: middle;
}
.rules-badge-standard { background: var(--primary-light); color: var(--primary-dark); }
.rules-badge-custom { background: #fff3e0; color: #e65100; border: 1px solid var(--accent); }

/* ---- UTILITIES ---- */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.positive { color: var(--primary); font-weight: 600; }
.negative { color: var(--danger); font-weight: 600; }

/* ---- RESPONSIVE ---- */
@media (max-width: 600px) {
  .hero { padding: 36px 24px; }
  .hero h1 { font-size: 1.8rem; }
  main { padding: 20px 16px; }
  .form-row { grid-template-columns: 1fr; }
  .sets-grid { grid-template-columns: 1fr; }
  .header-inner { padding: 0 16px; gap: 12px; }
  .logo-text { display: none; }
}
