/* Estilos específicos para el marcador de Minivoleibol Online */

/* --- Estilos Base --- */
body {
    background: linear-gradient(135deg, #6a11cb, #2575fc);
    color: #ecf0f1;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
}

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

/* --- Modo Solo Lectura (Ocultar controles) --- */
.score-controls, 
.match-controls, 
.input-group button,
.btn-new-set,
.btn-reset,
.btn-save { 
    display: none !important; 
}

.editable { 
    pointer-events: none; 
}

#match-location-display { 
    font-size: 1.1rem; 
    font-weight: bold; 
    color: #f1c40f; 
}

/* --- Estado de Conexión --- */
.connection-status {
    text-align: center;
    padding: 10px;
    margin-bottom: 15px;
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #bdc3c7; /* Gris por defecto (desconectado) */
    box-shadow: 0 0 5px rgba(189, 195, 199, 0.5);
    transition: all 0.5s ease;
}

/* --- Latency Indicators --- */
.status-dot.good {
    background-color: #2ecc71; /* Verde */
    box-shadow: 0 0 8px rgba(46, 204, 113, 0.7);
}

.status-dot.laggy {
    background-color: #f39c12; /* Naranja */
    box-shadow: 0 0 8px rgba(243, 156, 18, 0.7);
}

.status-dot.bad {
    background-color: #e74c3c; /* Rojo */
    box-shadow: 0 0 8px rgba(231, 76, 60, 0.7);
}

/* --- Optimizaciones para Móviles (Portrait) --- */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    /* Header simplificado */
    .app-header {
        min-height: auto;
        margin-bottom: 15px;
        padding: 0;
    }

    .header-content {
        padding: 15px;
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .header-left h1 {
        font-size: 1.5rem;
        margin: 0;
    }

    .header-left .subtitle {
        font-size: 0.9rem;
        margin-top: 5px;
    }

    /* Ocultar elementos no esenciales para ganar espacio */
    .floating-home-btn {
        display: none;
    }

    .header-bg {
        opacity: 0.3;
    }

    /* Marcador más compacto */
    .scoreboard-minivoley {
        gap: 10px;
        margin-bottom: 15px;
    }

    .team-minivoley {
        padding: 15px 10px;
    }

    .team-name-minivoley {
        font-size: 1.1rem;
        min-height: auto;
    }

    .score-minivoley {
        font-size: 4rem;
        margin: 10px 0;
    }

    /* Botones de compartir más pequeños */
    .btn-icon {
        min-width: 60px;
        height: 60px;
        font-size: 0.7rem;
        padding: 8px;
    }

    .btn-icon i {
        font-size: 1.4rem;
    }
}

/* --- Modo Pantalla Completa / Horizontal (Landscape) --- */
@media (max-width: 900px) and (orientation: landscape) {
    body {
        padding: 5px;
    }

    /* Ocultar todo excepto el marcador y la info esencial */
    .app-header, 
    .control-group, 
    footer,
    .floating-home-btn {
        display: none !important;
    }

    .scoreboard-minivoley {
        height: 85vh; /* Ocupar casi toda la altura */
        margin: 0;
        align-items: center;
    }

    .team-minivoley {
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .score-minivoley {
        font-size: 20vh; /* Escalar con la altura de la pantalla */
    }
    
    .current-set-info-minivoley {
        margin-bottom: 5px;
        padding: 5px;
    }
}

/* --- Botón de Tema (Claro/Oscuro) --- */
.theme-toggle-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s ease;
    font-size: 1.2rem;
}

.theme-toggle-btn:hover {
    background: rgba(0, 0, 0, 0.5);
    transform: scale(1.1);
}

