/* ==========================================================================
   STYLE.CSS - Diseño Premium Prode Mundial 2026 (Paleta Retro-Deportiva)
   Temática: Modo Claro Cream, Verde Oliva (#60864f), Oro/Mostaza (#c9bc48), Fondo Crema (#fff8ea)
   ========================================================================== */

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

:root {
    --bg-main: #fff8ea;        /* Fondo Crema Cálido */
    --bg-card: #ffffff;        /* Tarjetas Blanco Puro */
    --bg-card-disabled: #f4edd9; /* Tarjeta Deshabilitada / Inactiva */
    --bg-header: #ffffff;
    
    --primary: #60864f;        /* Verde Oliva */
    --primary-hover: #48653b;
    --accent: #c9bc48;         /* Oro/Mostaza */
    --accent-hover: #a59b38;
    --danger: #ef4444;         /* Rojo Alerta */
    
    --text-primary: #253120;   /* Verde Oscuro casi Negro */
    --text-secondary: #586952; /* Verde Muted */
    --text-muted: #889683;     /* Gris Verdoso */
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow: 0 4px 20px -2px rgba(96, 134, 79, 0.12);
    --shadow-hover: 0 10px 25px -4px rgba(96, 134, 79, 0.2);
    --border-light: rgba(96, 134, 79, 0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* ==========================================================================
   Estructura General y Header
   ========================================================================== */

header {
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-light);
    box-shadow: 0 2px 10px rgba(96, 134, 79, 0.05);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 1rem 2rem;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary);
}

.logo span {
    color: var(--accent);
}

.user-nav-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-badge {
    background: rgba(96, 134, 79, 0.06);
    border: 1px solid var(--border-light);
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-badge .avatar-dot {
    width: 8px;
    height: 8px;
    background-color: var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 6px var(--primary);
}

.btn-logout {
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--danger);
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-logout:hover {
    background: var(--danger);
    color: #fff;
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.2);
}

/* ==========================================================================
   Contenedor Principal y Layout
   ========================================================================== */

main {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* ==========================================================================
   Pantallas de Acceso (Login / Registro / Bloqueo Admin)
   ========================================================================== */

.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 75vh;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 24px;
    padding: 2.5rem;
    width: 100%;
    max-width: 450px;
    box-shadow: var(--shadow);
    text-align: center;
    animation: fadeIn 0.5s ease-out;
}

.auth-card .trophy-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    animation: float 4s ease-in-out infinite;
}

.auth-card h2 {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: var(--primary);
    letter-spacing: -0.5px;
}

.auth-card p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

.form-group {
    text-align: left;
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.input-control {
    width: 100%;
    background: #fffdf9;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    color: var(--text-primary);
    font-size: 1rem;
    transition: var(--transition);
}

.input-control:focus {
    outline: none;
    border-color: var(--primary);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(96, 134, 79, 0.15);
}

.input-control:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #f3edd9;
}

.btn-block {
    width: 100%;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    border: none;
    color: var(--text-primary);
    font-size: 1.05rem;
    font-weight: 700;
    padding: 0.9rem;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 12px rgba(201, 188, 72, 0.25);
}

.btn-block:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(201, 188, 72, 0.4);
}

/* ==========================================================================
   Tablero de Partidos e Indicadores de Estado
   ========================================================================== */

.board-header {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.board-info {
    text-align: center;
}

.board-info h1 {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.board-info p {
    color: var(--text-secondary);
}

/* Secciones de Semanas en la vista continua */
.week-section {
    margin-bottom: 3.5rem;
}

.week-section-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary);
    border-bottom: 2px solid var(--border-light);
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.week-section-title span.date-range {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: rgba(96, 134, 79, 0.08);
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
}

.week-section.inactive-week .week-section-title {
    color: var(--text-muted);
    border-bottom-color: rgba(96, 134, 79, 0.06);
}

.week-section.inactive-week .week-section-title span.date-range {
    background: rgba(96, 134, 79, 0.03);
    color: var(--text-muted);
}

/* Grill de Partidos */
.matches-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 1.5rem;
}

/* Tarjeta de Partido */
.match-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 20px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.match-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: transparent;
    transition: var(--transition);
}

/* Tarjeta Activa Abierta */
.match-card:not(.match-disabled):hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: var(--primary);
}

/* Tarjeta Votada */
.match-card.voted::before {
    background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
}
.match-card.voted {
    border-color: rgba(96, 134, 79, 0.3);
}

/* Tarjeta Deshabilitada (Semanas pasadas/futuras o expirado) */
.match-card.match-disabled {
    background: var(--bg-card-disabled);
    border-color: rgba(96, 134, 79, 0.06);
    box-shadow: none;
    opacity: 0.75;
}

.match-card.match-disabled .team-flag {
    filter: grayscale(40%) opacity(80%);
}

.match-card.match-disabled .team-name {
    color: var(--text-secondary);
}

/* Cabecera Tarjeta */
.match-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 700;
}

.match-group {
    background: rgba(96, 134, 79, 0.08);
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    color: var(--primary);
    letter-spacing: 0.5px;
}

.status-badge {
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.status-open {
    background: rgba(96, 134, 79, 0.12);
    color: var(--primary);
    border: 1px solid rgba(96, 134, 79, 0.2);
}

.status-closed {
    background: rgba(239, 68, 68, 0.08);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.15);
}

.status-voted {
    background: rgba(201, 188, 72, 0.15);
    color: #8c8225;
    border: 1px solid rgba(201, 188, 72, 0.3);
}

.status-locked {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-muted);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

/* Equipos e Inputs */
.teams-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

.team-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    gap: 0.5rem;
    text-align: center;
    max-width: 42%;
}

.team-flag {
    font-size: 2.2rem;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
    line-height: 1;
}

