/* =====================================================================
   FUTMONDO WEBAPP — Design System
   Mobile-first, dark mode, football-themed
   ===================================================================== */

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

/* -----------------------------------------------------------------------
   1. DESIGN TOKENS
----------------------------------------------------------------------- */
:root {
  /* Brand palette */
  --color-brand:       #22c55e;   /* football green */
  --color-brand-dark:  #16a34a;
  --color-brand-glow:  rgba(34, 197, 94, 0.25);
  --color-gold:        #f59e0b;   /* rankings / 1st place */
  --color-silver:      #94a3b8;
  --color-bronze:      #cd7c50;
  --color-danger:      #ef4444;
  --color-warning:     #f59e0b;
  --color-info:        #3b82f6;

  /* Dark surface palette */
  --surface-base:      #0f172a;   /* page background */
  --surface-card:      #1e293b;   /* cards */
  --surface-card-alt:  #263348;   /* elevated cards */
  --surface-border:    #334155;
  --surface-input:     #1e293b;

  /* Text */
  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;
  --text-inverse:   #0f172a;

  /* Layout */
  --navbar-height:       60px;
  --bottom-nav-height:   64px;
  --page-padding:        16px;
  --card-radius:         16px;
  --btn-radius:          12px;

  /* Shadows */
  --shadow-card:   0 4px 24px rgba(0,0,0,0.4);
  --shadow-glow:   0 0 20px var(--color-brand-glow);

  /* Transitions */
  --ease-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --dur-fast: 150ms;
  --dur-base: 250ms;

  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;
  --text-3xl:  1.875rem;
}

/* -----------------------------------------------------------------------
   2. RESET & BASE
----------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--surface-base);
  color: var(--text-primary);
  min-height: 100dvh;
  /* Reserve space for bottom nav on mobile */
  padding-bottom: var(--bottom-nav-height);
  overflow-x: hidden;
}

a { color: var(--color-brand); text-decoration: none; }
a:hover { color: var(--color-brand-dark); }

img { max-width: 100%; display: block; }

/* -----------------------------------------------------------------------
   3. TOP NAVBAR
----------------------------------------------------------------------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--navbar-height);
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--surface-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--page-padding);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-lg);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.nav-brand a {
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-brand .brand-icon {
  font-size: 22px;
  filter: drop-shadow(0 0 8px var(--color-brand));
}

/* Season selector */
.nav-temporada select {
  background: var(--surface-card);
  color: var(--text-secondary);
  border: 1px solid var(--surface-border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  cursor: pointer;
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-out);
}
.nav-temporada select:focus {
  border-color: var(--color-brand);
}

/* Desktop nav links — hidden on mobile */
.nav-links {
  display: none;
  list-style: none;
  gap: 4px;
  align-items: center;
}
.nav-links a {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 8px;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.nav-links a:hover,
.nav-links a.active {
  background: var(--surface-card);
  color: var(--text-primary);
}

@media (min-width: 768px) {
  .nav-links { display: flex; }
  body { padding-bottom: 0; }
  .bottom-nav { display: none !important; }
}

/* -----------------------------------------------------------------------
   4. BOTTOM NAVIGATION (mobile app feel)
----------------------------------------------------------------------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--bottom-nav-height);
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--surface-border);
  display: flex;
  align-items: stretch;
  /* iOS safe area */
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 500;
  transition: color var(--dur-fast) var(--ease-out);
  position: relative;
}

.bottom-nav a .nav-icon {
  font-size: 20px;
  transition: transform var(--dur-fast) var(--ease-out);
}

.bottom-nav a.active {
  color: var(--color-brand);
}

.bottom-nav a.active .nav-icon {
  filter: drop-shadow(0 0 6px var(--color-brand));
  transform: scale(1.1);
}

.bottom-nav a:active .nav-icon {
  transform: scale(0.9);
}

/* -----------------------------------------------------------------------
   5. PAGE LAYOUT
----------------------------------------------------------------------- */
.page {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--page-padding);
  padding-top: 20px;
}

.page-header {
  margin-bottom: 24px;
}

.page-title {
  font-size: var(--text-2xl);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  margin-top: 4px;
}

/* Section headers */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-title {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: var(--text-xs);
}

/* -----------------------------------------------------------------------
   6. CARDS
----------------------------------------------------------------------- */
.card {
  background: var(--surface-card);
  border-radius: var(--card-radius);
  border: 1px solid var(--surface-border);
  overflow: hidden;
  transition: border-color var(--dur-base) var(--ease-out),
              transform var(--dur-base) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out);
}

.card:hover {
  border-color: var(--color-brand);
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

.card-body {
  padding: 16px;
}

.card-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--surface-border);
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* -----------------------------------------------------------------------
   7. RANKING ROWS (core UI element)
----------------------------------------------------------------------- */
.ranking-list {
  background: var(--surface-card);
  border-radius: var(--card-radius);
  border: 1px solid var(--surface-border);
  overflow: hidden;
}

.ranking-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--surface-border);
  transition: background var(--dur-fast) var(--ease-out);
  text-decoration: none;
  color: inherit;
}

