/* ============================================================
   Squash Newman — Hoja de estilos principal
   Colores: Pantone 7421 (#5C2033), Pantone 130 (#F0AA00), Blanco
   Estética: Cloudflare-inspired — limpio, moderno, sin adornos
   ============================================================ */

:root {
  --claret:      #5C2033;  /* Pantone 7421 */
  --claret-dark: #3e1624;
  --claret-light:#7a2d46;
  --gold:        #F0AA00;  /* Pantone 130 */
  --gold-dark:   #c68f00;
  --gold-light:  #ffe066;
  --white:       #ffffff;
  --bg:          #f7f8fa;
  --bg2:         #eef0f4;
  --border:      #e2e5eb;
  --text:        #1a1d23;
  --text2:       #4a5162;
  --text3:       #8891a5;
  --radius:      8px;
  --radius-lg:   14px;
  --shadow:      0 1px 3px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.06);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.12);
  --sidebar-w:   240px;
  --transition:  0.18s ease;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
}
a { color: var(--claret); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea {
  font-family: inherit;
  font-size: 0.95rem;
}

/* ---- Layout ---- */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w); height: 100vh;
  background: var(--claret);
  display: flex; flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
}

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  overflow-y: auto;
}

.page-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 2rem 4rem;
}

/* ---- Sidebar ---- */
.sidebar-header {
  display: flex; align-items: center; gap: 12px;
  padding: 22px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}
.logo { width: 40px; height: 40px; border-radius: 0; object-fit: contain; }
.logo-text {
  color: var(--white); font-weight: 700; font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }

.nav-section {
  padding: 8px 14px 4px;
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(255,255,255,0.4);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.75);
  font-size: 0.9rem;
  font-weight: 450;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all var(--transition);
  user-select: none;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: var(--white); }
.nav-item.active {
  background: rgba(255,255,255,0.12);
  color: var(--white);
  border-left-color: var(--gold);
  font-weight: 600;
}
.nav-item .nav-icon { font-size: 1.1rem; width: 20px; text-align: center; }
.nav-arrow { margin-left: auto; font-size: 0.7rem; opacity: 0.6; }
.nav-submenu { display: none; }
.nav-submenu.open { display: block; }
.nav-subitem {
  padding: 8px 20px 8px 36px;
  color: rgba(255,255,255,0.6);
  font-size: 0.85rem;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all var(--transition);
  user-select: none;
}
.nav-subitem:hover { background: rgba(255,255,255,0.06); color: var(--white); }
.nav-subitem.active { color: var(--white); border-left-color: var(--gold); font-weight: 600; }

