/* ============================================================
   RPSTATS — estilos específicos de la app
   Variables, reset, navbar, footer, landing, login, botones
   comunes y responsive base → rp-shared-style.css (assets)
   ============================================================ */

:root {
  /* Alias internos (RPStats usa --bg, --surface, etc.) */
  --bg:       var(--app-bg);
  --surface:  var(--app-surface);
  --surface2: var(--app-surface2);
  --border:   var(--app-border);
  --text:     var(--app-text);
  --muted:    var(--app-muted);

  /* Variables específicas de RPStats */
  --gold:        #f0b429;
  --gold-dark:   #c8920f;
  --danger:      #dc2626;
  --success:     #16a34a;
  --warning:     #d97706;
  --info:        #0369a1;
  --red-card:    #C62828;
  --yellow-card: #FACC15;
  --radius:      8px;
}

/* ── Modo claro: alias internos + overrides específicos de RPStats ── */
body.light-mode {
  --bg:      #f0f4f2;
  --surface: #ffffff;
  --surface2:#e8f0eb;
  --border:  rgba(1,44,29,0.2);
  --text:    #012C1D;
  --muted:   #3a5a4a;
}

/* Cards y superficies */
body.light-mode .card,
body.light-mode .stat-card,
body.light-mode .match-card,
body.light-mode .modal       { background: #ffffff; color: #012C1D; border-color: rgba(1,44,29,0.2); }
body.light-mode .card-header { border-bottom-color: rgba(1,44,29,0.12); }
body.light-mode .card-title  { color: #012C1D; }
body.light-mode h2, body.light-mode h3 { color: #012C1D; }
body.light-mode .page-header h1 { color: #012C1D; }
body.light-mode .page-header    { border-bottom-color: rgba(1,44,29,0.2); }
body.light-mode .stat-value     { color: #012C1D; }
body.light-mode .match-rival    { color: #012C1D; }

/* Notices */
body.light-mode .notice { background: rgba(1,44,29,0.06); }

/* Forms */
body.light-mode input, body.light-mode select, body.light-mode textarea {
  background: #f5f8f6; color: #012C1D; border-color: rgba(1,44,29,0.35);
}
body.light-mode input::placeholder, body.light-mode textarea::placeholder { color: rgba(1,44,29,0.4); }
body.light-mode select option { background: #fff; color: #012C1D; }
body.light-mode input:focus, body.light-mode select:focus, body.light-mode textarea:focus {
  border-color: #012C1D; box-shadow: 0 0 0 2px rgba(1,44,29,0.12);
}
body.light-mode label { color: #3a5a4a; }

/* Botones */
body.light-mode .btn.gold   { background: #012C1D; color: #fff; }
body.light-mode .btn.ghost  { border-color: rgba(1,44,29,0.35); color: #012C1D; }
body.light-mode .btn.ghost:hover { background: rgba(1,44,29,0.08); }

/* Tabla */
body.light-mode th { background: #012C1D; color: #fff; }
body.light-mode td { color: #012C1D; }
body.light-mode tr:hover td { background: #f0f7f3; }

/* Mobile menu en modo claro: siempre verde */
body.light-mode .mobile-menu { background: #012C1D; }

/* Elementos con color:#fff que necesitan override */
body.light-mode .btn           { color: #012C1D; }
body.light-mode .btn.green,
body.light-mode .btn.red       { color: #fff; }
body.light-mode .card-title    { color: #3a5a4a; }
body.light-mode .match-score   { color: #012C1D; }
body.light-mode .stats-tab.active { color: #012C1D; border-bottom-color: #012C1D; }
body.light-mode .stats-tab:hover  { color: #012C1D; }
body.light-mode .modal-title   { color: #012C1D; }
body.light-mode .modal-close:hover { color: #012C1D; }
body.light-mode .event-item    { background: rgba(1,44,29,0.04); }
body.light-mode .player-row:hover  { background: rgba(1,44,29,0.05); }
body.light-mode .timer-display { background: #012C1D; }
body.light-mode .text-white    { color: #012C1D; }

/* Dorsal y chips */
body.light-mode .dorsal { color: var(--gold); background: rgba(1,44,29,0.12); }
/* Links — no están en shared */
a { color: rgba(255,255,255,0.75); text-decoration: none; }
a:hover { color: #fff; text-decoration: underline; }
body.light-mode a { color: #3a5a4a; }
body.light-mode a:hover { color: #012C1D; }

/* ── Layout ── */
html, body { overflow-x: hidden; height: 100%; line-height: 1.5; }
#app { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; background: var(--app-bg); }
.page { padding: 20px 24px; flex: 1; }

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.page-header h1 {
  font-family: var(--font-card);
  font-size: 22px;
  color: #fff;
  font-weight: 400;
  letter-spacing: .5px;
  margin: 0;
}

.page-header .subtitle { font-size: 12px; color: var(--app-muted); }

h2 { font-size: 18px; font-weight: 600; color: rgba(255,255,255,.9); margin: 0 0 8px; }
h3 { font-size: 15px; font-weight: 600; color: rgba(255,255,255,.75); margin: 0 0 6px; }
body.light-mode h2 { color: #012C1D; }
body.light-mode h3 { color: #3a5a4a; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.card-title { font-size: 14px; font-weight: 600; color: #c8dbd0; margin: 0; }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid rgba(255,255,255,.2);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat-card.gold    { border-left-color: var(--gold); }
.stat-card.green   { border-left-color: #4ade80; }
.stat-card.danger  { border-left-color: var(--danger); }
.stat-card.info    { border-left-color: var(--info); }

.stat-value { font-family: var(--font-card); font-size: 28px; color: #fff; line-height: 1.1; }
.stat-label { font-size: 10px; color: var(--app-muted); text-transform: uppercase; letter-spacing: .6px; font-weight: 700; margin-top: 4px; }

/* ============================================================
   GRIDS
   ============================================================ */
.grid   { display: grid; grid-template-columns: repeat(2,1fr); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit,minmax(200px,1fr)); gap: 12px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: none;
  background: var(--surface2);
  color: #fff;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  font-family: var(--font-ui);
  cursor: pointer;
  text-decoration: none;
  transition: filter .15s, opacity .15s;
  white-space: nowrap;
  letter-spacing: .2px;
}
.btn:hover { filter: brightness(1.2); text-decoration: none; }
.btn:active { opacity: .85; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn.gold    { background: #fff; color: #012C1D; }
.btn.green   { background: var(--success); color: #fff; }
.btn.red     { background: var(--danger); color: #fff; }
.btn.ghost   { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn.ghost:hover { background: rgba(255,255,255,.08); }

.btn.sm  { padding: 5px 10px; font-size: 12px; border-radius: 5px; }
.btn.lg  { padding: 12px 24px; font-size: 15px; border-radius: 8px; }
.btn.xl  { padding: 16px 28px; font-size: 18px; border-radius: 10px; }
.btn.full { width: 100%; justify-content: center; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================================================
   FORMS
   ============================================================ */
.form-row { margin-bottom: 14px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  margin-bottom: 5px;
}

input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font-ui);
  background: rgba(0,0,0,.25);
  color: var(--text);
  transition: border-color .15s;
}

input::placeholder, textarea::placeholder { color: rgba(255,255,255,.25); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(240,180,41,.12);
}
select option { background: #012C1D; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  overflow-x: auto;
}

table { width: 100%; border-collapse: collapse; background: #fff; }
th, td {
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
  padding: 8px 12px;
  font-size: 13px;
  color: #111;
  vertical-align: middle;
}
th {
  background: #1a3d2a;
  color: rgba(255,255,255,.85);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  white-space: nowrap;
}
tr:hover td { background: #f7faf8; }

.td-num { text-align: right; font-variant-numeric: tabular-nums; }
.td-center { text-align: center; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(255,255,255,.12);
  color: var(--text);
}

.badge-ok      { background: #dcfce7; color: #166534; }
.badge-warn    { background: #fef9c3; color: #854d0e; }
.badge-error   { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-gold    { background: var(--gold); color: #012C1D; }
.badge-draft   { background: #f1f5f9; color: #475569; }
.badge-active  { background: #d1fae5; color: #065f46; }
.badge-paused  { background: #fef3c7; color: #92400e; }
.badge-finished { background: #e0e7ff; color: #3730a3; }

/* ============================================================
   NOTICES
   ============================================================ */
.notice {
  border-left: 3px solid var(--border);
  padding: 10px 14px;
  background: rgba(255,255,255,.04);
  border-radius: 0 6px 6px 0;
  font-size: 13px;
  margin: 10px 0;
}
.notice.warn  { border-left-color: var(--warning); background: rgba(217,119,6,.08); }
.notice.error { border-left-color: var(--danger);  background: rgba(220,38,38,.08); }
.notice.info  { border-left-color: var(--info);    background: rgba(3,105,161,.08); }
.notice.gold  { border-left-color: var(--gold);    background: rgba(240,180,41,.06); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal {
  background: #01391f;
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
}

.modal.wide { max-width: 700px; }
.modal.full { max-width: 95vw; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title { font-family: var(--font-card); font-size: 18px; color: #fff; }
.modal-close {
  background: none; border: none; color: var(--muted);
  font-size: 20px; cursor: pointer; padding: 4px;
  transition: color .15s;
}
.modal-close:hover { color: #fff; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--border); }

/* ============================================================
   PLAYER AVATAR
   ============================================================ */
.player-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--muted);
  flex-shrink: 0;
}
.player-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.player-avatar.lg { width: 52px; height: 52px; font-size: 20px; }

.player-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  transition: background .12s;
}
.player-row:hover { background: rgba(255,255,255,.06); }
.player-name { font-weight: 600; font-size: 13px; color: var(--text); }
.player-pos { font-size: 11px; color: var(--muted); }

/* Dorsal badge */
.dorsal {
  min-width: 28px; height: 28px;
  background: var(--surface2);
  border-radius: 5px;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-card);
  font-size: 13px;
  color: var(--gold);
  font-weight: 400;
  flex-shrink: 0;
}

/* ============================================================
   MATCH CARD
   ============================================================ */
.match-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.match-card:hover { border-color: var(--gold); background: var(--surface2); }
.match-card.active-match { border-color: #4ade80; background: rgba(74,222,128,.05); }

.match-score {
  font-family: var(--font-card);
  font-size: 24px;
  color: #fff;
  white-space: nowrap;
  min-width: 70px;
  text-align: center;
}
.match-rival { font-weight: 600; font-size: 14px; color: var(--text); }
.match-meta  { font-size: 11px; color: var(--muted); }

.result-W { color: #4ade80; }
.result-D { color: var(--gold); }
.result-L { color: #f87171; }

/* ============================================================
   LIVE MATCH — CRONÓMETRO & EVENTO PANEL
   ============================================================ */
.live-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 16px;
  height: calc(100vh - 80px);
}

.live-left { display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.live-right { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }

/* Timer display */
.timer-display {
  background: #010d06;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.timer-clock {
  font-family: var(--font-card);
  font-size: 52px;
  color: #fff;
  line-height: 1;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}

.timer-clock.extra { color: var(--gold); }

.timer-period {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.timer-score {
  font-family: var(--font-card);
  font-size: 36px;
  color: #fff;
  text-align: center;
}
.timer-score .rival { font-size: 12px; color: var(--muted); font-family: var(--font-ui); }

/* Event buttons */
.event-grid {
  display: grid;
  grid-template-columns: repeat(3,1fr);
  gap: 8px;
}

.event-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 8px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 12px;
  color: #fff;
  transition: filter .12s, transform .1s;
  background: var(--surface2);
  border: 1px solid var(--border);
}
.event-btn:hover { filter: brightness(1.25); }
.event-btn:active { transform: scale(.95); }
.event-btn .ev-icon { font-size: 22px; }

.event-btn.ev-gol        { background: #1a5c32; border-color: #2d8a50; }
.event-btn.ev-asistencia { background: #1a4a5c; border-color: #2d7a8a; }
.event-btn.ev-amarilla   { background: #5c4a00; border-color: #a07c00; }
.event-btn.ev-roja       { background: #5c1a1a; border-color: #8a2d2d; }
.event-btn.ev-cambio     { background: #2a1a5c; border-color: #4a2d8a; }
.event-btn.ev-lesion     { background: #5c2d1a; border-color: #8a4a2d; }
.event-btn.ev-propio     { background: #4a1a1a; border-color: #7a2d2d; }
.event-btn.ev-recibido   { background: #3a1a1a; border-color: #6a2d2d; }
.event-btn.ev-obs        { background: #1a1a3a; border-color: #2d2d6a; }

/* Event log */
.event-log { display: flex; flex-direction: column; gap: 4px; }

.event-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: rgba(255,255,255,.04);
  border-radius: 6px;
  font-size: 12px;
  border-left: 2px solid transparent;
}
.event-item.gol         { border-left-color: #4ade80; }
.event-item.amarilla    { border-left-color: var(--yellow-card); }
.event-item.roja        { border-left-color: var(--red-card); }
.event-item.cambio      { border-left-color: var(--info); }
.event-item.lesion      { border-left-color: var(--warning); }
.event-item.gol_recibido { border-left-color: #f87171; }
.event-item.gol_propio  { border-left-color: #f87171; }

.event-minute {
  font-family: var(--font-card);
  font-size: 14px;
  color: var(--gold);
  min-width: 30px;
}

/* On-field player chips */
.field-players {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.player-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  transition: border-color .12s;
}
.player-chip:hover { border-color: var(--gold); }
.player-chip .chip-min { font-family: var(--font-card); color: var(--gold); font-size: 11px; }
.player-chip.captain::after { content: ' ©'; color: var(--gold); }

/* Cards shown on chip */
.chip-cards { display: flex; gap: 2px; }
.chip-card  { width: 8px; height: 12px; border-radius: 1px; display: inline-block; }
.chip-card.yellow { background: var(--yellow-card); }
.chip-card.red    { background: var(--red-card); }

/* ============================================================
   PITCH / CAMPO TÁCTICO
   ============================================================ */
.pitch-container {
  position: relative;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.pitch-svg {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  overflow: hidden;
}

.pitch-player {
  cursor: grab;
  transition: transform .1s;
}
.pitch-player:hover .pitch-player-circle { filter: brightness(1.3); }
.pitch-player.dragging { cursor: grabbing; }

/* ============================================================
   STATS PAGE
   ============================================================ */
.stats-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.stats-tab {
  padding: 8px 16px;
  border: none;
  background: none;
  color: var(--app-muted);
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .12s, border-color .12s;
}
.stats-tab.active { color: #fff; border-bottom-color: #fff; }
.stats-tab:hover  { color: var(--text); }

/* ============================================================
   LOGIN
   ============================================================ */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}

/* ============================================================
   RESPONSIVE — específico de RPStats
   ============================================================ */
@media (max-width: 768px) {
  .page { padding: 12px 14px; }
  .live-layout { grid-template-columns: 1fr; height: auto; }
  .live-right  { order: -1; }
  .grid-4, .grid-3, .grid { grid-template-columns: repeat(2,1fr); }
  .event-grid { grid-template-columns: repeat(3,1fr); }
  .timer-clock { font-size: 38px; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .match-card { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .grid-4, .grid-3 { grid-template-columns: 1fr 1fr; }
  .event-btn { padding: 12px 6px; }
  .event-btn .ev-icon { font-size: 20px; }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 20px; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 20px; }
.flex  { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: 6px; }
.gap-2 { gap: 12px; }
.gap-3 { gap: 20px; }
.text-gold  { color: var(--gold); }
.text-muted { color: var(--app-muted); }
.text-white { color: #fff; }
.text-sm { font-size: 14px; }
.text-xs { font-size: 12px; }
.fw-bold { font-weight: 700; }
.font-card { font-family: var(--font-card); }
.w-100 { width: 100%; }
.text-center { text-align: center; }

/* Spinner */
.spinner {
  width: 24px; height: 24px;
  border: 3px solid rgba(255,255,255,.15);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px;
  color: var(--muted);
  font-size: 14px;
}
