/* Learnnet Academy PWA / mobile app chrome.
   Desktop layout is left unchanged. Phone + standalone get an app shell. */

:root {
    --pwa-theme: #6d675d;
    --pwa-accent: #ccd871;
    --pwa-text: #3d3a35;
    --pwa-muted: #8a8378;
    --pwa-bg: #f6f5f2;
    --pwa-surface: #ffffff;
    --pwa-tabbar-height: 64px;
    --pwa-safe-top: env(safe-area-inset-top, 0px);
    --pwa-safe-bottom: env(safe-area-inset-bottom, 0px);
}

.local-pwa-tabbar,
.local-pwa-install {
    display: none;
}

.local-pwa-tab {
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(204, 216, 113, 0.45);
}

.local-pwa-tab.is-pressed,
.local-pwa-tab:active {
    background: rgba(204, 216, 113, 0.32);
}

.local-pwa-tabbar.is-away {
    visibility: hidden;
    pointer-events: none;
}

/* -------------------------------------------------------------------------- */
/* Phone (browser) and installed PWA on compact screens                       */
/* -------------------------------------------------------------------------- */
@media (max-width: 767.98px) {
    html.local-pwa-ready,
    html.local-pwa-ready body {
        background: var(--pwa-bg);
    }

    html.local-pwa-ready body.pwa-mobile,
    html.local-pwa-ready body,
    #wrapper,
    .elan-page-wrapper,
    .our-dashbord,
    #page,
    .dashboard_main_content {
        padding-bottom: calc(var(--pwa-tabbar-height) + var(--pwa-safe-bottom) + 8px) !important;
    }

    .local-pwa-tabbar {
        display: flex;
        position: fixed !important;
        left: 0;
        right: 0;
        bottom: 0 !important;
        width: 100%;
        max-width: 100vw;
        z-index: 2147483000;
        min-height: calc(var(--pwa-tabbar-height) + var(--pwa-safe-bottom));
        height: auto;
        margin: 0;
        padding: 0 0 var(--pwa-safe-bottom);
        background: #ffffff;
        border-top: 1px solid rgba(109, 103, 93, 0.12);
        box-shadow: 0 -8px 24px rgba(61, 58, 53, 0.08);
        justify-content: space-around;
        align-items: stretch;
        pointer-events: auto;
        -webkit-user-select: none;
        user-select: none;
        touch-action: manipulation;
    }

    .local-pwa-tab {
        flex: 1 1 0;
        min-width: 0;
        min-height: var(--pwa-tabbar-height);
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        padding: 10px 4px;
        color: var(--pwa-muted);
        text-decoration: none !important;
        cursor: pointer;
        -webkit-tap-highlight-color: rgba(204, 216, 113, 0.45);
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
        touch-action: manipulation;
        font-size: 10px;
        line-height: 1.2;
        font-weight: 600;
        letter-spacing: 0.01em;
    }

    .local-pwa-tab-icon {
        width: 26px;
        height: 26px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .local-pwa-tab-icon svg {
        width: 22px;
        height: 22px;
        fill: currentColor;
    }

    .local-pwa-tab-label {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .local-pwa-tab.is-active {
        color: var(--pwa-theme);
    }

    .local-pwa-tab.is-active .local-pwa-tab-icon {
        background: rgba(204, 216, 113, 0.35);
        border-radius: 12px;
        width: 42px;
    }

    .go-top,
    a.mobilelink,
    .mobilelink {
        display: none !important;
    }

    body.path-my .footer-area,
    body.path-course .footer-area,
    body.path-mod .footer-area,
    body.path-message .footer-area,
    body.path-calendar .footer-area,
    body.path-user .footer-area,
    body.path-grade .footer-area,
    body.path-login .footer-area {
        display: none !important;
    }

    /* Theme banner, breadcrumb and extra H2 repeat the Moodle page heading. */
    .page-title-area,
    .breadcrumb_widgets,
    .page-title-content h2 {
        display: none !important;
    }

    #page-my-index .page-title-area,
    #page-my-index .page-title-area nav,
    #page-my-index .breadcrumb {
        display: none !important;
    }

    /* Course overview: keep the trainings, drop filter/search/sort on phones. */
    .block-myoverview [data-region="filter"],
    [data-region="myoverview"] [data-region="filter"] {
        display: none !important;
    }

    .block-myoverview,
    [data-region="myoverview"],
    .dashboard-card-deck {
        overflow-x: hidden;
        max-width: 100%;
    }

    .dashboard-card-deck {
        display: block !important;
        margin: 0 !important;
    }

    .dashboard-card-deck .dashboard-card {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 0 12px !important;
        flex: none !important;
    }

    .bottom-region-main-box,
    #page.container.bottom-region-main-box {
        max-width: 100% !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .course-content,
    .course-content-item-content,
    .activity-item {
        max-width: 100%;
    }

    .btn,
    .default-btn,
    input[type="submit"],
    .aalink {
        min-height: 44px;
    }

    .navbar-area {
        box-shadow: 0 1px 0 rgba(61, 58, 53, 0.08) !important;
    }

    .path-login .page-title-area {
        display: none !important;
    }

    .path-login .login-wrapper,
    .path-login .login-wrapper.pt-100 {
        padding-top: 20px !important;
        padding-bottom: 16px !important;
    }

    .path-login .navbar-area .default-btn,
    .path-login .others-option-for-responsive {
        display: none !important;
    }

    /* Messages: one-column list in normal page flow.
       Moodle uses h-100 + overflow-y:auto on the overview body; that
       collapses to 0px when parents have no definite height (iPhone). */
    body.path-message #wrapper,
    body.path-message .our-dashbord,
    body.path-message .dashboard_main_content,
    body.path-message .main_content_container,
    body.path-message #page,
    body.path-message #region-main,
    body.path-message [role="main"],
    #page-message-index #wrapper,
    #page-message-index .our-dashbord,
    #page-message-index .dashboard_main_content,
    #page-message-index #region-main,
    #page-message-index [role="main"] {
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow: visible !important;
    }

    body.path-message .our-dashbord,
    #page-message-index .our-dashbord {
        background: #fff;
    }

    body.path-message .dashboard_main_content,
    #page-message-index .dashboard_main_content {
        padding-top: 8px !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        padding-bottom: calc(var(--pwa-tabbar-height) + var(--pwa-safe-bottom) + 16px) !important;
    }

    body.path-message .col-lg-8,
    body.path-message .col-lg-4,
    #page-message-index .col-lg-8,
    #page-message-index .col-lg-4 {
        flex: 0 0 100%;
        max-width: 100%;
        width: 100%;
        padding-left: 8px;
        padding-right: 8px;
    }

    body.path-message .elan-sidebar-region,
    body.path-message #page-header,
    body.path-message .elan-full-header,
    #page-message-index .elan-sidebar-region,
    #page-message-index #page-header {
        display: none !important;
    }

    body.path-message .message-app.main,
    #page-message-index .message-app.main {
        display: block !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow: visible !important;
        border: 0 !important;
        border-radius: 0;
        background: #fff;
    }

    body.path-message .message-app.main > .container-fluid,
    body.path-message .message-app.main > .container-fluid > .row,
    #page-message-index .message-app.main > .container-fluid,
    #page-message-index .message-app.main > .container-fluid > .row {
        display: block !important;
        height: auto !important;
        max-width: 100%;
        margin: 0;
        position: static;
    }

    body.path-message .message-app.main .col-4,
    body.path-message .message-app.main .conversationcontainer,
    body.path-message .message-app.main .conversationcontainer > .h-100,
    body.path-message .message-app.main .border-end,
    body.path-message .message-app.main [data-region="panel-header-container"],
    body.path-message .message-app.main [data-region="panel-body-container"],
    body.path-message .message-app.main .view-overview-body,
    body.path-message .message-app.main .view-overview-body .h-100,
    #page-message-index .message-app.main .col-4,
    #page-message-index .message-app.main .conversationcontainer,
    #page-message-index .message-app.main .border-end,
    #page-message-index .message-app.main [data-region="panel-body-container"],
    #page-message-index .message-app.main .view-overview-body,
    #page-message-index .message-app.main .view-overview-body .h-100 {
        display: block !important;
        flex: none !important;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow: visible !important;
        padding-left: 0;
        padding-right: 0;
    }

    body.path-message .message-app.main .conversationcontainer .section,
    #page-message-index .message-app.main .conversationcontainer .section,
    #page-message-index #region-main .conversationcontainer .section {
        max-height: none !important;
        height: auto !important;
        overflow: visible !important;
    }

    body.path-message .message-app.main .overview-section-toggle,
    #page-message-index .message-app.main .overview-section-toggle {
        min-height: 48px;
        padding: 12px 8px !important;
    }

    body.path-message .message-app.main [data-region="view-overview-search-input"],
    #page-message-index .message-app.main [data-region="view-overview-search-input"] {
        min-height: 44px;
        background: #fff !important;
    }

    /* Chat / contacts / settings: overlay only when that header is actually shown. */
    body.path-message .message-app.main .col-8,
    #page-message-index .message-app.main .col-8 {
        display: none !important;
        flex: 0 0 100%;
        max-width: 100%;
        width: 100%;
        padding: 0;
        background: #fff;
    }

    body.path-message .message-app.main.is-pane-open .col-8,
    body.path-message .message-app.main .col-8:has(> [data-region="header-container"] > [data-region="view-conversation"]:not(.hidden)),
    body.path-message .message-app.main .col-8:has(> [data-region="header-container"] > [data-region="view-contacts"]:not(.hidden)),
    body.path-message .message-app.main .col-8:has(> [data-region="header-container"] > [data-region="view-settings"]:not(.hidden)),
    #page-message-index .message-app.main.is-pane-open .col-8,
    #page-message-index .message-app.main .col-8:has(> [data-region="header-container"] > [data-region="view-conversation"]:not(.hidden)),
    #page-message-index .message-app.main .col-8:has(> [data-region="header-container"] > [data-region="view-contacts"]:not(.hidden)),
    #page-message-index .message-app.main .col-8:has(> [data-region="header-container"] > [data-region="view-settings"]:not(.hidden)) {
        display: flex !important;
        flex-direction: column !important;
        position: fixed !important;
        left: 0;
        right: 0;
        top: 0;
        bottom: calc(var(--pwa-tabbar-height) + var(--pwa-safe-bottom));
        z-index: 1040;
        height: auto !important;
        overflow: hidden;
        padding-top: env(safe-area-inset-top, 0px);
    }

    body.path-message .message-app.main .col-8 .header-container,
    body.path-message .message-app.main .col-8 .footer-container,
    #page-message-index .message-app.main .col-8 .header-container,
    #page-message-index .message-app.main .col-8 .footer-container {
        flex-shrink: 0;
    }

    body.path-message .message-app.main .col-8 .body-container,
    #page-message-index .message-app.main .col-8 .body-container {
        flex: 1 1 auto;
        min-height: 0;
        position: relative;
        overflow: hidden;
    }

    body.path-message .message-app.main .icon-back-in-app,
    #page-message-index .message-app.main .icon-back-in-app {
        display: inline-flex !important;
    }

    body.path-message .message-app.main .border-end {
        border-right: 0 !important;
    }
}

