/* ==========================================================================
   SIDEBAR NAVIGAATIO (PÄIVITETTY KOKONAISUUS)
   ========================================================================== */

.sidebar {
    width: 280px;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(15px);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    z-index: 1100;
    padding: 2rem 1rem;
    transition: all 0.4s cubic-bezier(0.77, 0, 0.175, 1); /* Sulava liuku mobiilille */
}

/* Logo-alue */
.sidebar-header {
    text-align: center;
    margin-bottom: 3rem;
}

.sidebar-logo img {
    width: 120px;
    height: 120px;
    display: block;
    margin: 0 auto 1rem;
    object-fit: cover;
    border-radius: 50%;
    
    /* Kuvanlaadun parannukset */
    image-rendering: high-quality;
    -webkit-backface-visibility: hidden; /* Estää tärinää ja säröilyä */
    backface-visibility: hidden;
    
    /* Varmistetaan ettei vanhat suodattimet kummittele */
    filter: none !important;
}

.sidebar-logo img:hover {
    transform: scale(1.05) rotate(-2deg);
    filter: drop-shadow(0 0 20px rgba(78, 168, 255, 0.8));
}

.sidebar-brand {
    font-size: 1.4rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 0.2rem;
    letter-spacing: 1px;
}

.sidebar-subtitle {
    font-size: 0.8rem;
    color: #4ea8ff;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* --- VALIKON LINKIT --- */
.sidebar-menu .nav-link {
    color: #4ea8ff !important;
    font-weight: 500;
    letter-spacing: 0.5px;
    padding: 1rem 1.5rem;
    text-decoration: none;
    position: relative;
    transition: all 0.3s ease;
    text-shadow: 0 0 8px rgba(78, 168, 255, 0.3);
    border-left: 4px solid transparent;
}

/* Hover-tila ja Aktiivinen sivu */
.sidebar-menu .nav-link:hover,
.sidebar-menu .nav-link.active {
    color: #fff !important;
    background: rgba(78, 168, 255, 0.1);
    text-shadow: 0 0 12px rgba(78, 168, 255, 0.8);
    border-left: 4px solid #4ea8ff;
    box-shadow: inset 10px 0 20px -10px rgba(78, 168, 255, 0.4);
    padding-left: 1.8rem;
}

/* Neon-viiva tehoste aktiiviselle linkille */
.sidebar-menu .nav-link.active::before {
    content: "";
    position: absolute;
    left: -4px;
    top: 20%;
    height: 60%;
    width: 4px;
    background: #4ea8ff;
    box-shadow: 0 0 15px #4ea8ff, 0 0 30px #4ea8ff;
    border-radius: 0 5px 5px 0;
}

/* --- SIDEBAR FOOTER & IKONIT --- */
.sidebar-footer {
    padding: 20px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    width: 100%;
    margin-top: auto;
}

.sidebar-icons a {
    color: #4ea8ff;
    opacity: 0.7;
    transition: all 0.3s ease;
    display: inline-block;
}

.sidebar-icons a:hover {
    color: #fff;
    opacity: 1;
    transform: translateY(-3px);
    filter: drop-shadow(0 0 10px #4ea8ff);
}

.sidebar-copy {
    color: #555;
    font-size: 11px;
    letter-spacing: 1px;
    margin-top: 5px;
}

/* ==========================================================================
   MOBIILIELEMENTIT (OFF-CANVAS)
   ========================================================================== */

/* Mobiili yläpalkki */
.mobile-top-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 70px;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 1050;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Hampurilaispainike */
.menu-toggle {
    background: transparent;
    border: 1px solid rgba(78, 168, 255, 0.5);
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.menu-toggle:hover {
    box-shadow: 0 0 15px rgba(78, 168, 255, 0.4);
}

.navbar-toggler-icon-custom {
    display: block;
    width: 24px;
    height: 2px;
    background: #4ea8ff;
    position: relative;
    box-shadow: 0 0 8px #4ea8ff;
}

.navbar-toggler-icon-custom::before,
.navbar-toggler-icon-custom::after {
    content: "";
    position: absolute;
    width: 24px;
    height: 2px;
    background: #4ea8ff;
    left: 0;
}
.navbar-toggler-icon-custom::before { top: -8px; }
.navbar-toggler-icon-custom::after { top: 8px; }

/* Sulkemispainike sidebarissa piiloon, hampurilaispainike hoitaa sen */
.menu-close {
    display: none !important;
}

/* Varmista että overlay ei ole tiellä kun se on kiinni */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1050; /* Sidebaran alapuolella */
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none; /* Estää klikkausten estämisen kun piilossa */
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* ==========================================================================
   RESPONSIIVISUUS (MEDIA QUERIES)
   ========================================================================== */

@media (max-width: 991px) {
    .sidebar {
        left: -300px; /* Piilotetaan vasemmalle */
        /* Lisätään yläreunaan tilaa, jotta logo ei jää top-barin alle */
        padding-top: 80px !important;
    }

    .mobile-top-bar {
        display: flex !important; /* Pakotetaan näkyviin */
        z-index: 4000 !important; /* Nostetaan kaiken muun päälle */
        background: #000 !important; /* Varmistetaan musta tausta */
        height: 60px;
        position: fixed;
    }
    
    .sidebar.active {
        left: 0; /* Liukuu sisään */
        box-shadow: 15px 0 50px rgba(0, 0, 0, 0.9);
    }

    /* Piilotetaan työpöydän margin-siirrot */
    #page-content, .hero-header {
        margin-left: 0 !important;
        width: 100% !important;
        padding-top: 70px; /* Tilaa mobiilipalkille */
    }

    /* Varmista että logon kuva mahtuu palkkiin */
    .sidebar-logo-mobile img {
        height: 35px;
        width: auto;
    }

    /* Pakotetaan hampurilaispainike näkyviin */
    .menu-toggle {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        z-index: 2001;
    }
}

@media (min-width: 992px) {
    .mobile-top-bar {
        display: none !important;
    }
    
    /* Varmistetaan että sisältö väistää sidebaria työpöydällä */
    #page-content, .hero-header {
        margin-left: 280px;
        width: calc(100% - 280px);
    }
}