/* ============================================================
   PORRA MUNDIAL 2026 - Styles
   ============================================================ */

:root {
  --bg-dark: #0a0f1a;
  --bg-card: #141b2d;
  --bg-card-hover: #1a2340;
  --bg-input: #1e2942;
  --accent: #00c853;
  --accent-dim: #00963e;
  --gold: #ffd700;
  --silver: #c0c0c0;
  --bronze: #cd7f32;
  --text: #e8eaf6;
  --text-dim: #8892b0;
  --text-muted: #5a6580;
  --positive: #00e676;
  --negative: #ff5252;
  --neutral: #78909c;
  --border: #2a3550;
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---- LAYOUT ---- */
.app-container {
  max-width: 900px;
  margin: 0 auto;
  padding-bottom: 80px;
}

/* ---- HEADER ---- */
#app-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
#header-player-name {
  font-weight: 700;
  font-size: 1rem;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
#header-budget {
  background: var(--accent-dim);
  color: #fff;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
}
#btn-logout {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
}
#btn-logout:hover { border-color: var(--negative); color: var(--negative); }

/* ---- NAV ---- */
#app-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  justify-content: center;
  gap: 0;
  z-index: 100;
  padding: 0 4px;
}
.nav-btn {
  flex: 1;
  max-width: 120px;
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 10px 4px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.65rem;
  transition: color 0.2s;
}
.nav-btn .nav-icon { font-size: 1.3rem; }
.nav-btn.active { color: var(--accent); }
.nav-btn:hover { color: var(--text); }

/* ---- VIEWS ---- */
.view { display: none !important; padding: 16px; }
.view.active { display: block !important; }

/* ---- LOGIN ---- */
#view-login.active {
  display: flex !important;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 30px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}
.login-logo { font-size: 3rem; margin-bottom: 8px; }
.login-title { font-size: 1.5rem; font-weight: 800; margin-bottom: 4px; }
.login-subtitle { color: var(--text-dim); font-size: 0.9rem; margin-bottom: 30px; }

.form-group {
  margin-bottom: 16px;
  text-align: left;
}
.form-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.form-group input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus { border-color: var(--accent); }
.form-group input::placeholder { color: var(--text-muted); }

.btn {
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-primary {
  background: var(--accent);
  color: #000;
  width: 100%;
}
.btn-primary:hover { background: var(--accent-dim); }

#login-error {
  display: none;
  color: var(--negative);
  font-size: 0.85rem;
  margin-bottom: 12px;
  padding: 8px;
  background: rgba(255,82,82,0.1);
  border-radius: var(--radius-sm);
}

/* ---- SECTION TITLES ---- */
.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 24px 0 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}
.section-title:first-child { margin-top: 8px; }