/* -------------------------------------------------------------------------- */
/* Installed PWA (iPhone, Android, iPad)                                      */
/* -------------------------------------------------------------------------- */
@media (display-mode: standalone), (display-mode: fullscreen) {
    html,
    body {
        overscroll-behavior-y: contain;
        background: var(--pwa-bg);
    }

    .local-pwa-tabbar {
        display: flex;
        position: fixed !important;
        left: 0;
        right: 0;
        bottom: 0 !important;
        width: 100%;
        z-index: 2147483000;
        min-height: calc(var(--pwa-tabbar-height) + var(--pwa-safe-bottom));
        height: auto;
        padding: 0 0 var(--pwa-safe-bottom);
        background: #ffffff;
        border-top: 1px solid rgba(109, 103, 93, 0.12);
        justify-content: space-around;
        align-items: stretch;
        transform: none !important;
        -webkit-user-select: none;
        user-select: none;
    }

    .local-pwa-tab {
        flex: 1 1 0;
        min-width: 0;
        min-height: var(--pwa-tabbar-height);
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        padding: 10px 4px;
        color: var(--pwa-muted);
        text-decoration: none !important;
        -webkit-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
        touch-action: manipulation;
        font-size: 10px;
        font-weight: 600;
    }

    .local-pwa-tab-icon {
        width: 26px;
        height: 26px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .local-pwa-tab-icon svg {
        width: 22px;
        height: 22px;
        fill: currentColor;
    }

    .local-pwa-tab.is-active {
        color: var(--pwa-theme);
    }

    .local-pwa-tab.is-active .local-pwa-tab-icon {
        background: rgba(204, 216, 113, 0.35);
        border-radius: 12px;
        width: 42px;
    }

    body {
        padding-bottom: calc(var(--pwa-tabbar-height) + var(--pwa-safe-bottom)) !important;
        padding-top: 0 !important;
    }

    .navbar-area {
        padding-top: var(--pwa-safe-top) !important;
        position: sticky;
        top: 0;
        z-index: 1030;
        background: var(--pwa-surface) !important;
        box-shadow: 0 1px 0 rgba(61, 58, 53, 0.08) !important;
    }

    .navbar-area.is-sticky {
        top: 0 !important;
    }

    .footer-area,
    .go-top,
    a.mobilelink,
    .mobilelink,
    .elan-nav .navbar-nav,
    #page-footer,
    .footer-section {
        display: none !important;
    }

    .page-title-area,
    .page-title-content h2,
    .breadcrumb_widgets h2.title {
        display: none !important;
    }

    .desktop-navigation,
    .elan-nav .mean-bar {
        /* Keep the hamburger; hide leftover desktop chrome. */
    }

    #page-my-index .footer-area,
    .path-admin .footer-area,
    .path-my .footer-area {
        padding-left: 0 !important;
        display: none !important;
    }

    .drawer-toggles .drawer-left-toggle .btn {
        min-width: 44px;
        min-height: 44px;
    }

    .path-login .page-title-area,
    .path-login .navbar-area .default-btn,
    .path-login .others-option-for-responsive {
        display: none !important;
    }

    .path-login .login-wrapper,
    .path-login .login-wrapper.pt-100 {
        padding-top: 16px !important;
        padding-bottom: 12px !important;
    }

    .block-myoverview [data-region="filter"],
    [data-region="myoverview"] [data-region="filter"] {
        display: none !important;
    }

    .dashboard-card-deck {
        display: block !important;
        overflow-x: hidden !important;
        margin: 0 !important;
    }

    .dashboard-card-deck .dashboard-card {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 0 12px !important;
        flex: none !important;
    }
}

/* iOS home-screen mode does not always match display-mode: standalone. */
html.pwa-standalone .navbar-area,
body.pwa-standalone .navbar-area {
    padding-top: var(--pwa-safe-top) !important;
}

html.pwa-standalone .page-title-area,
html.pwa-standalone .page-title-content h2,
html.pwa-standalone .breadcrumb_widgets h2.title,
html.pwa-standalone .block-myoverview [data-region="filter"],
html.pwa-standalone [data-region="myoverview"] [data-region="filter"],
body.pwa-standalone .page-title-area,
body.pwa-standalone .page-title-content h2,
body.pwa-standalone .breadcrumb_widgets h2.title,
body.pwa-standalone .block-myoverview [data-region="filter"],
body.pwa-standalone [data-region="myoverview"] [data-region="filter"] {
    display: none !important;
}

html.pwa-standalone body,
body.pwa-standalone {
    padding-bottom: calc(var(--pwa-tabbar-height) + var(--pwa-safe-bottom)) !important;
}

html.pwa-standalone .local-pwa-tabbar,
html.pwa-mobile .local-pwa-tabbar,
body.pwa-standalone .local-pwa-tabbar,
body.pwa-mobile .local-pwa-tabbar {
    display: flex;
    position: fixed !important;
    left: 0;
    right: 0;
    bottom: 0 !important;
    width: 100%;
    z-index: 2147483000;
    min-height: calc(var(--pwa-tabbar-height) + var(--pwa-safe-bottom));
    height: auto;
    padding: 0 0 var(--pwa-safe-bottom);
    background: #ffffff;
    border-top: 1px solid rgba(109, 103, 93, 0.12);
    justify-content: space-around;
    align-items: stretch;
    transform: none !important;
    -webkit-user-select: none;
    user-select: none;
}

html.pwa-standalone .local-pwa-tab,
html.pwa-mobile .local-pwa-tab,
body.pwa-standalone .local-pwa-tab,
body.pwa-mobile .local-pwa-tab {
    flex: 1 1 0;
    min-width: 0;
    min-height: var(--pwa-tabbar-height);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 10px 4px;
    color: var(--pwa-muted);
    text-decoration: none !important;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    touch-action: manipulation;
    font-size: 10px;
    font-weight: 600;
}

html.pwa-standalone .local-pwa-tab-icon svg,
body.pwa-standalone .local-pwa-tab-icon svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

html.pwa-standalone .local-pwa-tab.is-active,
body.pwa-standalone .local-pwa-tab.is-active {
    color: var(--pwa-theme);
}

@media (min-width: 992px) {
    html.pwa-mobile .local-pwa-tabbar,
    body.pwa-mobile .local-pwa-tabbar,
    html.pwa-standalone .local-pwa-tabbar,
    body.pwa-standalone .local-pwa-tabbar {
        display: none !important;
    }
}

/* -------------------------------------------------------------------------- */
/* Add-to-home-screen banner                                                  */
/* -------------------------------------------------------------------------- */
.local-pwa-install.is-visible {
    display: flex;
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(var(--pwa-tabbar-height) + var(--pwa-safe-bottom) + 12px);
    z-index: 2147483001;
    background: var(--pwa-surface);
    color: var(--pwa-text);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(61, 58, 53, 0.18);
    padding: 12px 14px;
    gap: 12px;
    align-items: center;
    font-size: 13px;
    line-height: 1.35;
}

.local-pwa-install-icon img {
    display: block;
    border-radius: 12px;
}

.local-pwa-install-copy {
    flex: 1 1 auto;
    min-width: 0;
}

.local-pwa-install-copy strong {
    display: block;
    font-size: 14px;
    margin-bottom: 2px;
}

.local-pwa-install-text {
    margin: 0;
    color: var(--pwa-muted);
}

.local-pwa-ios-step {
    color: var(--pwa-theme);
    font-weight: 700;
}

.local-pwa-install-btn {
    flex: 0 0 auto;
    border: 0;
    background: var(--pwa-theme);
    color: #fff;
    border-radius: 999px;
    padding: 8px 14px;
    font-weight: 700;
    font-size: 13px;
}

.local-pwa-install-close {
    position: absolute;
    top: 4px;
    right: 8px;
    border: 0;
    background: transparent;
    color: var(--pwa-muted);
    font-size: 22px;
    line-height: 1;
    padding: 4px;
}

@media (min-width: 768px) {
    .local-pwa-install.is-visible {
        display: none !important;
    }
}

html.pwa-standalone .local-pwa-install {
    display: none !important;
}

/* -------------------------------------------------------------------------- */
/* Language picker: header chip + bottom sheet (hamburger screens)            */
/* -------------------------------------------------------------------------- */
.local-pwa-lang {
    display: none;
}

@media (max-width: 1199.98px) {
    .local-pwa-lang {
        display: block;
    }

    .local-pwa-lang-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 5px;
        position: fixed;
        top: calc(var(--pwa-safe-top) + 10px);
        right: 102px;
        z-index: 1045;
        min-width: 52px;
        height: 36px;
        padding: 0 10px;
        border: 0;
        border-radius: 999px;
        background: #ffffff;
        color: var(--pwa-text);
        box-shadow: 0 1px 0 rgba(61, 58, 53, 0.08), 0 6px 16px rgba(61, 58, 53, 0.08);
        font-size: 12px;
        font-weight: 700;
        letter-spacing: 0.04em;
        line-height: 1;
        -webkit-tap-highlight-color: rgba(204, 216, 113, 0.45);
        touch-action: manipulation;
    }

    .local-pwa-lang-toggle .local-pwa-lang-flag {
        font-size: 16px;
        line-height: 1;
    }

    .local-pwa-lang-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 2147483500;
        background: rgba(61, 58, 53, 0.42);
    }

    .local-pwa-lang-sheet {
        display: none;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 2147483510;
        max-height: min(78vh, 560px);
        overflow: auto;
        background: #ffffff;
        border-radius: 20px 20px 0 0;
        padding: 8px 16px calc(var(--pwa-tabbar-height) + var(--pwa-safe-bottom) + 20px);
        box-shadow: 0 -12px 40px rgba(61, 58, 53, 0.18);
        -webkit-overflow-scrolling: touch;
    }

    .local-pwa-lang.is-open .local-pwa-lang-backdrop,
    .local-pwa-lang.is-open .local-pwa-lang-sheet {
        display: block;
    }

    .local-pwa-lang-handle {
        width: 36px;
        height: 4px;
        border-radius: 999px;
        background: rgba(109, 103, 93, 0.22);
        margin: 6px auto 10px;
    }

    .local-pwa-lang-sheet-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        margin-bottom: 8px;
    }

    .local-pwa-lang-sheet-head h2 {
        margin: 0;
        font-size: 18px;
        font-weight: 700;
        color: var(--pwa-text);
    }

    .local-pwa-lang-close {
        border: 0;
        background: transparent;
        color: var(--pwa-muted);
        font-size: 28px;
        line-height: 1;
        padding: 4px 8px;
    }

    .local-pwa-lang-list {
        list-style: none;
        margin: 0;
        padding: 0;
    }

    .local-pwa-lang-item {
        display: flex;
        align-items: center;
        gap: 12px;
        min-height: 52px;
        padding: 10px 12px;
        margin: 0 0 6px;
        border-radius: 14px;
        color: var(--pwa-text) !important;
        text-decoration: none !important;
        background: var(--pwa-bg);
    }

    .local-pwa-lang-item.is-active {
        background: rgba(204, 216, 113, 0.38);
        font-weight: 700;
    }

    .local-pwa-lang-item-badge {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        min-width: 52px;
        font-weight: 700;
        letter-spacing: 0.04em;
        font-size: 13px;
    }

    .local-pwa-lang-item-name {
        flex: 1 1 auto;
        min-width: 0;
        font-size: 16px;
    }

    .local-pwa-lang-check {
        color: var(--pwa-theme);
        font-size: 18px;
        font-weight: 700;
    }

    /* Hide the nested hamburger / user-menu language controls. */
    .mean-nav li:has(a[href*="lang="]),
    .mean-nav .langmenu,
    .elan-nav .navbar-nav > li.dropdown:has(a[href*="lang="]),
    .usermenu a.carousel-navigation-link[data-pwa-hide-lang],
    .langmenu select.form-select {
        display: none !important;
    }
}
