/* General Body and HTML Styles */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #333;
    background-color: #f0f2f5; /* Light grey background */
    overflow: hidden; /* Prevent body scroll, map handles its own */
    font-size: 14px; /* Pienempi perusfonttikoko */
}

/* Map Container */
#mapid {
    height: 100%;
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1; /* Map is below other UI elements */
}

/* Main Container for all UI elements */
#main-container {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

#error-message {
    background-color: rgba(200, 0, 0, 0.8);
    color: white;
    display: none;
    font-size: 1em;
}

/* Action Buttons (General Styling) */
.action-button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85em;
    transition: background-color 0.2s ease, transform 0.1s ease;
    white-space: nowrap;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.action-button:hover {
    background-color: #0056b3;
    transform: translateY(-1px);
}

.action-button:active {
    background-color: #004085;
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* Top-left Mobile Buttons Container */
#top-left-mobile-buttons {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    pointer-events: auto;
}

/* Info button on mobile */
#info-button-mobile {
    position: fixed;
    top: 55px;
    right: 10px;
    z-index: 500;
    display: flex;
    background-color: #28a745;
    pointer-events: auto;
}

/* Mobiilin info-painike, kun modaali on avoinna */
#info-button-mobile.active {
    background-color: #dc3545;
    color: white;
}

/* Mobile-only action buttons (e.g., info, geolocation, refresh) */
.action-button.mobile-only {
    padding: 8px 12px;
    font-size: 0.85em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    box-sizing: border-box;
    flex-grow: 0;
    min-width: unset;
    min-height: unset;
    white-space: nowrap;
}

/* Opacity Containers */
/* Yleiset liukusäädinten tyylit, jotka koskevat molempia versioita */
#radar-opacity-container h4, #lightning-opacity-container h4,
#radar-opacity-container-mobile h4, #lightning-opacity-container-mobile h4 {
    margin-top: 0;
    color: #007bff;
    font-size: 1em;
    text-align: center;
}

#radar-opacity-container label, #lightning-opacity-container label,
#radar-opacity-container-mobile label, #lightning-opacity-container-mobile label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.85em;
}

#radar-opacity, #lightning-opacity, #radar-opacity-mobile, #lightning-opacity-mobile {
    width: 100%;
    -webkit-appearance: none;
    height: 8px;
    border-radius: 50%;
    background: #d3d3d3;
    outline: none;
    opacity: 0.7;
    transition: opacity .2s;
}

#radar-opacity::-webkit-slider-thumb, #lightning-opacity::-webkit-slider-thumb,
#radar-opacity-mobile::-webkit-slider-thumb, #lightning-opacity-mobile::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    box-shadow: 0 0 5px rgba(0,0,0,0.2);
}

#radar-opacity::-moz-range-thumb, #lightning-opacity::-moz-range-thumb,
#radar-opacity-mobile::-moz-range-thumb, #lightning-opacity-mobile::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    box-shadow: 0 0 5px rgba(0,0,0,0.2);
}

/* Time Slider Styles */
#time-slider-container {
    padding: 10px;
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 25%;
    max-width: 600px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    z-index: 500;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

@media (max-width: 768px) {
    #time-slider-container {
        width: 50%;
    }
    #time-slider-container p, #time-slider-container span, .time-label {
        font-size: 0.75em;
    }
}


#time-slider-container p, #time-slider-container span {
    margin: 0;
    font-size: 0.85em;
    color: #000;
}

#time-slider {
    width: 100%;
}

#time-labels {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-top: 5px;
    font-size: 0.75em;
    color: #777;
    position: relative;
    height: 10px;
}

.time-tick {
    position: absolute;
    top: -5px;
    width: 1px;
    height: 10px;
    background-color: #000;
    transform: translateX(-50%);
}

#animation-time-display {
    font-weight: bold;
    color: #000;
    font-size: 1.1em;
}

/* Loading spinner */
#loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 15px 30px;
    border-radius: 10px;
    z-index: 1000;
    display: none;
    font-size: 1.1em;
}

/*-----------------------------------------------------------------*/
/* UUSI KORJAUS: INFO PANEELIN TYYLIT                                */
/*-----------------------------------------------------------------*/
.info-panel-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7); /* Tummempi tausta */
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.info-panel-content {
    background-color: white;
    padding: 20px 30px;
    border-radius: 10px;
    max-width: 600px;
    max-height: 90vh; /* Pienempi maksimikorkeus */
    overflow-y: auto;
    position: relative;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    line-height: 1.6;
}

.info-panel-content h2, .info-panel-content h3 {
    color: #007bff;
    border-bottom: 2px solid #007bff;
    padding-bottom: 5px;
}

.info-panel-content ul {
    list-style-type: disc;
    padding-left: 20px;
}

.info-panel-content li {
    margin-bottom: 8px;
}

.info-panel-content .close-button {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: #555;
    transition: color 0.2s ease;
}

.info-panel-content .close-button:hover {
    color: #dc3545;
}


