/* === AFLAO NEXUS FINAL STATIC/MEDIA/MOBILE FIX START === */

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    -webkit-text-size-adjust: 100%;
}

img {
    max-width: 100%;
}

/* A failed image normally paints its alt text inside the image box. Hide
   that text immediately; the controller below supplies a real SVG fallback. */
img[src*="/media/"],
img[src*="res.cloudinary.com"],
img[src*="/image/upload/"] {
    color: transparent !important;
    font-size: 0 !important;
}

img.aflao-image-fallback {
    display: block !important;
    object-fit: contain !important;
    padding: 10px !important;
    color: transparent !important;
    font-size: 0 !important;
    background: #f6faf8 !important;
}

/* -------------------------- staff dashboard -------------------------- */

#aflao-mobile-sidebar-overlay {
    position: fixed;
    inset: 0;
    display: block;
    background: rgba(3, 24, 34, .58);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    transition: opacity .2s ease, visibility .2s ease;
}

#aflao-mobile-sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

@media (max-width: 992px) {
    :root {
        --an-mobile-nav-height: 70px;
    }

    body.aflao-mobile-nav-open {
        overflow: hidden !important;
    }

    .navbar {
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: var(--an-mobile-nav-height) !important;
        padding: 0 10px !important;
        z-index: 3100 !important;
        contain: none !important;
        will-change: auto !important;
        background: #fff !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }

    .navbar-brand,
    .navbar-center {
        display: none !important;
    }

    .navbar-left {
        flex: 0 0 auto !important;
        gap: 6px !important;
    }

    .navbar-right {
        flex: 0 0 auto !important;
        margin-left: auto !important;
        gap: 5px !important;
    }

    #sidebar-toggle,
    .navbar-toggle {
        display: flex !important;
        width: 42px !important;
        height: 42px !important;
        min-width: 42px !important;
        min-height: 42px !important;
        opacity: 1 !important;
        filter: none !important;
        transform: none !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        z-index: 3300 !important;
    }

    .navbar-icon,
    .language-button,
    .theme-switch,
    .navbar-user > button.navbar-user {
        width: 42px !important;
        height: 42px !important;
        min-width: 42px !important;
        min-height: 42px !important;
        border-radius: 11px !important;
    }

    /* The staff drawer is a single opaque drawer. It never uses the old
       blurred .sidebar-overlay and never collapses into the page content. */
    #sidebar,
    .sidebar {
        top: var(--an-mobile-nav-height) !important;
        left: 0 !important;
        bottom: 0 !important;
        width: min(290px, calc(100vw - 24px)) !important;
        height: calc(100dvh - var(--an-mobile-nav-height)) !important;
        transform: translate3d(-110%, 0, 0) !important;
        visibility: hidden !important;
        pointer-events: none !important;
        z-index: 3200 !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        transition: transform .22s ease, visibility 0s linear .22s !important;
    }

    #sidebar.aflao-mobile-open,
    .sidebar.aflao-mobile-open {
        transform: translate3d(0, 0, 0) !important;
        visibility: visible !important;
        pointer-events: auto !important;
        transition: transform .22s ease !important;
    }

    .sidebar-overlay {
        display: none !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }

    #aflao-mobile-sidebar-overlay {
        top: var(--an-mobile-nav-height);
        bottom: 0;
        z-index: 3150;
    }

    /* Fixed viewport menus cannot be clipped by .navbar or the phone edge. */
    .navbar-dropdown {
        position: static !important;
        overflow: visible !important;
    }

    .navbar-dropdown > .navbar-dropdown-menu,
    .navbar-dropdown > .notification-dropdown,
    .navbar-dropdown > .message-dropdown {
        position: fixed !important;
        top: calc(var(--an-mobile-nav-height) + 6px) !important;
        right: 6px !important;
        left: auto !important;
        width: min(360px, calc(100vw - 12px)) !important;
        min-width: 0 !important;
        max-width: calc(100vw - 12px) !important;
        max-height: calc(100dvh - var(--an-mobile-nav-height) - 14px) !important;
        margin: 0 !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
        transform: translate3d(0, -8px, 0) !important;
        z-index: 4000 !important;
    }

    .navbar-dropdown.active > .navbar-dropdown-menu,
    .navbar-dropdown.active > .notification-dropdown,
    .navbar-dropdown.active > .message-dropdown,
    .navbar-dropdown > .navbar-dropdown-menu.show,
    .navbar-dropdown > .notification-dropdown.show,
    .navbar-dropdown > .message-dropdown.show {
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        transform: translate3d(0, 0, 0) !important;
    }

    .navbar-dropdown-menu::before {
        right: 18px !important;
    }

    .navbar-dropdown-menu .dropdown-item,
    .notification-item,
    .message-item {
        min-height: 44px;
        white-space: normal;
    }

    .notification-text,
    .message-text,
    .navbar-dropdown-menu span {
        overflow-wrap: anywhere;
    }
}

