/* Unified suite navigation and app switcher. */

.app-switcher-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-top: 2px;
}

.app-switcher-btn {
    width: 34px;
    height: 34px;
    margin-right: 6px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #555;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.1rem;
    cursor: pointer;
    user-select: none;
    transition:
        background 0.15s ease,
        box-shadow 0.2s ease,
        color 0.15s ease,
        transform 0.15s ease;
}

.app-switcher-btn:hover,
.app-switcher-btn:focus-visible,
.app-switcher-btn[aria-expanded="true"] {
    background: rgba(0, 80, 157, 0.08);
    box-shadow: 0 0 0 3px rgba(0, 80, 157, 0.12);
    color: #00509d;
    outline: none;
}

.app-switcher-btn:hover {
    transform: scale(1.05);
}

.app-switcher-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 300px;
    max-height: min(680px, calc(100vh - 96px));
    overflow-x: hidden;
    overflow-y: auto;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 14px;
    background: #fff;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.18),
        0 2px 8px rgba(0, 0, 0, 0.08);
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px) scale(0.97);
    transform-origin: top right;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.app-switcher-dropdown.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.app-switcher-header {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 12px 16px 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    background: rgba(255, 255, 255, 0.96);
    text-align: center;
}

.app-switcher-header-label,
.app-switcher-section-label {
    color: #737373;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.055em;
    text-transform: uppercase;
}

.app-switcher-section-label {
    padding: 12px 16px 8px;
}

.app-switcher-local-section {
    border-bottom: 1px solid rgba(0, 0, 0, 0.07);
}

.app-switcher-local-section[hidden] {
    display: none !important;
}

.app-switcher-local-content {
    padding: 0 8px 10px;
}

.app-switcher-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    padding: 0 8px 12px;
}

.app-switcher-item {
    position: relative;
    min-width: 0;
    padding: 10px 6px;
    border-radius: 10px;
    color: inherit;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease;
}

.app-switcher-item:hover,
.app-switcher-item:focus-visible {
    background: rgba(0, 80, 157, 0.06);
    color: inherit;
    outline: none;
    text-decoration: none;
}

.app-switcher-item:focus-visible {
    box-shadow: inset 0 0 0 2px rgba(0, 80, 157, 0.28);
}

.app-switcher-item.current {
    background: rgba(0, 80, 157, 0.08);
}

.app-switcher-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    font-size: 1.4rem;
    font-weight: 700;
}

.app-switcher-icon img {
    width: 100%;
    height: 100%;
    border-radius: inherit;
    object-fit: cover;
}

.app-switcher-name {
    max-width: 76px;
    overflow: hidden;
    color: #444;
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-switcher-item.current .app-switcher-name {
    color: #00509d;
    font-weight: 600;
}

.app-switcher-current-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #00509d;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.55rem;
}

.app-switcher-empty {
    padding: 16px;
    color: #777;
    font-size: 0.8rem;
    text-align: center;
}

/* The real sidebar subtree is moved here on mobile, never cloned. */
.suite-navigation-mounted {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
    flex: none !important;
    overflow: visible !important;
}

.suite-navigation-mounted > .left-navbar-card,
.suite-navigation-mounted .left-navbar-card {
    min-height: 0 !important;
    margin: 0 0 8px !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

.suite-navigation-mounted .left-navbar-card:last-child {
    margin-bottom: 0 !important;
}

.suite-navigation-mounted .left-navbar-card.nav-card {
    padding: 0 !important;
}

.suite-navigation-mounted .left-navbar-card.nav-card nav {
    gap: 10px;
}


.suite-navigation-mounted .nav-link {
    min-height: 44px;
    display: flex;
    align-items: center;
}

@media (min-width: 992px) {
    .app-switcher-wrapper.desktop-no-apps {
        display: none;
    }
}

@media (max-width: 991.98px) {
    .app-switcher-btn {
        width: 44px;
        height: 44px;
    }

    .app-switcher-wrapper.has-local-navigation .app-switcher-dropdown {
        position: fixed;
        top: 74px;
        right: 10px;
        left: 10px;
        width: auto;
        max-height: calc(100dvh - 86px);
        transform-origin: top center;
    }


    /* Keep Bootstrap's hamburger as a no-JS fallback, then retire it only
       after the combined panel has successfully mounted the local menu. */
    .suite-navigation-ready .navbar-toggler {
        display: none !important;
    }

    /* The offcanvas shell is empty while its body lives in the popover. */
    .suite-navigation-ready .sidebar-offcanvas {
        display: none !important;
    }
}

@media (max-width: 360px) {
    .app-switcher-dropdown {
        position: fixed;
        top: 74px;
        right: 10px;
        left: 10px;
        width: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-switcher-btn,
    .app-switcher-dropdown,
    .app-switcher-item {
        transition: none;
    }

    .app-switcher-btn:hover {
        transform: none;
    }
}

/* Credits pinned to the very bottom of the app menu panel, below "Switch app",
   with room to breathe between the divider, the title and the bar. */
.app-switcher-credits-section {
    border-top: 1px solid rgba(0, 0, 0, 0.07);
}

.app-switcher-credits-section[hidden] {
    display: none !important;
}

.app-switcher-credits-section .left-navbar-card.credits-card {
    min-height: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 18px 16px 16px !important;
}

.app-switcher-credits-section .credits-card h5 {
    margin: 0 0 12px !important;
    font-size: 1rem;
    line-height: 1.25;
}

.app-switcher-credits-section .credits-card .progress-container {
    width: min(100%, 240px);
    margin: 0 0 10px !important;
    padding: 2px;
    border-radius: 7px;
}

.app-switcher-credits-section .credits-card .modern-progress {
    height: 6px;
}

.app-switcher-credits-section .credits-card #credits-text {
    margin: 0 0 8px !important;
    font-size: 0.75rem;
    line-height: 1.25;
}

.app-switcher-credits-section .credits-card #manage-plan-link {
    margin: 0 !important;
    font-size: 0.8rem;
}
