:root {
    --bg-dark: #121212;
    --bg-panel: #1a1a1a;
    --bg-card: #222222;
    --bg-card-hover: #2a2a2a;
    --accent-green: #4caf50;
    --text-main: #f0f0f0;
    --text-dim: #a0a0a0;
    --border-color: #2c2c2c;
    
    /* Podio Colors */
    --gold: #ffd700;
    --silver: #b0b0b0;
    --bronze: #cd7f32;
}

body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
}


/* LOADING SCREEN */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-dark);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

.loading-screen p {
    color: var(--text-main);
    font-size: 1.2rem;
    font-weight: 500;
}

.loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--accent-green);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* INTERFAZ FLOTANTE SUPERPUESTA (HUD) */
#floating-controls {
    position: fixed;
    top: 15px;
    left: 0;
    width: 100%;
    height: 0; 
    pointer-events: none;
    z-index: 5000; /* Prioridad máxima sobre el mapa */
}

.hud-tabs {
    pointer-events: auto;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

/* Selector de Año Integrado en Sidebar */
.year-picker-hud {
    background-color: transparent;
    border: none;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin-bottom: 20px;
}

.hud-label {
    display: none;
}

.picker-row {
    display: flex;
    align-items: center;
    gap: 15px;
}

#year-display {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-main);
    min-width: 80px;
    text-align: center;
    letter-spacing: 2px;
}

.hud-arrow-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-dim);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.2s;
}

.hud-arrow-btn:hover {
    background-color: var(--accent-green);
    color: #000;
    border-color: var(--accent-green);
}

/* Esquina Superior Derecha: Botones de Pestañas */
.hud-tabs {
    position: absolute;
    top: 0;
    right: 15px;
    display: flex;
    background-color: rgba(26, 26, 26, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 4px;
    backdrop-filter: blur(8px);
}

.hud-tab-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.hud-tab-btn:hover {
    color: #fff;
}

.hud-tab-btn.active {
    background-color: var(--accent-green);
    color: #fff;
}

/* ESTRUCTURA DE PANTALLAS COMPLETA (HUD VIEWS) */
#main-container {
    margin-top: 0;
    height: 100vh;
    position: relative;
    width: 100%;
}

.view {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    opacity: 1;
    transform: translateY(0);
}

.view.hidden {
    display: none !important;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
}

.view:not(.hidden) {
    opacity: 1;
    transform: translateY(0);
}

/* DISTRIBUCIÓN EN ESCRITORIO */
#sidebar {
    position: absolute;
    top: 0;
    left: 0;
    width: 350px;
    height: 100%;
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    padding: 20px;
    padding-top: 60px;
    box-sizing: border-box;
    overflow-y: auto;
    z-index: 4000;
}

#sidebar h1 {
    font-size: 1.3rem;
    margin-top: 0;
    margin-bottom: 20px;
    color: #fff;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

#map {
    position: absolute;
    top: 0;
    left: 350px;
    width: calc(100% - 350px);
    height: 100%;
    background-color: var(--bg-dark);
    z-index: 10;
}

.leaflet-top.leaflet-left {
    top: inherit !important;
    bottom: 25px !important;
    left: inherit !important;
    right: 25px !important;
}

/* ELEMENTOS DE DETALLES DE VOTACIÓN */
.placeholder {
    color: var(--text-dim);
    text-align: center;
    font-style: italic;
    margin-top: 30px;
    font-size: 0.95rem;
}

.vote-item {
    background-color: var(--bg-card);
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.vote-item span:first-child {
    font-weight: 500;
    font-size: 0.95rem;
}

.vote-item .points {
    color: var(--accent-green);
    font-weight: 700;
    background: rgba(76, 175, 80, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.9rem;
}

/* SECCIÓN LEADERBOARD (VISTA DE DATOS) */
#data-view {
    background-color: var(--bg-dark);
    overflow-y: auto;
    padding: 100px 15px 40px 15px;
    box-sizing: border-box;
}

.leaderboard-container {
    width: 100%;
    max-width: 750px;
    margin: 0 auto;
}

.leaderboard-header {
    margin-bottom: 25px;
    display: flex;
    justify-content: flex-start;
    width: 100%;
}

/* SELECTOR DE RONDAS EN DATOS */
.round-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 5px;
    background-color: rgba(26, 26, 26, 0.6);
    padding: 6px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    width: fit-content;
}