.team-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.2;
}

.scores-input-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.score-input {
    width: 50px;
    height: 50px;
    background: #fffdfa;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    text-align: center;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    outline: none;
    transition: var(--transition);
}

.score-input::-webkit-outer-spin-button,
.score-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.score-input[type=number] {
    -moz-appearance: textfield;
}

.score-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(96, 134, 79, 0.15);
    background: #ffffff;
}

.score-input:disabled {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.06);
    color: var(--text-secondary);
    opacity: 0.9;
}

.score-separator {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-secondary);
}

/* Previsualización del Resultado */
.prediction-banner {
    background: rgba(96, 134, 79, 0.04);
    border: 1px solid rgba(96, 134, 79, 0.06);
    border-radius: 10px;
    padding: 0.5rem;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.prediction-banner strong {
    color: var(--primary);
}

.prediction-banner.draw strong {
    color: var(--text-primary);
}

.prediction-banner.win strong {
    color: var(--primary);
}

/* Pie de Tarjeta */
.match-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.25rem;
}

.match-datetime {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.btn-save-match {
    background: var(--accent);
    border: none;
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 2px 6px rgba(201, 188, 72, 0.2);
}

.btn-save-match:hover:not(:disabled) {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 10px rgba(96, 134, 79, 0.2);
}

.btn-save-match:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background: #e2dcb6;
    color: var(--text-muted);
    transform: none;
    box-shadow: none;
}

/* ==========================================================================
   Modo de Conexión / Indicador de estado del Sistema
   ========================================================================== */

.system-status-banner {
    max-width: 1200px;
    width: 100%;
    margin: 1rem auto 0 auto;
    padding: 0.6rem 1.5rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid var(--border-light);
}

.system-status-banner.mode-api {
    background: #eef7eb;
    border-color: rgba(96, 134, 79, 0.2);
    color: var(--primary);
}

.system-status-banner.mode-local {
    background: #fdfae7;
    border-color: rgba(201, 188, 72, 0.3);
    color: #8c8225;
}

/* ==========================================================================
   Panel de Admin
   ========================================================================== */

.admin-layout {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.admin-actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    background: var(--bg-card);
    padding: 1.25rem 1.5rem;
    border-radius: 16px;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow);
}

.search-container {
    display: flex;
    align-items: center;
    background: #fffdf9;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 0.2rem 0.8rem;
    width: 100%;
    max-width: 320px;
}

.search-input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 0.5rem;
    width: 100%;
    font-size: 0.9rem;
    outline: none;
}

.admin-tab-nav {
    display: flex;
    gap: 0.5rem;
    background: rgba(96, 134, 79, 0.05);
    padding: 0.3rem;
    border-radius: 12px;
}

.admin-tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.6rem 1.2rem;
    border-radius: 9px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.admin-tab-btn.active {
    background: var(--primary);
    color: #fff;
}

.btn-export {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    border: none;
    color: var(--text-primary);
    font-weight: 700;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 12px rgba(201, 188, 72, 0.2);
}

.btn-export:hover:not(:disabled) {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 6px 15px rgba(96, 134, 79, 0.2);
}

.btn-export:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

.admin-panel-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* Tabla Estilo Admin */
.responsive-table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    min-width: 600px;
}

th, td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(96, 134, 79, 0.08);
}

th {
    font-weight: 700;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tr:last-child td {
    border-bottom: none;
}

.user-row {
    cursor: pointer;
    transition: var(--transition);
}

.user-row:hover {
    background: rgba(96, 134, 79, 0.02);
}

.expanded-details {
    background: rgba(96, 134, 79, 0.01);
    border-bottom: 1px solid rgba(96, 134, 79, 0.08);
}

.expanded-container {
    padding: 1.5rem 2rem;
    animation: slideDown 0.3s ease-out;
}

.expanded-title {
    font-weight: 800;
    margin-bottom: 1rem;
    color: var(--primary);
    font-size: 0.95rem;
}

.votes-subgrid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.vote-mini-card {
    background: #fffdf9;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 1rem;
}

.vote-mini-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.vote-mini-teams {
    display: flex;
    justify-content: space-between;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.vote-mini-prediction {
    font-size: 0.8rem;
    color: var(--primary);
    text-align: center;
    background: rgba(96, 134, 79, 0.06);
    padding: 0.25rem;
    border-radius: 6px;
    font-weight: 600;
}

/* Checkboxes Personalizados */
.custom-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* ==========================================================================
   Modales y Diálogos de Confirmación Personalizados
   ========================================================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(37, 49, 32, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: #ffffff;
    border: 1px solid var(--border-light);
    box-shadow: 0 20px 40px -10px rgba(37, 49, 32, 0.25);
    border-radius: 24px;
    padding: 2rem;
    width: 90%;
    max-width: 440px;
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-title {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 0.75rem;
}

.modal-text {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 1.75rem;
}

.modal-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.btn-modal {
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

.btn-modal-cancel {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.btn-modal-cancel:hover {
    background: rgba(0, 0, 0, 0.1);
}

.btn-modal-confirm {
    background: var(--accent);
    color: var(--text-primary);
}

.btn-modal-confirm:hover {
    background: var(--primary);
    color: #fff;
}

/* ==========================================================================
   Animaciones
   ========================================================================== */

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    header {
        padding: 1rem;
    }
    
    .header-container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .user-nav-info {
        width: 100%;
        justify-content: space-between;
    }
    
    main {
        padding: 1.5rem 1rem;
    }
    
    .board-info h1 {
        font-size: 1.75rem;
    }
    
    .matches-grid {
        grid-template-columns: 1fr;
    }
    
    .admin-actions-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-container {
        max-width: none;
    }
    
    .admin-tab-nav {
        justify-content: center;
    }
}
