/* Reset y configuración base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: #4a5568;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.header h1 i {
    color: #f6ad55;
    margin-right: 15px;
}

.competition-period {
    font-size: 1.2rem;
    color: #718096;
    margin-bottom: 20px;
}

.progress-bar {
    position: relative;
    background: #e2e8f0;
    border-radius: 25px;
    height: 10px;
    margin: 20px 0;
    overflow: hidden;
}

.progress-fill {
    background: linear-gradient(90deg, #38b2ac, #4fd1c7);
    height: 100%;
    width: 25%; /* Ajustar según el progreso real */
    border-radius: 25px;
    animation: pulse 2s infinite;
}

.progress-text {
    font-size: 0.9rem;
    color: #4a5568;
    font-weight: 500;
}

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

/* Podio */
.podium-section {
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 20px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.podium-section h2 {
    text-align: center;
    font-size: 1.8rem;
    color: #4a5568;
    margin-bottom: 25px;
}

.podium {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 10px;
    margin: 20px 0;
}

.podium-place {
    text-align: center;
    background: linear-gradient(145deg, #f7fafc, #edf2f7);
    border-radius: 15px;
    padding: 15px 12px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.podium-place:hover {
    transform: translateY(-5px);
}

.podium-place.first {
    height: 180px;
    width: 160px;
    background: linear-gradient(145deg, #ffd700, #ffed4a);
}

.podium-place.second {
    height: 150px;
    width: 140px;
    background: linear-gradient(145deg, #c0c0c0, #e2e8f0);
}

.podium-place.third {
    height: 120px;
    width: 160px;
    background: linear-gradient(145deg, #cd7f32, #ed8936);
}

.medal {
    font-size: 2.2rem;
    margin-bottom: 8px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.5));
}

.medal.gold { 
    color: #b8860b; /* Dorado más oscuro para mejor contraste */
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.4);
}

.medal.silver { 
    color: #708090; /* Plata más oscura para mejor contraste */
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.4);
}

.medal.bronze { 
    color: #8B4513; /* Bronce más oscuro para mejor contraste */
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.4);
}

.participant-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: #2d3748;
    margin-bottom: 5px;
    text-align: center;
    line-height: 1.2;
    word-wrap: break-word;
    hyphens: auto;
    max-width: 100%;
    padding: 0 8px;
    overflow-wrap: break-word;
}

.participant-score {
    font-weight: 700;
    font-size: 1.1rem;
    color: #2b6cb0;
}