.round-tab-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.round-tab-btn:hover {
    color: var(--text-main);
    background-color: rgba(255, 255, 255, 0.05);
}

.round-tab-btn.active {
    background-color: var(--accent-green);
    color: #000;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

#leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* AJUSTES DE TARJETAS DE CLASIFICACIÓN */
.leaderboard-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    transition: transform 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.leaderboard-card:hover {
    border-color: #444;
    background-color: var(--bg-card-hover);
    transform: translateY(-1px);
}

.card-main {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
    min-width: 0;
}

.card-scores-grid {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-shrink: 0;
    text-align: right;
}

.score-block {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.total-block {
    min-width: 90px;
}

.split-block {
    min-width: 80px;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    padding-left: 16px;
}

.score-label {
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--text-dim);
    letter-spacing: 0.5px;
    margin-bottom: 2px;
    text-transform: uppercase;
}

.score-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
}

.score-value.split-val {
    font-size: 0.95rem;
    font-weight: 500;
    color: #d0d0d0;
}

@media (max-width: 600px) {
    .leaderboard-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .card-scores-grid {
        width: 100%;
        justify-content: space-between;
        gap: 10px;
        padding-top: 8px;
        border-top: 1px solid rgba(255, 255, 255, 0.05);
        text-align: left;
    }
    
    .split-block {
        border-left: none;
        padding-left: 0;
    }
}

.rank {
    width: 32px;
    height: 32px;
    background-color: #2a2a2a;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-dim);
}

.leaderboard-card:nth-child(1) { border-left: 4px solid var(--gold); }
.leaderboard-card:nth-child(2) { border-left: 4px solid var(--silver); }
.leaderboard-card:nth-child(3) { border-left: 4px solid var(--bronze); }

.country-info-card {
    display: flex;
    flex-direction: column;
}

.country-name {
    font-size: 1.05rem;
    font-weight: 600;
    color: #fff;
}

.artist-name {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-top: 2px;
}

.total-points {
    font-size: 1.05rem;
    font-weight: 700;
}
.total-points.rank-gold { color: var(--gold); }
.total-points.rank-silver { color: var(--silver); }
.total-points.rank-bronze { color: var(--bronze); }

/* ADAPTACIÓN EN MÓVILES */
@media (max-width: 768px) {
    #floating-controls {
        top: 10px;
    }
    
    #sidebar {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 50vh;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding-top: 15px; 
        z-index: 4000;
        display: flex;
        flex-direction: column;
    }

    #map {
        position: absolute;
        top: 50vh;
        left: 0;
        width: 100%;
        height: 50vh;
        z-index: 10;
    }
    
    .hud-tabs {
        right: 10px;
    }
    
    #year-display {
        font-size: 1.5rem;
        min-width: 50px;
    }
    
    .hud-tab-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
}
#btn-wld {
    margin-right: 5px;
    border-right: 1px solid var(--border-color);
    border-radius: 20px 0 0 20px;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}
#btn-wld.hidden {
    display: none;
}

/* VOTE DIRECTION TOGGLE */
.vote-direction-toggle {
    display: flex;
    margin: 10px 0 15px 0;
    background: #333;
    border-radius: 6px;
    overflow: hidden;
}
.vote-direction-toggle.hidden {
    display: none;
}
.vote-dir-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 6px 0;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: 0.2s;
}
.vote-dir-btn.active {
    background: var(--accent-green);
    color: #fff;
}

/* SIDEBAR SEARCH */
.sidebar-search {
    margin-bottom: 15px;
}
#country-search {
    width: 100%;
    padding: 8px;
    background-color: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
}

/* EDITION SUMMARY (DATA VIEW) */
.edition-summary {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 15px 20px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 20px;
}
.edition-summary img {
    max-width: 100px;
    max-height: 80px;
    object-fit: contain;
}
.edition-summary-info h3 {
    margin: 0 0 5px 0;
    color: var(--accent-green);
    font-size: 1.2rem;
}
.edition-summary-info p {
    margin: 0;
    color: var(--text-dim);
    font-size: 0.9rem;
    line-height: 1.4;
}