@media (max-width: 576px) {
    .navbar {
        padding-left: 7px !important;
        padding-right: 7px !important;
    }

    .navbar-right {
        gap: 3px !important;
    }

    #sidebar-toggle,
    .navbar-toggle,
    .navbar-icon,
    .language-button,
    .theme-switch,
    .navbar-user > button.navbar-user {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        min-height: 40px !important;
        border-radius: 10px !important;
    }

    #sidebar,
    .sidebar {
        width: min(290px, calc(100vw - 16px)) !important;
    }

    .navbar-dropdown > .navbar-dropdown-menu,
    .navbar-dropdown > .notification-dropdown,
    .navbar-dropdown > .message-dropdown {
        width: calc(100vw - 12px) !important;
        max-width: calc(100vw - 12px) !important;
    }
}

/* ---------------------------- public portal --------------------------- */

.portal-header {
    z-index: 5000 !important;
    background: #fff !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

.portal-listing-media img,
.portal-detail-logo img,
.portal-gallery img,
.portal-poster-grid article > img,
.portal-institution-mini-media img,
.portal-brand img,
.portal-footer-brand img {
    color: transparent !important;
    font-size: 0 !important;
}

#aflao-portal-menu-overlay {
    display: none;
}

@media (max-width: 1100px) {
    .portal-nav-wrap {
        min-height: 72px !important;
        padding-top: 8px !important;
        padding-bottom: 8px !important;
    }

    .portal-brand img {
        width: 48px !important;
        height: 48px !important;
        border-radius: 14px !important;
    }

    .portal-brand small {
        display: none !important;
    }

    .portal-navigation {
        top: 72px !important;
        z-index: 4999 !important;
        max-height: calc(100dvh - 72px) !important;
        background: #fff !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }

    .portal-navigation.is-open {
        visibility: visible !important;
        transform: translateY(0) !important;
    }

    #aflao-portal-menu-overlay {
        position: fixed;
        z-index: 4998;
        inset: 72px 0 0;
        display: block;
        background: rgba(3, 24, 34, .34);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }

    #aflao-portal-menu-overlay.show {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .portal-nav-panel,
    .portal-nav-panel-wide,
    .portal-account-panel {
        position: static !important;
        width: 100% !important;
        max-width: none !important;
        max-height: none !important;
        margin: 3px 0 8px !important;
        overflow: visible !important;
        background: #f8fbfa !important;
        box-shadow: none !important;
        animation: none !important;
    }
}

