/* ===== VARIABLES ===== */
:root {
    --primary: #1a237e;
    --primary-dark: #0d1452;
    --success: #4caf50;
    --info: #2196f3;
    --warning: #ff9800;
    --danger: #ff4757;
    --auto: #ff9800;
    --gold: #ffd700;
    --silver: #c0c0c0;
    --bronze: #cd7f32;
}

/* ===== GLOBAL ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}
.container {
    max-width: 1200px; margin: 0 auto; background: white; min-height: 100vh;
    box-shadow: 0 0 40px rgba(0,0,0,0.1);
}

/* ===== HEADER ===== */
header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white; padding: 25px 20px; text-align: center;
}
header h1 { font-size: 28px; font-weight: 800; margin-bottom: 8px; }
header p { opacity: 0.9; font-size: 14px; }

/* ===== NAVEGACIÓN ===== */
.nav-pwa {
    display: flex; background: white; padding: 10px; position: sticky; top: 0;
    z-index: 100; box-shadow: 0 2px 10px rgba(0,0,0,0.05); border-bottom: 1px solid #eee;
    flex-wrap: wrap; gap: 5px;
}
.nav-pwa a {
    flex: 1; min-width: 70px; color: #666; text-decoration: none; text-align: center;
    padding: 12px 8px; border-radius: 12px; font-weight: 600; font-size: 14px;
    transition: all 0.3s; display: flex; align-items: center; justify-content: center;
    gap: 6px; white-space: nowrap;
}
.nav-pwa a.active, .nav-pwa a:hover { background: var(--primary); color: white; }

