/* PredictorFutbol Web · FASE 5 (mobile-first, comercial).
   Tokens de marca reutilizables; clases del FASE 2/3/4 preservadas. */

:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --border: #e3e7ee;
  --text: #1c2333;
  --muted: #6b7484;
  --accent: #1f6feb;
  --accent-strong: #1756c1;
  --accent-soft: #e8f0fe;
  --pos: #1a7f37;
  --pos-soft: #e6f4ea;
  --neg: #c62828;
  --neg-soft: #fdecea;
  --warn: #7a5c00;
  --warn-bg: #fff8e6;
  --warn-border: #e8d28a;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lift: 0 6px 18px rgba(16, 24, 40, .10);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
@media (min-width: 860px) {
  .topbar { flex-direction: row; align-items: center; justify-content: space-between; padding: 12px 24px; }
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  font-weight: 700;
  display: grid; place-items: center;
  box-shadow: var(--shadow);
  flex: none;
}
.brand h1 { margin: 0; font-size: 18px; line-height: 1.1; }
.tagline { margin: 0; font-size: 12px; color: var(--muted); }

.nav { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 9px;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  flex: 1 1 auto;
}
.nav-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* ---------- Layout ---------- */
.content { max-width: 1100px; margin: 20px auto; padding: 0 12px; }
.view { display: none; }
.view.active { display: block; }
.view h2 { margin: 0 0 6px; font-size: 20px; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.hint { color: var(--muted); margin: 0 0 14px; font-size: 14px; }
.muted { color: var(--muted); }

.ghost-btn, .primary-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 9px;
  padding: 9px 14px;
  font-size: 14px;
  cursor: pointer;
  transition: transform .06s ease, box-shadow .12s ease;
}
.ghost-btn:hover { border-color: var(--accent); color: var(--accent); }
.primary-btn { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.primary-btn:hover { background: var(--accent-strong); box-shadow: var(--shadow-lift); }

/* ---------- Auth (FASE 6) ---------- */
.auth-zone {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.auth-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
}
.auth-username { font-weight: 600; color: var(--accent-strong); }
.auth-role { color: var(--accent); }
.login-box {
  max-width: 420px;
  margin: 24px auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 20px;
}
.login-box h2 { margin: 0 0 4px; }
.login-error {
  background: var(--neg-soft);
  border: 1px solid #f5c6c6;
  color: var(--neg);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 13px;
  margin: 10px 0 0;
}
.role-select {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--surface);
  margin-right: 6px;
}

