/* ===== Mobile Bottom Navigation Bar ===== */

:root {
    --mobile-nav-height: 72px;
    --mobile-nav-margin: 12px;
    --mobile-nav-bg: #ffffff;
    --mobile-nav-active: var(--bs-primary, #007bff);
    --mobile-nav-text: #8e8e93;
    --mobile-nav-btn-size: 56px;
}

[data-bs-theme="dark"] {
    --mobile-nav-bg: #1c1c1e;
    --mobile-nav-text: #8e8e93;
    --mobile-nav-active: var(--bs-primary, #0a84ff);
}

.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: var(--mobile-nav-margin);
    left: var(--mobile-nav-margin);
    right: var(--mobile-nav-margin);
    z-index: 1090;
    background-color: var(--mobile-nav-bg);
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    margin-bottom: env(safe-area-inset-bottom, 0px);
    transition: transform 0.3s ease, opacity 0.3s ease;
    padding: 0 8px;
}

[data-bs-theme="dark"] .mobile-bottom-nav {
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

@media (max-width: 991.98px) {
    .mobile-bottom-nav {
        display: flex;
    }

    body.has-bottom-nav {
        /* Total height: margin + bar height + safe area */
        padding-bottom: calc(var(--mobile-nav-height) + var(--mobile-nav-margin) * 2 + env(safe-area-inset-bottom, 0px));
    }

    body.has-bottom-nav footer {
        margin-bottom: calc(var(--mobile-nav-height) + var(--mobile-nav-margin) * 2 + env(safe-area-inset-bottom, 0px));
    }

    body.has-bottom-nav .navbar-toggler {
        display: none !important;
    }

    body.has-bottom-nav #navbarNav {
        display: none !important;
    }
}

.mobile-bottom-nav__items {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: var(--mobile-nav-height);
    margin: 0;
    padding: 0;
    list-style: none;
}

.mobile-bottom-nav__item {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Standout Middle Button */
.mobile-bottom-nav__item--center {
    flex: 0 0 70px;
    z-index: 1;
}

.mobile-bottom-nav__link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 8px 2px;
    color: var(--mobile-nav-text);
    text-decoration: none;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.01em;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    border-radius: 16px;
}

.mobile-bottom-nav__link i,
.mobile-bottom-nav__link .nav-icon {
    font-size: 22px;
    margin-bottom: 4px;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.mobile-bottom-nav__link span {
    display: block;
    white-space: nowrap;
    line-height: 1.2;
}

.mobile-bottom-nav__link:active {
    background-color: rgba(0, 0, 0, 0.04);
    transform: scale(0.95);
}

[data-bs-theme="dark"] .mobile-bottom-nav__link:active {
    background-color: rgba(255, 255, 255, 0.06);
}

.mobile-bottom-nav__link.active {
    color: var(--mobile-nav-active);
}

.mobile-bottom-nav__link.active i {
    transform: translateY(-2px) scale(1.1);
}

/* Center menu button specific styling */
.mobile-bottom-nav__menu-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: var(--mobile-nav-btn-size);
    height: var(--mobile-nav-btn-size);
    background: var(--mobile-nav-active);
    color: #ffffff !important;
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    padding: 0;
    margin-bottom: 4px;
}

.mobile-bottom-nav__menu-btn i {
    font-size: 24px;
    transition: transform 0.4s ease;
}

.mobile-bottom-nav__menu-btn span {
    display: none; /* Hide text for the circular button to keep it clean */
}

.mobile-bottom-nav__menu-btn:active {
    transform: scale(0.9) translateY(2px);
    box-shadow: 0 2px 6px rgba(0, 123, 255, 0.2);
}

.mobile-bottom-nav__menu-btn.is-open {
    transform: rotate(135deg);
    background-color: #ff3b30; /* Red for close */
    box-shadow: 0 4px 12px rgba(255, 59, 48, 0.3);
}

/* Adjustments for the center item container */
.mobile-bottom-nav__item--center::before {
    content: '';
    position: absolute;
    top: -12px;
    width: 68px;
    height: 34px;
    background-color: transparent;
    border-radius: 0 0 40px 40px;
    /* Optional: creates a cutout effect if the background was fixed, but here it's floating */
}

/* ===== Menu Panel (slide-up overlay) ===== */

.mobile-menu-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1089;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity 0.25s ease;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.mobile-menu-overlay.is-visible {
    display: block;
}

.mobile-menu-overlay.is-active {
    opacity: 1;
}

.mobile-menu-panel {
    position: fixed;
    bottom: calc(var(--mobile-nav-height) + var(--mobile-nav-margin) * 2 + env(safe-area-inset-bottom, 0px) + 8px);
    left: var(--mobile-nav-margin);
    right: var(--mobile-nav-margin);
    z-index: 1091;
    background-color: var(--mobile-nav-bg);
    border-radius: 24px;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.15);
    max-height: 75vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateY(120%);
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    padding: 0;
    display: none;
}

.mobile-menu-panel.is-visible {
    display: block;
}

.mobile-menu-panel.is-open {
    transform: translateY(0);
}

.mobile-menu-panel__handle {
    display: flex;
    justify-content: center;
    padding: 12px 0 6px;
}

.mobile-menu-panel__handle::after {
    content: '';
    width: 40px;
    height: 5px;
    background: #d1d1d6;
    border-radius: 3px;
}

[data-bs-theme="dark"] .mobile-menu-panel__handle::after {
    background: #48484a;
}

.mobile-menu-panel__section {
    padding: 8px 0;
}

.mobile-menu-panel__section-title {
    padding: 8px 24px 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #8e8e93;
}

.mobile-menu-panel__divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.06);
    margin: 4px 20px;
}

[data-bs-theme="dark"] .mobile-menu-panel__divider {
    background: rgba(255, 255, 255, 0.08);
}

.mobile-menu-panel__link {
    display: flex;
    align-items: center;
    padding: 14px 24px;
    color: inherit;
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    transition: background 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.mobile-menu-panel__link:active {
    background: rgba(0, 0, 0, 0.05);
}

[data-bs-theme="dark"] .mobile-menu-panel__link:active {
    background: rgba(255, 255, 255, 0.08);
}

.mobile-menu-panel__link.active {
    color: var(--mobile-nav-active);
}

.mobile-menu-panel__link i {
    width: 32px;
    font-size: 20px;
    text-align: center;
    margin-right: 14px;
    color: #636366;
}

.mobile-menu-panel__link.active i {
    color: var(--mobile-nav-active);
}

.mobile-menu-panel__link .menu-chevron {
    margin-left: auto;
    color: #c7c7cc;
    font-size: 12px;
}

/* User info header in menu panel */
.mobile-menu-panel__user {
    display: flex;
    align-items: center;
    padding: 20px 24px 12px;
    gap: 14px;
}

.mobile-menu-panel__user img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--mobile-nav-active);
}

.mobile-menu-panel__user-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--mobile-nav-active);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.mobile-menu-panel__user-info {
    flex: 1;
    min-width: 0;
}

.mobile-menu-panel__user-name {
    font-size: 17px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-menu-panel__user-email {
    font-size: 13px;
    color: #8e8e93;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Lift the PWA install toast above the bottom nav */
@media (max-width: 991.98px) {
    body.has-bottom-nav #pwaInstallToast {
        bottom: calc(var(--mobile-nav-height) + var(--mobile-nav-margin) * 2 + env(safe-area-inset-bottom, 0px) + 12px) !important;
    }
}