/* ===== PESTAÑAS ===== */
.vista-tabs {
    display: flex; gap: 10px; margin: 15px 20px; background: #f8f9fa; padding: 8px;
    border-radius: 50px; border: 1px solid #e0e0e0;
}
.vista-tab {
    flex: 1; text-align: center; padding: 12px 10px; border-radius: 40px; font-weight: 600;
    font-size: 14px; cursor: pointer; transition: all 0.3s; text-decoration: none;
    color: #666; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.vista-tab:hover { background: rgba(26,35,126,0.1); color: var(--primary); }
.vista-tab.active { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; }
.vista-container { display: none; }
.vista-container.active { display: block; animation: fadeIn 0.3s; }

/* ===== GRUPOS ===== */
.grupo-section {
    margin-bottom: 20px; background: white; border-radius: 16px; overflow: hidden;
    border: 1px solid #f0f0f0;
}
.grupo-header {
    background: #f8f9fa; padding: 12px 16px; font-weight: 700; color: var(--primary);
    display: flex; align-items: center; gap: 12px; border-bottom: 2px solid #e0e0e0; cursor: pointer;
}
.grupo-header:hover { background: #e8eaf6; }
.grupo-letra { background: var(--primary); color: white; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 10px; font-weight: 800; }
.grupo-count { margin-left: auto; font-size: 13px; color: #666; background: #e0e0e0; padding: 4px 10px; border-radius: 30px; }
.toggle-icon { transition: transform 0.3s; }
.grupo-content { transition: max-height 0.3s; overflow: hidden; }
.grupo-content.collapsed { max-height: 0 !important; padding: 0 !important; }

/* ===== TABLA ===== */
.partidos-tabla { width: 100%; border-collapse: collapse; font-size: 13px; }
.partidos-tabla th { background: #f5f5f5; padding: 10px 8px; font-weight: 600; color: #333; border-bottom: 2px solid #ddd; }
.partidos-tabla td { padding: 10px 6px; border-bottom: 1px solid #eee; vertical-align: middle; }
.partidos-tabla tr:hover { background: #fafafa; }

.equipo-col { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.bandera-mini { width: 20px; height: 14px; object-fit: cover; border-radius: 3px; border: 1px solid #ddd; }
.equipo-nombre { font-weight: 500; font-size: 12px; }
.fecha-cell { font-size: 11px; color: #666; white-space: nowrap; }
.hora-cell { font-size: 12px; font-weight: 600; color: var(--primary); white-space: nowrap; }

.input-goles-mini {
    width: 45px; padding: 6px 4px; text-align: center; border: 2px solid #e0e0e0;
    border-radius: 8px; font-size: 14px; font-weight: 600; transition: all 0.2s;
}
.input-goles-mini:focus { border-color: var(--primary); outline: none; }
.input-goles-mini.modificado { background: #fff3e0; border-color: var(--warning); }
.input-goles-mini.guardado { background: #e8f5e9; border-color: var(--success); }
.input-goles-mini:disabled { background: #f5f5f5; border-color: #ddd; color: #999; cursor: not-allowed; }

/* ===== ESTADOS ===== */
.partido-deshabilitado { opacity: 0.8; background: #fafafa; position: relative; }
.partido-deshabilitado::before { content: "🔒"; position: absolute; left: 5px; top: 5px; font-size: 10px; opacity: 0.5; }

.estado-badge { display: inline-block; padding: 3px 8px; border-radius: 30px; font-size: 10px; font-weight: 600; }
.badge-pendiente { background: #ffa502; color: white; }
.badge-pronosticado { background: var(--success); color: white; }
.badge-jugando { background: var(--danger); color: white; animation: pulse 1.5s infinite; }
.badge-cerrado { background: #999; color: white; }
.badge-hoy { background: var(--danger); color: white; font-size: 9px; padding: 2px 6px; border-radius: 20px; margin-left: 5px; }

@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.7; } 100% { opacity: 1; } }

/* ===== BADGES ===== */
.badge { display: inline-block; padding: 4px 12px; border-radius: 50px; font-size: 12px; font-weight: 600; }
.badge-exacto { background: var(--success); color: white; }
.badge-resultado { background: var(--info); color: white; }
.badge-racha { background: var(--danger); color: white; }
.badge-auto {
    background: var(--auto); color: white; padding: 3px 10px; border-radius: 30px; font-size: 10px;
    font-weight: 700; display: inline-block; margin-left: 5px; text-transform: uppercase;
    animation: pulse-auto 2s infinite;
}
@keyframes pulse-auto { 0% { opacity: 1; } 50% { opacity: 0.8; } 100% { opacity: 1; } }

.grupo-tag { background: #e0e0e0; color: #333; padding: 2px 8px; border-radius: 20px; font-size: 10px; margin-left: 5px; }

/* ===== NAVEGADOR DE DÍAS ===== */
.nav-dias { display: flex; gap: 10px; margin-bottom: 25px; flex-wrap: wrap; }
.nav-dia-btn {
    flex: 1; min-width: 80px; padding: 12px 10px; border: none; border-radius: 30px;
    background: white; color: #333; font-weight: 600; cursor: pointer; transition: all 0.3s;
    border: 2px solid transparent;
}
.nav-dia-btn:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(0,0,0,0.1); }
.nav-dia-btn.hoy { background: var(--danger); color: white; }
.nav-dia-btn.manana { background: #ffa502; color: white; }
.nav-dia-btn.pasado { background: var(--info); color: white; }
.nav-dia-btn.proximos { background: var(--primary); color: white; }
.badge-count { background: rgba(255,255,255,0.2); padding: 2px 8px; border-radius: 20px; font-size: 11px; margin-left: 5px; }

/* ===== CATEGORÍAS DÍA ===== */
.categoria-dia { margin-bottom: 30px; }
.categoria-titulo {
    display: flex; align-items: center; gap: 15px; margin-bottom: 20px; padding-bottom: 10px;
    border-bottom: 3px solid; font-size: 22px; font-weight: 700;
}
.categoria-hoy .categoria-titulo { color: var(--danger); border-bottom-color: var(--danger); }
.categoria-manana .categoria-titulo { color: #ffa502; border-bottom-color: #ffa502; }
.categoria-pasado_manana .categoria-titulo { color: var(--info); border-bottom-color: var(--info); }
.categoria-proximos .categoria-titulo { color: var(--primary); border-bottom-color: var(--primary); }
.fecha-badge { background: #f0f0f0; padding: 5px 15px; border-radius: 30px; font-size: 14px; color: #666; margin-left: 15px; }

.dia-card { background: white; border-radius: 20px; margin-bottom: 20px; overflow: hidden; border: 1px solid #eee; }
.dia-header {
    background: #f8f9fa; padding: 15px 20px; display: flex; align-items: center;
    justify-content: space-between; cursor: pointer; border-bottom: 2px solid #e0e0e0;
}
.dia-header:hover { background: #e8eaf6; }
.dia-header-left { display: flex; align-items: center; gap: 15px; }
.dia-nombre { font-size: 18px; font-weight: 700; color: var(--primary); }
.dia-fecha { font-size: 14px; color: #666; }
.dia-stats { display: flex; gap: 15px; align-items: center; }
.stat-circulo { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.stat-total { background: var(--primary); color: white; }
.stat-pronosticados { background: var(--success); color: white; }
.stat-pendientes { background: #ffa502; color: white; }
.dia-content { transition: max-height 0.3s; overflow: hidden; }
.dia-content.collapsed { max-height: 0 !important; padding: 0 !important; }

/* ===== ALERTAS ===== */
.alerta-partidos-hoy {
    background: #fff3cd; border-left: 6px solid #ffc107; padding: 15px 20px;
    border-radius: 15px; margin-bottom: 20px; display: flex; align-items: center; gap: 15px; flex-wrap: wrap;
}
.btn-pronosticar-ahora { background: #ffc107; color: #856404; border: none; padding: 8px 20px; border-radius: 30px; font-weight: 700; font-size: 14px; cursor: pointer; text-decoration: none; }
.btn-pronosticar-ahora:hover { background: #e0a800; }

/* ===== RESUMEN RÁPIDO ===== */
.resumen-rapido {
    background: #f8f9fa; border-radius: 16px; padding: 15px 20px; margin-bottom: 20px;
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
    gap: 15px; border: 1px solid #e0e0e0;
}
.total-partidos { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.total-item { text-align: center; }
.total-numero { font-size: 28px; font-weight: 800; color: var(--primary); line-height: 1; }
.total-label { font-size: 11px; color: #666; text-transform: uppercase; }

/* ===== TOOLTIP ===== */
.tooltip-info { position: relative; display: inline-block; cursor: help; }
.tooltip-info:hover .tooltip-text { visibility: visible; opacity: 1; }
.tooltip-text {
    visibility: hidden; width: 200px; background: #333; color: white; text-align: center;
    padding: 8px; border-radius: 6px; position: absolute; z-index: 100; bottom: 125%;
    left: 50%; margin-left: -100px; opacity: 0; transition: opacity 0.3s; font-size: 12px;
}
.tooltip-text::after { content: ""; position: absolute; top: 100%; left: 50%; margin-left: -5px; border-width: 5px; border-style: solid; border-color: #333 transparent transparent transparent; }

/* ===== LEYENDA ===== */
.leyenda-item { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #666; }
.leyenda-color { width: 16px; height: 16px; border-radius: 4px; }
.color-hoy { background: var(--danger); }
.color-sinpronosticar { background: #ffa502; }
.color-pronosticado { background: var(--success); }
.color-modificado { background: var(--warning); }
.color-auto { background: var(--auto); }

/* ===== BARRA DE ACCIONES ===== */
.acciones-bar {
    position: sticky; bottom: 20px; background: white; border-radius: 60px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.2); padding: 12px 20px; margin-top: 30px;
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
    gap: 15px; border: 2px solid var(--primary); z-index: 100;
}
.contador-modificados { background: var(--warning); color: white; padding: 6px 15px; border-radius: 30px; font-weight: 600; font-size: 14px; }
.btn-guardar-todo {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white;
    border: none; padding: 12px 30px; border-radius: 40px; font-weight: 700; font-size: 16px;
    cursor: pointer; transition: all 0.3s; display: flex; align-items: center; gap: 10px;
}
.btn-guardar-todo:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 10px 25px rgba(26,35,126,0.4); }
.btn-guardar-todo:disabled { background: #ccc; cursor: not-allowed; }

/* ===== TOAST ===== */
.toast-notificacion {
    position: fixed; top: 20px; right: 20px; background: var(--success); color: white;
    padding: 15px 25px; border-radius: 50px; box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    transform: translateX(400px); transition: transform 0.3s; z-index: 1000;
}
.toast-notificacion.show { transform: translateX(0); }
.toast-notificacion.error { background: var(--danger); }

/* ===== LOADING ===== */
.loading-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,0.8);
    display: none; align-items: center; justify-content: center; z-index: 1000;
}
.loading-overlay.show { display: flex; }
.spinner { width: 50px; height: 50px; border: 5px solid #f3f3f3; border-top: 5px solid var(--primary); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* ===== TABLAS GENÉRICAS ===== */
.tabla-resultados { width: 100%; border-collapse: collapse; background: white; border-radius: 20px; overflow: hidden; }
.tabla-resultados th { background: var(--primary); color: white; padding: 16px 12px; font-weight: 600; }
.tabla-resultados td { padding: 16px 12px; border-bottom: 1px solid #eee; }
.tabla-resultados tbody tr:hover { background: #f8f9fa; }
.puntos { font-weight: 700; color: var(--primary); font-size: 18px; }

/* ===== PERFIL ===== */
.perfil-header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white; padding: 30px 20px; border-radius: 0 0 30px 30px; text-align: center;
}
.perfil-avatar {
    width: 100px; height: 100px; background: linear-gradient(135deg, var(--gold), #ffed4e);
    border-radius: 50%; margin: 0 auto 20px; display: flex; align-items: center;
    justify-content: center; font-size: 48px; font-weight: bold; color: var(--primary);
    border: 5px solid white;
}
.perfil-nombre { font-size: 28px; font-weight: 800; margin-bottom: 10px; }
.perfil-ranking { background: rgba(255,255,255,0.2); padding: 8px 20px; border-radius: 50px; display: inline-block; }

.stats-grid-perfil {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; margin-bottom: 30px; padding: 0 20px;
}
.stat-card-perfil { background: white; padding: 20px 10px; border-radius: 20px; text-align: center; border: 1px solid #eee; }
.stat-valor-perfil { font-size: 32px; font-weight: 800; color: var(--primary); line-height: 1; margin-bottom: 5px; }
.stat-label-perfil { font-size: 12px; color: #666; text-transform: uppercase; }

.detalles-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin: 0 20px 30px; }
.detalle-card { background: #f8f9fa; padding: 20px; border-radius: 20px; }
.detalle-item { display: flex; align-items: center; gap: 15px; margin-bottom: 15px; }
.detalle-item:last-child { margin-bottom: 0; }
.detalle-icono { font-size: 24px; width: 40px; height: 40px; background: white; border-radius: 12px; display: flex; align-items: center; justify-content: center; color: var(--primary); }
.detalle-info { flex: 1; }
.detalle-label { font-size: 12px; color: #666; margin-bottom: 2px; }
.detalle-valor { font-size: 20px; font-weight: 700; color: #333; }

/* ===== HISTORIAL ===== */
.historial-container { background: white; margin: 0 20px 30px; border-radius: 20px; padding: 20px; border: 1px solid #eee; }
.historial-titulo { display: flex; align-items: center; gap: 10px; color: var(--primary); margin-bottom: 20px; font-size: 18px; font-weight: 700; border-bottom: 2px solid #f0f0f0; padding-bottom: 15px; }
.historial-item {
    display: flex; align-items: center; justify-content: space-between; padding: 15px 0;
    border-bottom: 1px solid #eee; flex-wrap: wrap; gap: 15px;
}
.historial-item:last-child { border-bottom: none; }
.historial-info { flex: 2; min-width: 200px; }
.historial-equipos { font-weight: 700; color: #333; margin-bottom: 5px; }
.historial-fecha { font-size: 12px; color: #999; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.historial-pronostico { flex: 1; text-align: center; min-width: 120px; }
.historial-pronostico-label { font-size: 11px; color: #666; text-transform: uppercase; margin-bottom: 5px; }
.historial-pronostico-valor { font-size: 20px; font-weight: 700; color: var(--primary); }
.historial-resultado { flex: 1; text-align: center; min-width: 80px; }
.historial-resultado-label { font-size: 11px; color: #666; text-transform: uppercase; margin-bottom: 5px; }
.historial-resultado-valor { font-size: 16px; font-weight: 600; color: #333; }
.historial-puntos { flex: 0.5; text-align: center; min-width: 70px; }
.puntos-badge { background: var(--success); color: white; padding: 6px 12px; border-radius: 30px; font-weight: 700; font-size: 16px; display: inline-block; }
.puntos-badge-cero { background: #f0f0f0; color: #999; }
.historial-pendiente { background: #ffa502; color: white; padding: 6px 15px; border-radius: 30px; font-size: 13px; font-weight: 600; display: inline-block; }

/* ===== EXTRAS ===== */
.extras-card { background: #fff3e0; margin: 0 20px 30px; padding: 20px; border-radius: 20px; border-left: 6px solid var(--auto); }
.extras-titulo { display: flex; align-items: center; gap: 10px; color: #e65100; margin-bottom: 20px; font-size: 18px; font-weight: 700; }
.extras-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; }
.extras-item { background: white; padding: 15px; border-radius: 12px; display: flex; align-items: center; gap: 10px; }
.extras-icono { font-size: 24px; }
.extras-info { flex: 1; }
.extras-label { font-size: 11px; color: #666; text-transform: uppercase; }
.extras-valor { font-weight: 600; color: #333; font-size: 14px; }

/* ===== CAMBIO CONTRASEÑA ===== */
.password-section { background: white; margin: 0 20px 30px; border-radius: 20px; padding: 25px; border: 1px solid #eee; }
.password-titulo { display: flex; align-items: center; gap: 10px; color: var(--primary); margin-bottom: 20px; font-size: 18px; font-weight: 700; }
.password-form { max-width: 400px; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 600; color: #333; font-size: 14px; }
.form-control { width: 100%; padding: 12px 16px; border: 2px solid #e0e0e0; border-radius: 12px; font-size: 15px; transition: all 0.3s; }
.form-control:focus { border-color: var(--primary); outline: none; }
.btn-password { background: linear-gradient(135deg, var(--warning), #f57c00); color: white; border: none; padding: 14px 25px; border-radius: 12px; font-weight: 700; font-size: 16px; cursor: pointer; display: inline-flex; align-items: center; gap: 10px; }
.btn-password:hover { transform: translateY(-2px); box-shadow: 0 10px 20px rgba(255,152,0,0.3); }

/* ===== ALERTAS ===== */
.alert { padding: 15px 20px; border-radius: 12px; margin-bottom: 20px; font-size: 14px; }
.alert-success { background: #e8f5e9; color: #2e7d32; border: 1px solid #c8e6c9; }
.alert-error { background: #ffebee; color: #c62828; border: 1px solid #ffcdd2; }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 60px 20px; background: #f8f9fa; border-radius: 20px; }
.empty-icon { font-size: 64px; margin-bottom: 20px; opacity: 0.5; }

/* ===== FOOTER ===== */
.footer { text-align: center; padding: 20px; color: #666; border-top: 1px solid #eee; margin-top: 20px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .nav-pwa { overflow-x: auto; }
    .nav-pwa a { flex: 0 0 auto; min-width: 65px; font-size: 12px; padding: 10px 5px; }
    .partidos-tabla { display: block; overflow-x: auto; }
    .acciones-bar { flex-direction: column; border-radius: 20px; }
    .btn-guardar-todo { width: 100%; }
    .vista-tabs { margin: 10px; }
    .vista-tab { font-size: 12px; padding: 10px 5px; }
    .nav-dias { flex-direction: column; }
    .dia-header { flex-direction: column; text-align: center; }
    .stats-grid-perfil { grid-template-columns: repeat(2, 1fr); }
    .detalles-grid { grid-template-columns: 1fr; }
    .historial-item { flex-direction: column; text-align: center; }
    .historial-info, .historial-pronostico, .historial-resultado, .historial-puntos { width: 100%; }
    .extras-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    header h1 { font-size: 24px; }
    .nav-pwa { flex-direction: column; }
    .nav-pwa a { width: 100%; }
    .grupo-header { flex-wrap: wrap; }
    .total-numero { font-size: 22px; }
}