/* --- Estilos Modo Claro --- */
body.light-mode {
    background: linear-gradient(135deg, #f5f7fa, #c3cfe2);
    color: #2c3e50;
}

body.light-mode .scoreboard-minivoley .team-minivoley {
    background-color: rgba(255, 255, 255, 0.9);
    color: #2c3e50;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

body.light-mode .current-set-info-minivoley {
    background-color: rgba(255, 255, 255, 0.8);
    color: #2c3e50;
    border: 1px solid rgba(0,0,0,0.1);
}

body.light-mode .connection-status {
    background: rgba(255, 255, 255, 0.6);
    color: #2c3e50;
    border: 1px solid rgba(0,0,0,0.1);
}

body.light-mode #match-location-display {
    color: #d35400;
}

body.light-mode .theme-toggle-btn {
    background: rgba(255, 255, 255, 0.8);
    color: #f39c12;
    border-color: rgba(0,0,0,0.1);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* Ajuste posición botón en móvil */
@media (max-width: 768px) {
    .theme-toggle-btn {
        top: 15px;
        right: 15px;
        width: 40px;
        height: 40px;
    }
}

/* --- Toast Notification for Points --- */
.toast-notification {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(44, 62, 80, 0.95);
    color: white;
    padding: 15px 25px;
    border-radius: 25px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    z-index: 1002;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.1rem;
    font-weight: bold;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease, bottom 0.4s ease;
    backdrop-filter: blur(5px);
}

.toast-notification.show {
    opacity: 1;
    visibility: visible;
    bottom: 50px;
}

.toast-notification i {
    font-size: 1.3rem;
    color: #f1c40f; /* Amarillo para puntos */
}

body.light-mode .toast-notification {
    background-color: rgba(255, 255, 255, 0.95);
    color: #2c3e50;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
}

body.light-mode .toast-notification i {
    color: #d35400;
}

/* --- Host Message Toast --- */
.toast-notification.host-message {
    background-color: #e67e22; /* Naranja para mensajes del host */
    z-index: 1003; /* Por encima de puntos */
    bottom: 80px; /* Apilar si aparecen ambos */
}

/* --- Historial de Eventos --- */
.history-section {
    margin: 20px 0;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

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

.history-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #ecf0f1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-list {
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column-reverse; /* Lo más nuevo arriba */
    gap: 8px;
}

.history-item {
    display: flex;
    align-items: center;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    font-size: 0.9rem;
    animation: slideInLeft 0.3s ease;
    border-left: 3px solid transparent;
}

.history-item.point { border-left-color: #3498db; }
.history-item.set { border-left-color: #f1c40f; background: rgba(241, 196, 15, 0.1); }
.history-item.match { border-left-color: #e74c3c; background: rgba(231, 76, 60, 0.1); }

.history-time {
    font-family: monospace;
    opacity: 0.7;
    margin-right: 10px;
    font-size: 0.8rem;
    min-width: 45px;
}

.history-content {
    flex: 1;
}

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

/* Ajustes Modo Claro para Historial */
body.light-mode .history-section {
    background: rgba(255, 255, 255, 0.6);
    border-color: rgba(0, 0, 0, 0.1);
}

body.light-mode .history-header h3 {
    color: #2c3e50;
}

body.light-mode .history-item {
    background: rgba(255, 255, 255, 0.5);
    color: #2c3e50;
}

body.light-mode .history-item.set { background: rgba(241, 196, 15, 0.2); }
body.light-mode .history-item.match { background: rgba(231, 76, 60, 0.2); }

/* --- Gráfica de Evolución --- */
.chart-section {
    margin: 20px 0;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.chart-container {
    position: relative;
    height: 250px;
    width: 100%;
}

body.light-mode .chart-section {
    background: rgba(255, 255, 255, 0.6);
    border-color: rgba(0, 0, 0, 0.1);
}

/* --- Final Summary Overlay --- */
.final-summary-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s ease;
    backdrop-filter: blur(8px);
}

.final-summary-overlay.active {
    opacity: 1;
    visibility: visible;
}

.final-card {
    background: linear-gradient(135deg, #2c3e50, #3498db);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    max-width: 90%;
    width: 400px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transform: scale(0.8);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    color: white;
}

.final-summary-overlay.active .final-card {
    transform: scale(1);
}

.final-card h2 {
    font-size: 2rem;
    margin-bottom: 10px;
    color: #f1c40f;
}

.final-winner {
    font-size: 1.5rem;
    font-weight: bold;
    margin: 20px 0;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.final-score {
    font-size: 3rem;
    font-weight: bold;
    margin-bottom: 20px;
}

/* --- Landing View (Entrada Manual) --- */
.landing-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
    animation: fadeIn 0.5s ease;
}

.landing-card {
    background: rgba(255, 255, 255, 0.1);
    padding: 40px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    max-width: 500px;
    width: 90%;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
}

.landing-card h2 {
    margin-bottom: 20px;
    color: #fff;
    font-size: 1.8rem;
}

.input-group-landing {
    display: flex;
    gap: 10px;
    margin: 25px 0;
    flex-wrap: wrap;
}

.input-group-landing input {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    font-size: 1rem;
    min-width: 200px;
}

.landing-note {
    font-size: 0.9rem;
    opacity: 0.8;
    margin-top: 20px;
}

.hidden {
    display: none !important;
}

/* --- Botón de Reconexión --- */
.btn-reconnect {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    margin-left: 8px;
    transition: all 0.3s ease;
}

.btn-reconnect:hover {
    background: rgba(255, 255, 255, 0.4);
}