/* MODAL */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 6000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}
.modal.hidden {
    display: none;
}
.modal-content {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    padding: 25px;
}
.close-modal {
    position: absolute;
    top: 15px; right: 20px;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--text-dim);
}
.close-modal:hover { color: #fff; }

#modal-header { margin-bottom: 20px; border-bottom: 1px solid var(--border-color); padding-bottom: 15px; }
#modal-title { margin: 0 0 5px 0; font-size: 1.5rem; color: var(--accent-green); }
#modal-subtitle { margin: 0; font-size: 1.1rem; font-style: italic; color: var(--text-dim); font-weight: normal; }

.modal-video-container {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    margin-bottom: 20px;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}
.modal-video-container iframe {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
}

.modal-details {
    display: flex;
    gap: 20px;
}
#modal-info {
    flex: 1;
    font-size: 0.9rem;
    color: #ccc;
    line-height: 1.6;
}
#modal-info strong { color: #fff; }

.lyrics-container {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
}
.lyrics-controls {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.lyrics-controls select {
    background: #333; color: #fff; border: 1px solid #555; padding: 4px; border-radius: 4px;
}
#modal-lyrics {
    flex: 1;
    overflow-y: auto;
    max-height: 300px;
    white-space: pre-wrap;
    font-size: 0.85rem;
    color: #ddd;
    line-height: 1.5;
    padding-right: 10px;
}

@media (max-width: 768px) {
    .modal-details { flex-direction: column; }
    .edition-summary { flex-direction: column; align-items: flex-start; text-align: left; }
}

.leaderboard-card { cursor: pointer; }


.data-view-year-picker {
    background-color: transparent;
    border: none;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0;
    margin-bottom: 20px;
}

/* LEADERBOARD & DETAILS SPLIT LAYOUT */
#data-view {
    display: flex;
    flex-direction: column;
    padding: 30px 15px 40px 15px; /* Reducido espacio superior */
    box-sizing: border-box;
    overflow-y: auto;
    overflow-x: hidden;
    background-color: var(--bg-dark); /* Ensure background is dark */
}

.data-layout-wrapper {
    display: flex;
    gap: 20px;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    transition: all 0.3s ease;
    align-items: flex-start;
}

.leaderboard-container {
    flex: 1;
    width: 100%;
    transition: all 0.3s ease;
}

.leaderboard-container.split-mode {
    flex: 0 0 45%;
    max-width: 45%;
}


/* SONG DETAILS PANEL (RIGHT SIDE) */
/* SONG DETAILS PANEL (RIGHT SIDE) */
.song-details-panel {
    flex: 1;
    display: none;
    flex-direction: column;
    background-color: transparent;
    padding: 0;
}

.song-details-panel.active {
    display: flex;
}



.details-title h2 {
    margin: 0 0 5px 0;
    color: var(--accent-green);
    font-size: 1.3rem;
}

.details-title h3 {
    margin: 0;
    color: var(--text-main);
    font-size: 1.1rem;
    font-weight: 500;
}

.close-details {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
    padding: 0 5px;
}

.close-details:hover {
    color: #fff;
}

/* Make the video sticky relative to the whole viewport when scrolling down */

.details-video-wrapper {
    position: relative;
    margin-bottom: 20px;
}


.details-video-container {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

.details-video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.details-lyrics-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.details-lyrics-container h4 {
    margin: 0 0 10px 0;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.85rem;
}

.lyrics-text {
    flex: 1;
    white-space: pre-wrap;
    font-size: 0.95rem;
    color: #e0e0e0;
    line-height: 1.6;
    padding-right: 10px;
    /* Quitamos el overflow-y para que la letra expanda el div entero hacia abajo */
}

@media (max-width: 900px) {
    .data-layout-wrapper {
        flex-direction: column;
    }
    .leaderboard-container.split-mode {
        flex: auto;
        max-width: 100%;
    }
    .song-details-panel {
        height: auto;
        position: relative;
        top: 0;
    }
}


.details-header {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.details-lyrics-container {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
}


.details-video-wrapper {
    position: relative;
    margin-bottom: 20px;
}


.details-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.details-video-wrapper {
    position: relative;
    margin-bottom: 20px;
}


@media (max-width: 900px) {
    .details-video-wrapper {
    position: relative;
    margin-bottom: 20px;
}
}

/* Fix Hebrew and Arabic lyrics alignment if they use custom classes */
.lyrics_right {
    display: block;
    direction: rtl;
    text-align: right;
    font-weight: bold;
    color: var(--accent-green);
    margin-top: 5px;
}
