/* ============================================
   OVERRIDE GESTA.CSS - ALTA PRIORITÀ
   Caricato DOPO gesta.css per correggere
   img { width:100%; height:100% } globale
   ============================================ */

/* Sidebar con gradiente moderno */
div.sidebar,
.page > .sidebar,
.page div.sidebar,
main ~ .sidebar,
body .sidebar {
    background: #002D94 !important;
    background-image: linear-gradient(180deg, #002D94 0%, #1a4db8 50%, #001f6b 100%) !important;
    background-color: #002D94 !important;
    box-shadow: 0 8px 24px rgba(0, 45, 148, 0.2) !important;
    flex-shrink: 0;
}

/* ===== App shell layout (non dipende da CSS scoped) ===== */
.page {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.page > main {
    flex: 1;
    min-width: 0;
}

@media (min-width: 641px) {
    .page {
        flex-direction: row;
    }

    .page > .sidebar {
        min-height: 100vh;
        position: sticky;
        top: 0;
        height: 100vh;
        overflow: hidden;
    }
}

@media (max-width: 640.98px) {
    .page > .sidebar {
        width: 0;
        min-width: 0;
        overflow: visible;
    }
}

/* ===== Sidebar navigation ===== */
.nav-sidebar {
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width-expanded, 260px);
    min-width: var(--sidebar-width-expanded, 260px);
    height: 100vh;
    position: sticky;
    top: 0;
    background: var(--gradient-sidebar, linear-gradient(180deg, #002D94 0%, #001f6b 100%));
    color: #ffffff;
    transition: width 250ms ease, min-width 250ms ease;
    z-index: 200;
    overflow: hidden;
}

.nav-sidebar--collapsed {
    width: var(--sidebar-width-collapsed, 72px);
    min-width: var(--sidebar-width-collapsed, 72px);
}

.nav-sidebar__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    min-height: 56px;
    flex-shrink: 0;
}

.nav-sidebar__brand {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: inherit;
    min-width: 0;
    flex: 1;
}

/* ===== Top bar ===== */
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--topbar-height, 50px);
    padding: 0 16px;
    background: #002D94;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.app-topbar__left,
.app-topbar__actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-topbar__menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
}

.app-topbar__icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: white;
    cursor: pointer;
    border-radius: 8px;
    padding: 0;
}

@media (max-width: 640.98px) {
    .app-topbar__menu-btn {
        display: flex;
    }

    .nav-sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 199;
    }

    .nav-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        transition: transform 250ms ease;
        box-shadow: 0 12px 48px rgba(0, 45, 148, 0.25);
    }

    .nav-sidebar--mobile-open {
        transform: translateX(0);
    }
}

/* ===== Guardie immagini: annulla gesta.css img { width:100%; height:100% } ===== */
.nav-sidebar .nav-sidebar__logo,
.nav-sidebar img.nav-sidebar__logo {
    width: 36px !important;
    height: 36px !important;
    max-width: 36px !important;
    max-height: 36px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    object-fit: contain !important;
    flex-shrink: 0 !important;
}

.nav-sidebar img.nav-menu-link__icon,
.nav-sidebar .nav-menu-link__icon {
    width: 20px !important;
    height: 20px !important;
    max-width: 20px !important;
    max-height: 20px !important;
    min-width: 20px !important;
    min-height: 20px !important;
    object-fit: contain !important;
    flex-shrink: 0 !important;
}

.app-topbar .app-topbar__icon-img,
.app-topbar img.app-topbar__icon-img {
    width: 24px !important;
    height: 24px !important;
    max-width: 24px !important;
    max-height: 24px !important;
    min-width: 24px !important;
    min-height: 24px !important;
    object-fit: contain !important;
    flex-shrink: 0 !important;
}

.app-topbar .avatar-container {
    width: 30px !important;
    height: 30px !important;
    min-width: 30px !important;
    min-height: 30px !important;
    max-width: 30px !important;
    max-height: 30px !important;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    padding: 0;
    border: 2px solid white;
}

.app-topbar .avatar-image {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: cover !important;
}

.search-overlay .search-image {
    width: 400px !important;
    max-width: min(400px, 90vw) !important;
    height: auto !important;
}