/* ---------- Hero / home (FASE 5) ---------- */
.hero {
  background: linear-gradient(135deg, #10233f 0%, #173a66 55%, #1f6feb 130%);
  color: #fff;
  border-radius: var(--radius);
  padding: 26px 20px 24px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-lift);
}
.hero h2 { margin: 0 0 8px; font-size: 22px; line-height: 1.25; color: #fff; }
.hero-sub { margin: 0 0 12px; font-size: 14px; color: #d7e3f5; }
.hero-bullets { margin: 0 0 16px; padding-left: 18px; font-size: 14px; color: #e6eefb; }
.hero-bullets li { margin-bottom: 4px; }
.hero-stats {
  margin: 0 0 14px;
  font-size: 13px;
  color: #cfe0f6;
  font-variant-numeric: tabular-nums;
}
.hero-cta { background: #fff; border-color: #fff; color: var(--accent-strong); font-weight: 700; }
.hero-cta:hover { background: #eef4ff; color: var(--accent-strong); }

/* ---------- Fixtures HOY ---------- */
.fixture-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.fixture-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.fixture-league {
  font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--accent); font-weight: 600;
}
.fixture-teams {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin: 10px 0; font-size: 15px; font-weight: 600;
  flex-wrap: wrap;
}
.fixture-teams .vs { color: var(--muted); font-weight: 400; }
.fixture-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; align-items: center; }
.fixture-time { font-variant-numeric: tabular-nums; }
.state { text-transform: capitalize; }

/* ---------- Oportunidades (cards FASE 5) ---------- */
.opp-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.opp-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  transition: box-shadow .15s ease, transform .08s ease;
}
.opp-card:hover { box-shadow: var(--shadow-lift); }
.opp-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.opp-league { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); font-weight: 600; }
.opp-market {
  font-size: 12px; font-weight: 600; color: var(--text);
  background: var(--accent-soft); border-radius: 999px; padding: 3px 10px;
}
.opp-teams { margin: 10px 0 12px; font-size: 17px; }
.opp-teams .vs { color: var(--muted); font-weight: 400; }
.opp-expl { margin: 10px 0 0; font-size: 13px; color: var(--text); background: #f7f9fc; border-radius: 8px; padding: 8px 10px; }
.opp-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* ---------- Estados (FASE 5) ---------- */
.state-block {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 26px 18px;
  text-align: center;
  color: var(--text);
  margin-bottom: 14px;
}
.state-block .state-icon { display: block; font-size: 26px; margin-bottom: 6px; }
.state-block .state-title { margin: 0 0 4px; font-weight: 600; font-size: 15px; }
.state-block .state-message { margin: 0; color: var(--muted); font-size: 13px; }
.state-error { border-color: #f5c6c6; background: var(--neg-soft); }
.state-error .state-title { color: var(--neg); }
.state-spinner {
  display: inline-block;
  width: 26px; height: 26px;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: state-spin .8s linear infinite;
}
@keyframes state-spin { to { transform: rotate(360deg); } }
.state-retry { margin-top: 10px; }
.state-actions { text-align: center; margin-top: 12px; }
.state-actions .primary-btn { min-width: 160px; }

/* ---------- Badges (FASE 7) ---------- */
.opp-legend { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rank-badge {
  display: inline-flex;
  align-items: center;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 9px;
  box-shadow: var(--shadow);
}
.ev-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 9px;
  margin-top: 4px;
}
.ev-high { background: var(--pos-soft); color: var(--pos); border: 1px solid var(--pos); }
.ev-mid { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-border); }
.ev-marg { background: #eef1f5; color: var(--muted); border: 1px solid var(--border); }
.ev-none { background: var(--neg-soft); color: var(--neg); border: 1px solid #f5c6c6; }
.res-badge {
  display: inline-block;
  min-width: 28px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  border-radius: 6px;
  padding: 2px 8px;
}
.res-w { background: var(--pos-soft); color: var(--pos); }
.res-l { background: var(--neg-soft); color: var(--neg); }
.res-p { background: #eef1f5; color: var(--muted); }
.pl-pos { color: var(--pos); font-weight: 600; }
.pl-neg { color: var(--neg); font-weight: 600; }

/* ---------- Summary cards (FASE 7: Mis apuestas) ---------- */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 0 0 14px;
}
.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 12px;
  text-align: center;
}

/* ---------- Tablas ---------- */
.table-wrap, .grid-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: #fafbfc; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.league { font-weight: 600; }
.pos { color: var(--pos); font-weight: 600; }
.neg { color: var(--neg); font-weight: 600; }

/* ---------- Form de partido ---------- */
.match-form { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.match-form select, .match-form input, .match-form button {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px;
  font-size: 15px; background: var(--surface); min-width: 100%;
}

/* ---------- Historial ---------- */
tr.history-row { cursor: pointer; }
tr.history-row:hover td { background: #f4f7fd; }

.summary-bar {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 0 0 14px;
}
.summary-cell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 12px;
  text-align: center;
}
.summary-label { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.summary-value { display: block; font-size: 20px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.summary-hint { display: block; font-size: 11px; color: var(--muted); }

.history-groups { margin: 0 0 16px; }
.warn-banner {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--warn);
}
.warn-banner ul { margin: 4px 0 0 18px; padding: 0; }
.group-box { margin-bottom: 14px; }
.group-box h4 { margin: 0 0 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.group-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.group-table th, .group-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.group-table th { color: var(--muted); font-weight: 600; }
.group-table td.num, .group-table th.num { text-align: right; font-variant-numeric: tabular-nums; }

.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.pager-label { font-size: 14px; color: var(--muted); }
.pager .ghost-btn:disabled { opacity: .45; cursor: default; }

.empty-state {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  color: var(--text);
  margin-bottom: 14px;
}
.empty-state p { margin: 0 0 6px; }

/* ---------- Ficha de predicción y detalle de partido ---------- */
.action-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }

.match-detail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.match-detail h3 { margin: 0 0 6px; font-size: 18px; }
.liga { color: var(--muted); font-size: 14px; }
.movement { margin: 4px 0 16px; color: var(--accent); font-size: 14px; }

.stat-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.stat {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fafbfc;
}
.stat-label { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.stat-value { display: block; font-size: 19px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12px; color: var(--muted); }

.grid-block { padding: 4px 14px 14px; margin-bottom: 14px; }
.grid-block h4 { margin: 12px 0 8px; font-size: 15px; }
table.compact { font-size: 13px; }

.error {
  position: fixed;
  bottom: 18px; left: 50%;
  transform: translateX(-50%);
  background: var(--neg-soft);
  color: var(--neg);
  border: 1px solid #f5c6c6;
  padding: 10px 16px;
  border-radius: 9px;
  font-size: 14px;
  max-width: 92%;
  box-shadow: var(--shadow-lift);
  z-index: 20;
}
.hidden { display: none !important; }

/* ---------- Tablet y desktop (mobile-first: base = móvil) ---------- */
@media (min-width: 560px) {
  .opp-grid { grid-template-columns: repeat(2, 1fr); }
  .summary-bar, .summary-grid { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
  .stat-row { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
}

@media (min-width: 860px) {
  .nav { overflow: visible; }
  .nav-btn { flex: none; }
  .content { padding: 0 20px; margin: 24px auto; }
  .hero { padding: 34px 30px 30px; }
  .hero h2 { font-size: 26px; max-width: 720px; }
  .hero-sub { max-width: 640px; }
  .opp-grid { grid-template-columns: repeat(3, 1fr); }
  .match-form select, .match-form input, .match-form button { min-width: 180px; }
  .summary-value { font-size: 22px; }
  .match-detail { padding: 20px; }
}