.ranking-row:last-child { border-bottom: none; }

.ranking-row:hover,
.ranking-row:active {
  background: var(--surface-card-alt);
}

/* Position badge */
.rank-pos {
  min-width: 28px;
  text-align: center;
  font-weight: 800;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.rank-pos.pos-1 { color: var(--color-gold); font-size: var(--text-lg); }
.rank-pos.pos-2 { color: var(--color-silver); }
.rank-pos.pos-3 { color: var(--color-bronze); }

/* Team avatar */
.team-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-brand), var(--color-brand-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: var(--text-sm);
  color: var(--text-inverse);
  flex-shrink: 0;
  text-transform: uppercase;
}

.rank-info {
  flex: 1;
  min-width: 0;
}

.rank-name {
  font-weight: 600;
  font-size: var(--text-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 1px;
}

.rank-score {
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  text-align: right;
}

.rank-score-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-align: right;
}

/* -----------------------------------------------------------------------
   8. STAT CARDS (dashboard metrics)
----------------------------------------------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface-card);
  border-radius: var(--card-radius);
  border: 1px solid var(--surface-border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-icon { font-size: 22px; margin-bottom: 4px; }
.stat-value {
  font-size: var(--text-2xl);
  font-weight: 800;
  letter-spacing: -0.03em;
}
.stat-value.green { color: var(--color-brand); }
.stat-value.gold  { color: var(--color-gold); }
.stat-value.red   { color: var(--color-danger); }

.stat-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* -----------------------------------------------------------------------
   9. TABLES (jornadas, mercado)
----------------------------------------------------------------------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.data-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--surface-border);
}

.data-table td {
  padding: 12px;
  border-bottom: 1px solid rgba(51, 65, 85, 0.5);
  color: var(--text-primary);
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface-card-alt); }

/* -----------------------------------------------------------------------
   10. JORNADA SELECTOR
----------------------------------------------------------------------- */
.jornada-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
  gap: 8px;
  margin-bottom: 24px;
}

.jornada-btn {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-weight: 700;
  font-size: var(--text-sm);
  border: 1px solid var(--surface-border);
  background: var(--surface-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
  text-decoration: none;
}

.jornada-btn:hover {
  background: var(--color-brand);
  color: var(--text-inverse);
  border-color: var(--color-brand);
  transform: scale(1.05);
}

.jornada-btn.closed {
  background: rgba(34, 197, 94, 0.1);
  color: var(--color-brand);
  border-color: rgba(34, 197, 94, 0.3);
}

.jornada-btn.running {
  background: rgba(245, 158, 11, 0.15);
  color: var(--color-gold);
  border-color: rgba(245, 158, 11, 0.4);
  animation: pulse-border 2s ease-in-out infinite;
}

.jornada-btn.future {
  opacity: 0.4;
}

@keyframes pulse-border {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
  50% { box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.1); }
}

/* -----------------------------------------------------------------------
   11. BADGES & CHIPS
----------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: var(--text-xs);
  font-weight: 600;
}
.badge-green  { background: rgba(34,197,94,.15); color: var(--color-brand); }
.badge-gold   { background: rgba(245,158,11,.15); color: var(--color-gold); }
.badge-gray   { background: var(--surface-border); color: var(--text-muted); }
.badge-red    { background: rgba(239,68,68,.15); color: var(--color-danger); }

/* -----------------------------------------------------------------------
   12. BUTTONS
----------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--btn-radius);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--dur-fast) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--color-brand);
  color: var(--text-inverse);
}
.btn-primary:hover { background: var(--color-brand-dark); color: var(--text-inverse); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--surface-border);
}
.btn-ghost:hover { background: var(--surface-card); color: var(--text-primary); }

.btn-full { width: 100%; }

/* -----------------------------------------------------------------------
   13. FORM ELEMENTS
----------------------------------------------------------------------- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-group label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input {
  background: var(--surface-input);
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: var(--text-base);
  font-family: var(--font-sans);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
  -webkit-appearance: none;
}

.form-group input:focus {
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px var(--color-brand-glow);
}

.form-group input::placeholder { color: var(--text-muted); }

/* -----------------------------------------------------------------------
   14. LOGIN PAGE
----------------------------------------------------------------------- */
.login-container {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at top, rgba(34,197,94,.1) 0%, transparent 60%),
    var(--surface-base);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface-card);
  border-radius: 24px;
  border: 1px solid var(--surface-border);
  padding: 32px 28px;
  text-align: center;
}

.login-logo {
  font-size: 48px;
  margin-bottom: 8px;
  filter: drop-shadow(0 0 16px var(--color-brand));
}

.login-card h1 {
  font-size: var(--text-xl);
  font-weight: 800;
  margin-bottom: 2px;
}