/*-----------------------------------------------------------------*/
/* DESKTOP-STYLES (min-width: 769px)                               */
/*-----------------------------------------------------------------*/
@media (min-width: 769px) {
    body {
        display: flex;
        flex-direction: row;
        height: 100vh;
        overflow: hidden;
    }

    #main-container {
        display: flex;
        pointer-events: none;
    }

    /* Piilota mobiiliset elementit työpöydällä */
    #info-button-mobile, #top-left-mobile-buttons {
        display: none !important;
    }

    /* Left Panel for Title, Buttons, and Radar Opacity */
    #left-panel-container {
        display: flex;
        flex-direction: column;
        width: 300px;
        height: 100%;
        background-color: rgba(255, 255, 255, 0.95);
        box-shadow: 3px 0 10px rgba(0,0,0,0.1);
        z-index: 10;
        padding: 15px;
        box-sizing: border-box;
        pointer-events: auto;
        overflow-y: auto;
        position: relative;
    }

    #page-title {
        color: #007bff;
        font-size: 1.6em;
        text-align: center;
        margin-top: 0;
    }

    #desktop-buttons-container {
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin-top: 20px;
    }

    #radar-opacity-container {
        margin-top: 20px;
    }
    
    #lightning-opacity-container {
        margin-top: 10px;
    }

    /* Right Panel for Statistics and Legend */
    #right-panel-container {
        display: flex;
        flex-direction: column;
        width: 280px;
        height: 100%;
        background-color: rgba(255, 255, 255, 0.95);
        box-shadow: -3px 0 10px rgba(0,0,0,0.1);
        z-index: 10;
        padding: 15px;
        box-sizing: border-box;
        margin-left: auto;
        pointer-events: auto;
        overflow-y: auto;
    }
    #right-panel-container p, #right-panel-container li {
        font-size: 0.9em;
    }

    #statistics-container {
        margin-bottom: 0;
    }
    
    #statistics-container h3, #lightning-statistics h4 {
        color: #333;
        font-size: 1.1em;
        margin-top: 0;
        border-bottom: 2px solid #007bff;
        padding-bottom: 5px;
    }
    
    #lightning-statistics {
        margin-bottom: 10px;
    }
    
    #lightning-statistics ul {
        list-style-type: none;
        padding: 0;
        margin: 0;
    }
    
    #lightning-statistics li {
        margin-bottom: 5px;
    }
    
    #lightning-legend {
        padding-top: 0;
        margin-top: 10px;
    }

    /* Time Slider */
    #time-slider-container {
        width: 50%;
        max-width: 800px;
    }
    
    /* Piilota uusi painike työpöydällä */
    #toggle-mobile-ui-btn {
        display: none !important;
    }
    
    /* Piilota tietoteksti työpöydällä (se on jo modalin ulkopuolella desktop-näkymässä) */
    .info-text-desktop {
        display: block !important;
    }
    
    .desktop-only {
        display: block !important;
    }
    
    .mobile-only {
        display: none !important;
    }

}
/* KORJAUS: Mobiiliversio oikean paneelin näyttämiseen */
@media (max-width: 768px) {
    #main-container {
        display: block;
    }

    #left-panel-container {
        display: none;
    }
    
    #right-panel-container {
        display: none;
    }

    /* Piilota tietoteksti mobiilissa */
    .info-text-desktop {
        display: none !important;
    }
    
    .info-panel-modal .info-panel-content {
        max-width: 90%;
        width: 90%;
        height: 90vh; /* KORJAUS: Tee sisällöstä koko näytön kokoinen */
        padding: 15px 20px;
        box-sizing: border-box;
    }
    
    /* KORJAUS: Varmista, että tilastojen kontaineri näkyy varmasti */
    #statistics-container-mobile,
    #mobile-opacity-container,
    #lightning-legend-mobile {
        display: block !important;
        padding-top: 10px;
        border-top: 1px solid #ccc;
        margin-top: 15px;
    }
    
    #lightning-legend-mobile {
        padding-top: 10px;
        border-top: 1px solid #ccc;
        margin-top: 15px;
    }
    
    /* Lisää tämä osio radar6.css-tiedoston loppuun */
    .hidden-ui #top-left-mobile-buttons,
    .hidden-ui #info-button-mobile,
    .hidden-ui #time-slider-container {
        display: none !important;
    }

    /* Tyylit Piilota käyttöliittymä -painikkeelle */
    #toggle-mobile-ui-btn {
        position: fixed;
        top: 10px;
        right: 10px;
        z-index: 500;
        display: flex;
        background-color: #6c757d;
        color: white;
        pointer-events: auto;
    }
    
    /* Tyylit Tietoa -painikkeelle */
    #info-button-mobile {
        position: fixed;
        top: 55px;
        right: 10px;
        z-index: 500;
        display: flex;
        background-color: #28a745;
        pointer-events: auto;
    }
    
    /* Piilota desktop-elementit mobiilissa */
    .desktop-only {
        display: none !important;
    }

    /* Näytä mobile-only-elementit mobiilissa */
    .mobile-only {
        display: block !important;
    }
}