@media (max-width: 620px) {
    .portal-container {
        width: min(calc(100% - 28px), var(--container)) !important;
    }

    .portal-navigation {
        padding-left: 14px !important;
        padding-right: 14px !important;
    }

    .portal-page-hero {
        padding-block: 54px 48px !important;
    }

    .portal-page-hero h1 {
        font-size: clamp(2.15rem, 12vw, 3.8rem) !important;
        line-height: .98 !important;
    }

    .portal-section {
        padding-block: 48px !important;
    }

    .portal-card-grid,
    .portal-service-grid,
    .portal-poster-grid {
        grid-template-columns: 1fr !important;
    }

    .portal-listing-media {
        height: 210px !important;
        font-size: 2rem !important;
    }

    .portal-hero {
        min-height: 555px !important;
    }

    .portal-hero-content {
        padding-block: 76px !important;
    }

    .portal-hero-content h1 {
        font-size: clamp(2.5rem, 14vw, 4.5rem) !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    #sidebar,
    #aflao-mobile-sidebar-overlay,
    .navbar-dropdown > .navbar-dropdown-menu,
    .navbar-dropdown > .notification-dropdown,
    .portal-navigation {
        transition: none !important;
    }
}

/* === AFLAO NEXUS FINAL STATIC/MEDIA/MOBILE FIX END === */

/* === AFLAO NEXUS SIDEBAR BLUR/TOGGLE REPAIR START === */

@media (max-width: 992px) {
    /* The dashboard uses #sidebar-toggle. Hide the older second menu control. */
    .navbar .mobile-menu-toggle,
    .navbar button[aria-label="Open Navigation"] {
        display: none !important;
    }

    /* Keep legacy overlays from dimming or blurring the dashboard. */
    #mobile-overlay,
    .mobile-overlay,
    .sidebar-overlay {
        display: none !important;
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
        background: transparent !important;
        filter: none !important;
        -webkit-filter: none !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }

    /* This overlay remains a transparent click-to-close shield only. */
    #aflao-mobile-sidebar-overlay,
    #aflao-mobile-sidebar-overlay.show {
        background: transparent !important;
        filter: none !important;
        -webkit-filter: none !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }

    /* Never blur or fade page content while the drawer is open. */
    body.aflao-mobile-nav-open,
    body.aflao-mobile-nav-open #main-content,
    body.aflao-mobile-nav-open main,
    body.aflao-mobile-nav-open .app-shell,
    body.aflao-mobile-nav-open .app-layout,
    body.aflao-mobile-nav-open .dashboard-wrapper,
    body.aflao-mobile-nav-open .dashboard-content {
        filter: none !important;
        -webkit-filter: none !important;
        opacity: 1 !important;
    }

    #sidebar.aflao-mobile-open,
    #sidebar.mobile-open,
    #sidebar.show,
    .sidebar.aflao-mobile-open,
    .sidebar.mobile-open,
    .sidebar.show {
        opacity: 1 !important;
        filter: none !important;
        -webkit-filter: none !important;
    }
}

/* === AFLAO NEXUS SIDEBAR BLUR/TOGGLE REPAIR END === */

/* === AFLAO NEXUS MOBILE SIDEBAR NO-BLUR V2 START === */

@media (max-width: 992px) {
    /* The dashboard has one real toggle. Any older duplicate stays hidden. */
    .navbar .mobile-menu-toggle,
    .navbar button[aria-label="Open Navigation"],
    .navbar button[data-mobile-menu-toggle] {
        display: none !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }

    /* A drawer does not need a backdrop. Keep all old overlay nodes inert. */
    body.aflao-dashboard-shell #mobile-overlay,
    body.aflao-dashboard-shell .mobile-overlay,
    body.aflao-dashboard-shell .sidebar-overlay,
    body.aflao-dashboard-shell #aflao-mobile-sidebar-overlay,
    body.aflao-dashboard-shell [data-sidebar-overlay],
    body.aflao-dashboard-shell .drawer-backdrop,
    body.aflao-dashboard-shell .offcanvas-backdrop {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
        background: transparent !important;
        filter: none !important;
        -webkit-filter: none !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }

    /* Close-state rule wins over older .show/.mobile-open rules. */
    body.aflao-dashboard-shell #sidebar:not(.aflao-mobile-open),
    body.aflao-dashboard-shell .sidebar:not(.aflao-mobile-open) {
        transform: translate3d(-110%, 0, 0) !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }

    body.aflao-dashboard-shell #sidebar.aflao-mobile-open,
    body.aflao-dashboard-shell .sidebar.aflao-mobile-open {
        transform: translate3d(0, 0, 0) !important;
        visibility: visible !important;
        pointer-events: auto !important;
        opacity: 1 !important;
        filter: none !important;
        -webkit-filter: none !important;
        z-index: 6000 !important;
    }

    /* No legacy body/app state may dim the dashboard while the drawer is open. */
    body.aflao-dashboard-shell.aflao-mobile-nav-open,
    body.aflao-dashboard-shell.aflao-mobile-nav-open .app-shell,
    body.aflao-dashboard-shell.aflao-mobile-nav-open #main-content,
    body.aflao-dashboard-shell.aflao-mobile-nav-open main,
    body.aflao-dashboard-shell.aflao-mobile-nav-open .main-content,
    body.aflao-dashboard-shell.aflao-mobile-nav-open .dashboard-wrapper,
    body.aflao-dashboard-shell.aflao-mobile-nav-open .dashboard-content {
        filter: none !important;
        -webkit-filter: none !important;
        opacity: 1 !important;
    }
}

/* === AFLAO NEXUS MOBILE SIDEBAR NO-BLUR V2 END === */