/* ---- Interclub team badges ---- */
.badge-ic-bordo  { background: #5c1a25; color: #fff; }
.badge-ic-blanco { background: #e8e8e8; color: #333; }
.badge-ic-verde  { background: #166534; color: #fff; }
.badge-ic-amarillo { background: #92400e; color: #fff; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.12);
  display: flex; flex-direction: column; gap: 10px;
}
.user-badge {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.65);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-badge strong { color: var(--white); display: block; font-size: 0.9rem; }

.btn-logout {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.8);
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 0.82rem;
  transition: all var(--transition);
  width: 100%;
}
.btn-logout:hover { background: rgba(255,255,255,0.18); color: var(--white); }

/* ---- Mobile header ---- */
.mobile-header {
  display: none;
  position: fixed; top: 0; left: 0; right: 0;
  height: 56px;
  background: var(--claret);
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  z-index: 150;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.mobile-logo { width: 32px; height: 32px; border-radius: 0; object-fit: contain; flex-shrink: 0; }
.mobile-title { color: var(--white); font-weight: 700; font-size: 1rem; }
.btn-hamburger {
  background: none; border: none; display: flex; flex-direction: column;
  gap: 5px; padding: 4px; cursor: pointer;
}
.btn-hamburger span {
  display: block; width: 22px; height: 2px;
  background: var(--white); border-radius: 2px;
  transition: all var(--transition);
}
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.4); z-index: 90;
}

/* ---- Cards ---- */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card-sm { padding: 16px; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.card-title { font-size: 1.05rem; font-weight: 700; color: var(--text); }
.card-subtitle { font-size: 0.85rem; color: var(--text3); margin-top: 2px; }

/* ---- Page headers ---- */
.page-header { margin-bottom: 28px; }
.page-header h1 {
  font-size: 1.6rem; font-weight: 800;
  letter-spacing: -0.03em; color: var(--text);
}
.page-header p { color: var(--text2); margin-top: 4px; font-size: 0.95rem; }

/* ---- Badges & Pills ---- */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.badge-gold    { background: #FFF3CC; color: #9a6e00; }
.badge-claret  { background: #f5e8eb; color: var(--claret); }
.badge-green   { background: #e6f7f0; color: #0a7040; }
.badge-gray    { background: var(--bg2); color: var(--text3); }
.badge-blue    { background: #e8f0ff; color: #2a5be8; }
.badge-red     { background: #ffe8e8; color: #c0180d; }

/* Cat badges */
.cat-1 { background: #5C2033; color: #fff; }
.cat-2 { background: #8a2d4a; color: #fff; }
.cat-3 { background: #F0AA00; color: #fff; }
.cat-4 { background: var(--bg2); color: var(--text2); }
.cat-5 { background: var(--border); color: var(--text3); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 9px 18px;
  border-radius: var(--radius); border: none;
  font-size: 0.9rem; font-weight: 600;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary { background: var(--claret); color: var(--white); }
.btn-primary:hover { background: var(--claret-dark); }
.btn-gold { background: var(--gold); color: var(--claret-dark); }
.btn-gold:hover { background: var(--gold-dark); color: var(--white); }
.btn-outline {
  background: none; border: 1.5px solid var(--border); color: var(--text2);
}
.btn-outline:hover { border-color: var(--claret); color: var(--claret); }
.btn-ghost { background: none; color: var(--text2); }
.btn-ghost:hover { background: var(--bg2); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn-lg { padding: 12px 28px; font-size: 1rem; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn[disabled], .btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- Forms ---- */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block; margin-bottom: 6px;
  font-size: 0.875rem; font-weight: 600; color: var(--text2);
}
.form-control {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem; color: var(--text);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--claret);
  box-shadow: 0 0 0 3px rgba(92,32,51,0.1);
}
.form-control.error { border-color: #dc2626; }
.form-hint { font-size: 0.8rem; color: var(--text3); margin-top: 4px; }
.form-error { font-size: 0.82rem; color: #dc2626; margin-top: 5px; }

.form-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px;
}

.form-title {
  font-size: 1.1rem; font-weight: 700;
  margin-bottom: 20px; color: var(--text);
}

/* ---- Score inputs ---- */
.score-grid {
  display: grid;
  grid-template-columns: 1fr 40px 1fr;
  gap: 8px; align-items: center;
  margin-bottom: 10px;
}
.score-grid .set-label {
  grid-column: 1 / -1;
  font-size: 0.78rem; font-weight: 600;
  color: var(--text3); text-transform: uppercase;
  letter-spacing: 0.06em;
}
.score-grid .vs { text-align: center; color: var(--text3); font-weight: 600; }
.score-input {
  width: 100%; padding: 8px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  text-align: center; font-size: 1rem; font-weight: 600;
  transition: border-color var(--transition);
}
.score-input:focus { border-color: var(--claret); outline: none; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table {
  width: 100%; border-collapse: collapse;
  font-size: 0.9rem;
}
thead th {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 2px solid var(--border);
  font-size: 0.78rem; font-weight: 700;
  color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.05em;
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg); }
tbody td { padding: 12px 14px; vertical-align: middle; }
.rank-number {
  font-weight: 800; font-size: 1rem;
  color: var(--text3);
}
.rank-1 .rank-number { color: var(--gold-dark); }
.rank-2 .rank-number { color: #a0a0a0; }
.rank-3 .rank-number { color: #b07a30; }
.player-name { font-weight: 600; }
.player-name small { display: block; font-size: 0.78rem; font-weight: 400; color: var(--text3); }
.elo-score {
  font-variant-numeric: tabular-nums;
  font-weight: 700; color: var(--claret);
}

/* ---- Tabs ---- */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 24px; flex-wrap: wrap; }
.tab-btn {
  padding: 10px 20px; background: none; border: none; border-bottom: 2px solid transparent;
  margin-bottom: -2px; font-size: 0.9rem; font-weight: 500;
  color: var(--text3); cursor: pointer;
  transition: all var(--transition);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--claret); border-bottom-color: var(--claret); font-weight: 700; }

/* ---- Alerts ---- */
.alert {
  padding: 14px 18px; border-radius: var(--radius);
  font-size: 0.9rem; border-left: 4px solid;
  margin-bottom: 16px;
}
.alert-info   { background: #e8f0ff; border-color: #2a5be8; color: #1a3ab8; }
.alert-success{ background: #e6f7f0; border-color: #0a7040; color: #065530; }
.alert-warn   { background: #FFF8E6; border-color: var(--gold); color: #7a5500; }
.alert-error  { background: #ffe8e8; border-color: #dc2626; color: #8b1010; }

/* ---- Black Week banner ---- */
.bw-banner {
  background: linear-gradient(135deg, var(--claret-dark), var(--claret));
  color: var(--white); border-radius: var(--radius-lg);
  padding: 20px 24px; margin-bottom: 24px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  border: 2px solid var(--gold);
  box-shadow: 0 4px 20px rgba(92,32,51,0.3);
}
.bw-banner .bw-icon { font-size: 2rem; }
.bw-banner .bw-title { font-size: 1.2rem; font-weight: 800; color: var(--gold); }
.bw-banner .bw-sub   { font-size: 0.88rem; opacity: 0.8; }
.bw-badge {
  background: var(--gold); color: var(--claret-dark);
  padding: 4px 14px; border-radius: 999px;
  font-weight: 800; font-size: 0.82rem;
}

/* ---- Stats grid ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stats-grid-compact { grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 0; }
.stat-card {
  background: var(--white); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 18px 16px;
  text-align: center;
}
.stat-card-sm { padding: 12px 10px; }
.stat-card-sm .stat-value { font-size: 1.5rem; }
.stat-card-sm .stat-label { font-size: 0.72rem; }
.stat-value { font-size: 2rem; font-weight: 800; color: var(--claret); line-height: 1; }
.stat-label { font-size: 0.78rem; color: var(--text3); margin-top: 4px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }

/* ---- Profile ---- */
.profile-header {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  margin-bottom: 24px;
}
.avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--claret); color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 800; flex-shrink: 0;
}
.profile-info h2 { font-size: 1.4rem; font-weight: 800; }
.profile-info p  { color: var(--text2); font-size: 0.9rem; }

/* ---- Ranking change arrow ---- */
.rank-up   { color: #0a7040; font-weight: 700; }
.rank-down { color: #dc2626; font-weight: 700; }
.rank-same { color: var(--text3); }

/* ---- Login page ---- */
.auth-wrapper {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 20px;
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--white); border-radius: var(--radius-lg);
  border: 1px solid var(--border); padding: 40px;
  box-shadow: var(--shadow-lg);
}
.auth-logo {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  margin-bottom: 32px;
}
.auth-logo img { width: 64px; border-radius: 12px; }
.auth-logo h1 { font-size: 1.4rem; font-weight: 800; color: var(--claret); }
.auth-logo p  { font-size: 0.85rem; color: var(--text3); }
.auth-toggle { text-align: center; margin-top: 20px; font-size: 0.88rem; color: var(--text2); }
.auth-toggle a { color: var(--claret); font-weight: 600; cursor: pointer; }

/* ---- Match result form ---- */
.players-vs {
  display: grid; grid-template-columns: 1fr auto 1fr;
  gap: 12px; align-items: center; margin-bottom: 24px;
}
.vs-label {
  background: var(--bg2); border-radius: 50%;
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.82rem; color: var(--text3);
}

/* ---- Tournament table ---- */
.group-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 0; margin-bottom: 12px;
  border-bottom: 2px solid var(--border);
}
.group-name { font-size: 1rem; font-weight: 700; }
.pos-medal { font-size: 1.1rem; }

/* ---- Loading ---- */
.loading-spinner {
  display: flex; align-items: center; justify-content: center;
  min-height: 60vh;
}
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--claret);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center; padding: 60px 20px; color: var(--text3);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.95rem; }

/* ---- Toast notifications ---- */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 9999;
}
.toast {
  background: var(--text); color: var(--white);
  padding: 12px 20px; border-radius: var(--radius);
  font-size: 0.88rem; font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.25s ease;
  max-width: 320px;
}
.toast.success { background: #065530; }
.toast.error   { background: #8b1010; }
.toast.warn    { background: #7a5500; }
@keyframes slideIn { from { transform: translateX(100px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 300;
  }
  .sidebar.open { transform: none; }
  .sidebar-overlay { z-index: 250; }
  .sidebar-overlay.show { display: block; }
  .mobile-header { display: flex; align-items: center; gap: 10px; }
  .main-content { margin-left: 0; padding-top: 80px; }
  .page-container { padding: 1.25rem 1rem 3rem; }
  .page-header h1 { font-size: 1.3rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .auth-card { padding: 28px 20px; }
  .form-row { grid-template-columns: 1fr; }
  .players-vs { grid-template-columns: 1fr 32px 1fr; }
}

/* ---- Misc ---- */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.mt-auto  { margin-top: auto; }
.d-flex   { display: flex; }
.gap-8    { gap: 8px; }
.gap-12   { gap: 12px; }
.align-center { align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.font-bold { font-weight: 700; }
.text-sm { font-size: 0.85rem; }
.text-muted { color: var(--text3); }
.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

/* ---- Admin section highlight ---- */
.admin-section { border-left: 3px solid var(--gold); padding-left: 16px; }

/* ---- Category legend ---- */
.cat-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.cat-legend-item {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.8rem; color: var(--text2);
}
.cat-dot {
  width: 10px; height: 10px; border-radius: 50%;
}

/* ---- BW challenge card ---- */
.challenge-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 18px; background: var(--white);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 10px;
}
.challenge-card.pending { border-left: 4px solid var(--gold); }
.challenge-card.accepted{ border-left: 4px solid #0a7040; }
.challenge-card.rejected { border-left: 4px solid #dc2626; }

/* ---- WhatsApp button ---- */
.btn-wa {
  display: inline-flex; align-items: center; gap: 6px;
  background: #25D366; color: #fff;
  border: none; border-radius: var(--radius);
  padding: 6px 12px; font-size: 0.82rem; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background 0.15s;
}
.btn-wa:hover { background: #1ebe5d; }
.btn-wa svg  { flex-shrink: 0; }

/* ---- Nav divider ---- */
.nav-divider {
  border: none; border-top: 1px solid rgba(255,255,255,0.15);
  margin: 8px 12px;
}

/* ---- BW status dot ---- */
.bw-dot {
  display: inline-block;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--gold); margin-left: 6px;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.3; }
}

/* ---- Interclub table ---- */
.interclub-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.interclub-table th { background: var(--claret); color: #fff; padding: 8px 10px; text-align: left; }
.interclub-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); }
.interclub-table tr:last-child td { border-bottom: none; }
.interclub-table tr:hover td { background: var(--bg2); }

/* ---- Head-to-head badge ---- */
.h2h-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 20px; padding: 2px 10px; font-size: 0.8rem;
  color: var(--text2); margin-bottom: 12px;
}