/* Secciones de gráficos - CRÍTICO: Altura máxima 400px, mismo tamaño */
.chart-section {
    background: rgba(255, 255, 255, 0.95);
    padding: 25px;
    border-radius: 20px;
    margin-bottom: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.chart-section h2 {
    text-align: center;
    font-size: 1.6rem;
    color: #4a5568;
    margin-bottom: 20px;
}

/* CRÍTICO: Contenedores de gráficos con altura fija de 400px */
.chart-container {
    height: 400px !important;
    width: 100%;
    position: relative;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-container canvas {
    max-height: 380px !important;
    width: 100% !important;
    height: 380px !important;
}

/* Tabla de resultados */
.results-section {
    background: rgba(255, 255, 255, 0.95);
    padding: 25px;
    border-radius: 20px;
    margin-bottom: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.results-section h2 {
    text-align: center;
    font-size: 1.6rem;
    color: #4a5568;
    margin-bottom: 10px;
}

.editing-instructions {
    text-align: center;
    color: #718096;
    font-size: 0.9rem;
    margin-bottom: 20px;
    padding: 10px;
    background: rgba(66, 153, 225, 0.1);
    border-radius: 8px;
    border-left: 4px solid #4299e1;
}

.editing-instructions i {
    color: #4299e1;
    margin-right: 5px;
}

/* Nombres de participantes clickeables */
.participant-name {
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 8px 12px !important;
    border-radius: 8px;
    position: relative;
}

.participant-name:hover {
    background: rgba(66, 153, 225, 0.1);
    color: #2b6cb0;
    transform: translateX(3px);
}

.participant-name.editing-active {
    background: linear-gradient(145deg, #e6fffa, #b2f5ea);
    color: #00695c;
    font-weight: 600;
    border-left: 4px solid #38a169;
}

.participant-name.editing-active::after {
    content: '💾 Clic para guardar';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    color: #38a169;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.9);
    padding: 2px 6px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.participant-name.saved-changes {
    background: linear-gradient(145deg, #c6f6d5, #9ae6b4) !important;
    animation: savedPulse 1.5s ease-out;
}

.participant-name.saved-changes::after {
    content: '✅ Guardado';
    color: #22543d;
    font-weight: 600;
}

@keyframes savedPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(56, 161, 105, 0.4);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 0 0 10px rgba(56, 161, 105, 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(56, 161, 105, 0);
    }
}

/* Indicador sutil para mostrar que los nombres son clickeables */
.participant-name::before {
    content: '';
    margin-right: 0px;
}

.participant-name:hover::before {
    content: '';
}

.table-container {
    overflow-x: auto;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.results-table th,
.results-table td {
    padding: 12px 8px;
    text-align: center;
    border-bottom: 1px solid #e2e8f0;
}

.results-table th {
    background: linear-gradient(145deg, #4299e1, #3182ce);
    color: white;
    font-weight: 600;
    position: sticky;
    top: 0;
}

.results-table tr:nth-child(even) {
    background: #f8fafc;
}

.results-table tr:hover {
    background: #e6fffa;
    transform: scale(1.01);
    transition: all 0.2s ease;
}

.total-column {
    background: linear-gradient(145deg, #38a169, #2f855a) !important;
    font-weight: 700;
}

/* Estilos para campos editables en la tabla */
.score-input {
    width: 50px;
    padding: 5px;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    background: white;
    transition: all 0.2s ease;
}

/* Contenedor para campos con tooltips */
.results-table td {
    position: relative;
}

.score-input:focus {
    outline: none;
    border-color: #4299e1;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
    background: #f0f8ff;
}

.score-input:hover {
    border-color: #cbd5e0;
    background: #f8fafc;
}

/* Resaltado cuando se está editando */
.score-input.editing {
    border-color: #38a169;
    box-shadow: 0 0 0 3px rgba(56, 161, 105, 0.2);
    background: #f0fff4;
}

/* Inputs en modo solo lectura (apariencia de solo lectura pero funcional para controles) */
.score-input.readonly {
    background: #f7fafc;
    border-color: #e2e8f0;
    color: #4a5568;
    cursor: default;
    opacity: 0.9;
    text-align: center;
    font-weight: 600;
}

.score-input.readonly:focus {
    outline: none;
    box-shadow: none;
    border-color: #e2e8f0;
}

.score-input.readonly:hover {
    background: #f7fafc;
    border-color: #e2e8f0;
}

/* Inputs habilitados para edición de fila específica */
.score-input.row-editable {
    background: #f0fff4;
    border-color: #38a169;
    color: #22543d;
    cursor: default;
    position: relative;
}

.score-input.row-editable:focus {
    border-color: #38a169;
    box-shadow: 0 0 0 2px rgba(56, 161, 105, 0.2);
    background: #f0fff4;
}

.score-input.row-editable:hover {
    background: #e6fffa;
    border-color: #2f855a;
}

/* Indicador de cambio detectado */
.score-input.has-changes {
    background: #fff5e6 !important;
    border-color: #d69e2e !important;
    color: #744210 !important;
    font-weight: 600;
}

.score-input.has-changes:focus {
    border-color: #d69e2e !important;
    box-shadow: 0 0 0 2px rgba(214, 158, 46, 0.2) !important;
}

/* Animación para cambios guardados */
.score-input.saved {
    border-color: #38a169;
    background: #f0fff4;
    animation: saveHighlight 1s ease-out;
}

@keyframes saveHighlight {
    0% {
        background: #c6f6d5;
        transform: scale(1.05);
    }
    100% {
        background: #f0fff4;
        transform: scale(1);
    }
}

/* Estilos para total actualizado */
.total-score.updated {
    animation: totalUpdate 0.5s ease-out;
}

@keyframes totalUpdate {
    0% {
        transform: scale(1.1);
        background: #fed7d7;
    }
    100% {
        transform: scale(1);
        background: transparent;
    }
}

/* Animación para actualización de puntos de métodos */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
        color: #4299e1;
    }
}

/* Tooltip para mostrar incrementos */
.increment-tooltip {
    position: absolute;
    top: -25px;
    right: -5px;
    background: #38a169;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: bold;
    display: none;
    z-index: 1000;
    animation: tooltipFadeIn 0.3s ease-out;
}

.increment-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 3px solid transparent;
    border-top-color: #38a169;
}

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

/* Gráficos individuales por participante */
.individual-charts-section {
    margin-top: 30px;
    padding-top: 25px;
    border-top: 2px solid #e2e8f0;
}

.individual-charts-section h3 {
    text-align: center;
    font-size: 1.4rem;
    color: #4a5568;
    margin-bottom: 25px;
    font-weight: 600;
}

.individual-charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 25px;
    margin-top: 20px;
}

.participant-chart-card {
    background: linear-gradient(145deg, #f8fafc, #edf2f7);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.participant-chart-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
    border-color: #4299e1;
}

.participant-chart-card.rank-1 {
    background: linear-gradient(145deg, #fff8dc, #ffd700);
    border-color: #ffd700;
}

.participant-chart-card.rank-2 {
    background: linear-gradient(145deg, #f5f5f5, #c0c0c0);
    border-color: #c0c0c0;
}

.participant-chart-card.rank-3 {
    background: linear-gradient(145deg, #ffeaa7, #cd7f32);
    border-color: #cd7f32;
}

.participant-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.participant-name-header {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2d3748;
    display: flex;
    align-items: center;
    gap: 8px;
}

.participant-total-score {
    font-size: 1.3rem;
    font-weight: 700;
    color: #2b6cb0;
    display: flex;
    align-items: center;
    gap: 5px;
}

.rank-icon {
    font-size: 1.2rem;
}

.rank-icon.rank-1 { color: #ffd700; }
.rank-icon.rank-2 { color: #c0c0c0; }
.rank-icon.rank-3 { color: #cd7f32; }

.participant-chart-container {
    height: 250px !important;
    width: 100%;
    position: relative;
    margin: 0 auto;
}

.participant-chart-container canvas {
    max-height: 230px !important;
    width: 100% !important;
    height: 230px !important;
}



/* Información de métodos */
.methods-info {
    background: rgba(255, 255, 255, 0.95);
    padding: 25px;
    border-radius: 20px;
    margin-bottom: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.methods-info h2 {
    text-align: center;
    font-size: 1.6rem;
    color: #4a5568;
    margin-bottom: 25px;
}

.methods-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 20px;
    max-width: 1000px;
    margin: 0 auto;
}

.method-card {
    background: linear-gradient(145deg, #f7fafc, #edf2f7);
    padding: 20px;
    border-radius: 15px;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 2px solid transparent;
}

.method-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    border-color: #4299e1;
}

.method-card i {
    font-size: 2rem;
    color: #4299e1;
    margin-bottom: 10px;
}

.method-card h3 {
    font-size: 1.1rem;
    color: #2d3748;
    margin-bottom: 8px;
    font-weight: 600;
}

.method-card p {
    font-size: 0.9rem;
    color: #718096;
    margin-bottom: 10px;
}

/* Estilos para reglas de puntuación */
.points-rule {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    margin: 8px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
}

.points-rule:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.points-rule i {
    color: #ffd700;
    font-size: 0.9rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.rule-text {
    text-align: center;
    line-height: 1.2;
}

/* Estilos para los puntos de los métodos */
.method-points {
    background: linear-gradient(135deg, #4299e1, #3182ce);
    color: white;
    padding: 10px 15px;
    border-radius: 20px;
    text-align: center;
    margin-top: auto;
    box-shadow: 0 4px 10px rgba(66, 153, 225, 0.3);
    transition: all 0.3s ease;
}

.method-card:hover .method-points {
    transform: scale(1.05);
    box-shadow: 0 6px 15px rgba(66, 153, 225, 0.4);
}

.points-number {
    font-size: 1.4rem;
    font-weight: 700;
    display: block;
    line-height: 1;
}

.points-label {
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.9;
}

/* Colores específicos para cada método */
#points-boca .method-points { 
    background: linear-gradient(135deg, #4299e1, #3182ce); 
}

#points-tarjeta .method-points { 
    background: linear-gradient(135deg, #38a169, #2f855a); 
}

#points-bibliatel .method-points { 
    background: linear-gradient(135deg, #ed8936, #dd6b20); 
}

#points-video .method-points { 
    background: linear-gradient(135deg, #e53e3e, #c53030); 
}

#points-carpeta .method-points { 
    background: linear-gradient(135deg, #9f7aea, #805ad5); 
}

#points-biblia .method-points { 
    background: linear-gradient(135deg, #805ad5, #6b46c1); 
}

#points-extra .method-points { 
    background: linear-gradient(135deg, #38b2ac, #319795); 
}

/* Animación para actualización de puntos */
.method-points.updated {
    animation: pointsUpdate 0.6s ease-out;
}

@keyframes pointsUpdate {
    0% {
        transform: scale(1.1);
        box-shadow: 0 8px 20px rgba(66, 153, 225, 0.6);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 4px 10px rgba(66, 153, 225, 0.3);
    }
}

/* Footer */
.footer {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.footer p {
    color: #4a5568;
    margin-bottom: 5px;
}

.footer i {
    color: #e53e3e;
}

.update-time {
    font-size: 0.8rem;
    color: #718096;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    .header h1 {
        font-size: 2rem;
    }

    .podium {
        flex-direction: column;
        align-items: center;
    }

    .podium-place {
        width: 200px;
        height: auto !important;
        min-height: 120px;
        margin-bottom: 15px;
        padding: 15px;
    }

    .podium-place.first,
    .podium-place.second,
    .podium-place.third {
        width: 200px;
        height: auto !important;
    }

    .participant-name {
        font-size: 0.9rem;
        line-height: 1.3;
    }

    .medal {
        font-size: 2rem;
    }

    /* Ajustes para reglas de puntos en tablet */
    .points-rule {
        font-size: 0.75rem;
        padding: 6px 10px;
    }

    .methods-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
    }

    /* Puntos de métodos en tablet */
    .method-points {
        padding: 8px 12px;
    }
    
    .points-number {
        font-size: 1.2rem;
    }
    
    .points-label {
        font-size: 0.65rem;
    }

    /* Mantener altura fija en móviles también */
    .chart-container {
        height: 350px !important;
    }

    .chart-container canvas {
        max-height: 330px !important;
        height: 330px !important;
    }

    /* Gráficos individuales responsivos */
    .individual-charts-grid {
        grid-template-columns: 1fr;
    }

    .participant-chart-container {
        height: 200px !important;
    }

    .participant-chart-container canvas {
        max-height: 180px !important;
        height: 180px !important;
    }

    /* Campos editables en tablet */
    .score-input {
        width: 45px;
        font-size: 0.8rem;
        padding: 4px;
    }
}

@media (max-width: 480px) {
    .chart-container {
        height: 300px !important;
    }

    .chart-container canvas {
        max-height: 280px !important;
        height: 280px !important;
    }

    /* Gráficos individuales más pequeños en móvil */
    .participant-chart-container {
        height: 180px !important;
    }

    .participant-chart-container canvas {
        max-height: 160px !important;
        height: 160px !important;
    }

    /* Estilos responsivos para resultados */
    .results-section h2 {
        font-size: 1.3rem;
    }
    
    .editing-instructions {
        font-size: 0.8rem;
        padding: 8px;
        margin-bottom: 15px;
    }

    /* Campos editables en móvil */
    .score-input {
        width: 40px;
        font-size: 0.75rem;
        padding: 3px;
    }

    .results-table {
        font-size: 0.8rem;
    }

    .results-table th,
    .results-table td {
        padding: 8px 4px;
    }

    /* Podio más compacto en móviles pequeños */
    .podium-place {
        width: 180px;
        min-height: 100px;
        padding: 10px;
    }

    .participant-name {
        font-size: 0.8rem;
        line-height: 1.2;
    }

    .participant-score {
        font-size: 1rem;
    }

    .medal {
        font-size: 1.8rem;
        margin-bottom: 5px;
    }

    /* Ajustes para reglas de puntos en móvil */
    .points-rule {
        font-size: 0.7rem;
        padding: 5px 8px;
        margin: 6px 0;
    }

    .rule-text {
        line-height: 1.1;
    }

    /* Grid de métodos en móvil - cambiar a columna única */
    .methods-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        gap: 15px;
    }

    /* Puntos de métodos en móvil pequeño */
    .method-points {
        padding: 6px 10px;
    }
    
    .points-number {
        font-size: 1rem;
    }
    
    .points-label {
        font-size: 0.6rem;
    }
}

/* 🔄 SYNC ANIMATIONS FOR CROSS-DEVICE FUNCTIONALITY */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Sync indicator styles */
.sync-indicator {
    animation: slideIn 0.3s ease-out;
}

.error-message {
    animation: slideIn 0.3s ease-out;
}