/* ---- LEADERBOARD ---- */
.leaderboard { display: flex; flex-direction: column; gap: 6px; }
.leaderboard-row {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  gap: 12px;
  border: 1px solid transparent;
  transition: border-color 0.2s;
}
.leaderboard-row.is-me { border-color: var(--accent); }
.lb-rank { font-size: 1.2rem; min-width: 32px; text-align: center; }
.lb-info { flex: 1; min-width: 0; }
.lb-name { font-weight: 600; font-size: 0.95rem; }
.lb-teams { font-size: 1.1rem; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-points { font-size: 1.4rem; font-weight: 800; color: var(--accent); }
.lb-points small { font-size: 0.7rem; font-weight: 400; color: var(--text-dim); }

/* ---- MY TEAMS GRID ---- */
.my-teams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.team-card-mini {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
  border: 1px solid var(--border);
}
.tcm-flag { font-size: 2rem; }
.tcm-name { font-weight: 600; font-size: 0.85rem; margin-top: 4px; }
.tcm-group { font-size: 0.75rem; color: var(--text-dim); }
.tcm-points { font-weight: 700; margin-top: 4px; font-size: 0.9rem; }
.tcm-points.positive { color: var(--positive); }
.tcm-points.negative { color: var(--negative); }

/* ---- GROUPS GRID ---- */
.groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}
.group-card {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}
.group-header {
  background: var(--bg-input);
  padding: 8px 12px;
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.group-table { padding: 4px 0; }
.group-row {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  font-size: 0.85rem;
  gap: 8px;
}
.group-row:nth-child(even) { background: rgba(255,255,255,0.02); }
.gr-team { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gr-record { color: var(--text-dim); font-size: 0.75rem; min-width: 60px; text-align: center; }
.gr-pts { font-weight: 700; min-width: 24px; text-align: center; }
.gr-owners { font-size: 0.9rem; min-width: 40px; text-align: right; }

/* ---- TEAM SELECTION ---- */
.budget-bar {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
}
.budget-label { font-size: 0.9rem; margin-bottom: 8px; }
.budget-label strong { color: var(--accent); font-size: 1.1rem; }
.budget-track {
  height: 8px;
  background: var(--bg-input);
  border-radius: 4px;
  overflow: hidden;
}
.budget-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  border-radius: 4px;
  transition: width 0.3s;
}

.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.filter-bar select {
  flex: 1;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
}
.filter-bar select:focus { border-color: var(--accent); }

.teams-list { display: flex; flex-direction: column; gap: 6px; }
.team-card {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  gap: 12px;
  transition: all 0.2s;
}
.team-card:hover { background: var(--bg-card-hover); }
.team-card.owned { border-color: var(--accent); background: rgba(0,200,83,0.08); }
.team-card.disabled { opacity: 0.5; cursor: not-allowed; }

.tc-flag { font-size: 2rem; }
.tc-info { flex: 1; min-width: 0; }
.tc-name { font-weight: 600; }
.tc-group { font-size: 0.75rem; color: var(--text-dim); }
.tc-owners { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.owner-tag {
  font-size: 0.7rem;
  background: var(--bg-input);
  padding: 2px 8px;
  border-radius: 10px;
  color: var(--text-dim);
}
.tc-right { text-align: right; }
.tc-cost { font-size: 1.2rem; font-weight: 800; color: var(--gold); }
.tc-cost small { font-size: 0.65rem; font-weight: 400; color: var(--text-dim); }
.tc-gamepts { font-size: 0.8rem; font-weight: 600; }
.tc-gamepts.positive { color: var(--positive); }
.tc-gamepts.negative { color: var(--negative); }
.tc-status { font-size: 1rem; margin-top: 2px; }

/* ---- MATCHES ---- */
.match-group-header {
  background: var(--bg-input);
  padding: 6px 12px;
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  margin-top: 12px;
}
.match-row {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.match-row.final-match { border: 2px solid var(--gold); border-radius: var(--radius-sm); }
.mr-team { flex: 1; font-size: 0.85rem; }
.mr-home { text-align: right; }
.mr-away { text-align: left; }
.mr-score {
  min-width: 80px;
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
}
.match-row.played .mr-score { color: var(--accent); }
.match-row.upcoming .mr-score { color: var(--text-muted); }
.match-extra { display: block; font-size: 0.65rem; color: var(--text-dim); font-weight: 400; }

/* ---- PERGAMINO (RULES) ---- */
.pergamino {
  background: linear-gradient(135deg, #1a1208 0%, #2a1f0e 30%, #1a1208 100%);
  border: 2px solid #5c4a2a;
  border-radius: var(--radius);
  padding: 24px 20px;
  position: relative;
  overflow: hidden;
}
.pergamino::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.pergamino::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.pergamino-header {
  text-align: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #5c4a2a;
}
.pergamino-icon { font-size: 3rem; }
.pergamino-header h2 {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.6rem;
  color: var(--gold);
  margin-top: 4px;
}
.pergamino-sub {
  color: #a08c5a;
  font-size: 0.85rem;
  margin-top: 4px;
}
.pergamino-section {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px dashed #3d3118;
}
.pergamino-section h3 {
  color: var(--gold);
  font-size: 1rem;
  margin-bottom: 12px;
}
.pergamino-section h4 {
  color: #c4a44a;
  font-size: 0.85rem;
  margin: 12px 0 8px;
}
.pergamino-section ul {
  list-style: none;
  padding: 0;
}
.pergamino-section li {
  padding: 6px 0 6px 20px;
  position: relative;
  font-size: 0.88rem;
  color: #d4c8a0;
  line-height: 1.5;
}
.pergamino-section li::before {
  content: '⚜';
  position: absolute;
  left: 0;
  color: #8a7740;
  font-size: 0.75rem;
}

/* Premios */
.premio {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
}
.premio-gold { background: rgba(255,215,0,0.1); border: 1px solid rgba(255,215,0,0.3); }
.premio-silver { background: rgba(192,192,192,0.08); border: 1px solid rgba(192,192,192,0.2); }
.premio-bronze { background: rgba(205,127,50,0.08); border: 1px solid rgba(205,127,50,0.2); }
.premio-pos {
  font-weight: 800;
  font-size: 1.2rem;
  min-width: 50px;
  text-align: center;
}
.premio-gold .premio-pos { color: var(--gold); }
.premio-silver .premio-pos { color: var(--silver); }
.premio-bronze .premio-pos { color: var(--bronze); }
.premio-desc { font-size: 0.88rem; color: #d4c8a0; }

/* Rule table */
.rule-table {
  background: rgba(0,0,0,0.2);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.rule-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 14px;
  font-size: 0.85rem;
  color: #d4c8a0;
  border-bottom: 1px solid rgba(92,74,42,0.3);
}
.rule-row:last-child { border-bottom: none; }
.rule-row.highlight-gold { background: rgba(255,215,0,0.08); }
.rule-row.highlight-silver { background: rgba(192,192,192,0.05); }
.rule-row.highlight-bronze { background: rgba(205,127,50,0.05); }
.pts-pos { color: var(--positive); font-weight: 600; }
.pts-neg { color: var(--negative); font-weight: 600; }
.pts-neu { color: var(--neutral); font-weight: 600; }

.rule-note {
  font-size: 0.8rem;
  color: #8a7740;
  margin-top: 8px;
  font-style: italic;
}

/* Teams value grid in rules */
.teams-value-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 2px;
}
.tv-row {
  display: flex;
  align-items: center;
  padding: 5px 10px;
  font-size: 0.8rem;
  color: #d4c8a0;
  gap: 8px;
}
.tv-row:nth-child(even) { background: rgba(0,0,0,0.15); }
.tv-rank { color: #8a7740; min-width: 20px; font-size: 0.7rem; }
.tv-team { flex: 1; }
.tv-cost { font-weight: 700; color: var(--gold); min-width: 24px; text-align: right; }

.pergamino-footer {
  text-align: center;
  padding-top: 16px;
  color: #8a7740;
  font-style: italic;
  font-size: 0.9rem;
}

/* ---- ADMIN ---- */
.admin-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 12px;
}
.admin-section h3 {
  font-size: 0.95rem;
  margin-bottom: 12px;
  color: var(--accent);
}
.admin-section select,
.admin-section input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  margin-bottom: 8px;
  outline: none;
}
.admin-section select:focus,
.admin-section input:focus { border-color: var(--accent); }

.admin-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.admin-field label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 4px;
  text-transform: uppercase;
}

.thirds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px;
}
.third-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  border: 1px solid var(--border);
}
.third-check.qualified { border-color: var(--accent); background: rgba(0,200,83,0.08); }
.third-check input { width: auto; margin: 0; }

/* ---- UTILITIES ---- */
.muted { color: var(--text-muted); font-size: 0.8rem; }
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
  font-size: 0.95rem;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 600px) {
  .view { padding: 12px 10px; }
  
  .login-card { padding: 30px 20px; }
  .login-title { font-size: 1.3rem; }
  
  .groups-grid { grid-template-columns: 1fr; }
  .my-teams-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .teams-value-grid { grid-template-columns: 1fr; }
  
  .mr-team { font-size: 0.75rem; }
  .mr-score { min-width: 60px; font-size: 0.9rem; }
  
  .admin-form-grid { grid-template-columns: 1fr; }
  .thirds-grid { grid-template-columns: 1fr; }
  
  .leaderboard-row { padding: 10px; gap: 8px; }
  .lb-name { font-size: 0.85rem; }
  .lb-points { font-size: 1.1rem; }
  
  .pergamino { padding: 16px 14px; }
  .pergamino-header h2 { font-size: 1.3rem; }
  
  .filter-bar { flex-direction: column; }
  
  .nav-btn { font-size: 0.6rem; }
  .nav-btn .nav-icon { font-size: 1.1rem; }
}

@media (min-width: 601px) and (max-width: 900px) {
  .groups-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