.login-card h2 {
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

/* -----------------------------------------------------------------------
   15. ALERTS & MESSAGES
----------------------------------------------------------------------- */
.messages {
  padding: 0 var(--page-padding);
  margin-top: 12px;
}

.alert {
  border-radius: 10px;
  padding: 12px 14px;
  font-size: var(--text-sm);
  margin-bottom: 8px;
  border-left: 3px solid;
}
.alert-error, .alert-danger  { background: rgba(239,68,68,.1); border-color: var(--color-danger); color: #fca5a5; }
.alert-success               { background: rgba(34,197,94,.1);  border-color: var(--color-brand);  color: #86efac; }
.alert-warning               { background: rgba(245,158,11,.1); border-color: var(--color-gold);   color: #fcd34d; }
.alert-info                  { background: rgba(59,130,246,.1); border-color: var(--color-info);   color: #93c5fd; }

/* -----------------------------------------------------------------------
   16. HERO / INDEX PAGE
----------------------------------------------------------------------- */
.hero {
  text-align: center;
  padding: 48px 0 32px;
}

.hero-icon {
  font-size: 64px;
  margin-bottom: 16px;
  filter: drop-shadow(0 0 24px var(--color-brand));
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.hero-title {
  font-size: var(--text-3xl);
  font-weight: 800;
  letter-spacing: -0.04em;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #f1f5f9, var(--color-brand));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  color: var(--text-secondary);
  font-size: var(--text-base);
  margin-bottom: 32px;
}

.temporadas-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.temporada-card {
  background: var(--surface-card);
  border: 1px solid var(--surface-border);
  border-radius: var(--card-radius);
  padding: 20px 16px;
  text-align: center;
  text-decoration: none;
  color: var(--text-primary);
  transition: all var(--dur-base) var(--ease-out);
}

.temporada-card:hover,
.temporada-card:active {
  border-color: var(--color-brand);
  background: var(--surface-card-alt);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
  color: var(--text-primary);
}

.temporada-card.active {
  border-color: var(--color-brand);
  background: rgba(34, 197, 94, 0.08);
}

.temporada-year {
  font-size: var(--text-xl);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.temporada-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 4px;
}

/* -----------------------------------------------------------------------
   17. CHARTS WRAPPER
----------------------------------------------------------------------- */
.chart-container {
  background: var(--surface-card);
  border-radius: var(--card-radius);
  border: 1px solid var(--surface-border);
  padding: 16px;
  margin-bottom: 16px;
  position: relative;
}

.chart-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

/* -----------------------------------------------------------------------
   18. MARKET PLAYER CARD
----------------------------------------------------------------------- */
.player-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--surface-border);
  transition: background var(--dur-fast) var(--ease-out);
  text-decoration: none;
  color: inherit;
}
.player-card:last-child { border-bottom: none; }
.player-card:hover { background: var(--surface-card-alt); }

.player-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.player-name { font-weight: 600; font-size: var(--text-sm); }
.player-club { font-size: var(--text-xs); color: var(--text-muted); }
.player-value {
  margin-left: auto;
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--color-brand);
}

/* -----------------------------------------------------------------------
   19. PAYMENT TABLE ROWS
----------------------------------------------------------------------- */
.payment-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--surface-border);
}
.payment-row:last-child { border-bottom: none; }

.payment-name { flex: 1; font-weight: 500; font-size: var(--text-sm); }
.payment-amount {
  font-weight: 800;
  font-size: var(--text-base);
  color: var(--color-danger);
}
.payment-estimated { font-size: var(--text-xs); color: var(--text-muted); }

/* -----------------------------------------------------------------------
   20. LOADING SKELETON
----------------------------------------------------------------------- */
.skeleton {
  background: linear-gradient(90deg, var(--surface-card) 25%, var(--surface-card-alt) 50%, var(--surface-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* -----------------------------------------------------------------------
   21. UTILITIES
----------------------------------------------------------------------- */
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-xl { font-size: var(--text-xl); }
.font-bold { font-weight: 700; }
.text-muted { color: var(--text-muted); }
.text-brand { color: var(--color-brand); }
.text-gold  { color: var(--color-gold); }
.text-danger { color: var(--color-danger); }
.w-full { width: 100%; }

/* -----------------------------------------------------------------------
   22. SCROLLBAR (webkit)
----------------------------------------------------------------------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface-base); }
::-webkit-scrollbar-thumb { background: var(--surface-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* -----------------------------------------------------------------------
   23. PWA SPLASH / INSTALL BANNER
----------------------------------------------------------------------- */
.install-banner {
  display: none;
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 16px);
  left: 16px;
  right: 16px;
  background: var(--surface-card);
  border: 1px solid var(--color-brand);
  border-radius: var(--card-radius);
  padding: 14px 16px;
  z-index: 200;
  box-shadow: var(--shadow-card), var(--shadow-glow);
  gap: 12px;
  align-items: center;
}
.install-banner.show { display: flex; }
.install-banner-text { flex: 1; font-size: var(--text-sm); font-weight: 500; }
.install-banner-text small { color: var(--text-muted); font-size: var(--text-xs); }

/* -----------------------------------------------------------------------
   24. RESPONSIVE — Desktop enhancements
----------------------------------------------------------------------- */
@media (min-width: 768px) {
  :root {
    --page-padding: 24px;
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .temporadas-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .page {
    padding-top: 32px;
  }

  .page-title {
    font-size: var(--text-3xl);
  }
}
