/* ========================================
   Bottom Navigation Bar - Mobile Only
   ======================================== */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--header-bg);
    backdrop-filter: blur(var(--backdrop-blur-chrome));
    -webkit-backdrop-filter: blur(var(--backdrop-blur-chrome));
    border-top: 1px solid var(--header-border);
    z-index: 999;
    display: none;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                background 0.25s ease,
                border-color 0.25s ease,
                box-shadow 0.25s ease;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);
}

.bottom-nav::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(circle at center bottom, var(--header-glow-primary), transparent 70%);
    opacity: 0.5;
    z-index: -1;
}

/* Navigation Container */
.bottom-nav__container {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: 100%;
    max-width: 100%;
    padding: 0 0.5rem;
    gap: 0.25rem;
}

/* Navigation Items */
.bottom-nav__item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-width: 0;
    padding: 0.45rem 0.35rem;
    border-radius: var(--radius-sm);
    color: var(--nav-link-color);
    text-decoration: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav__item::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.2), rgba(14, 165, 233, 0.15));
    opacity: 0;
    transition: opacity 0.25s ease;
    z-index: -1;
}

.bottom-nav__item:active {
    transform: scale(0.95);
}

/* Icon Wrapper */
.bottom-nav__icon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin-bottom: 0.15rem;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.bottom-nav__icon i {
    font-size: 1.4rem;
    transition: color 0.25s ease;
}

/* Text Label */
.bottom-nav__text {
    font-size: 0.68rem;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    transition: color 0.25s ease, transform 0.25s ease;
}

/* Active State */
.bottom-nav__item.active {
    color: var(--nav-link-active);
}

.bottom-nav__item.active::before {
    opacity: 1;
}

.bottom-nav__item.active .bottom-nav__icon {
    transform: translateY(-2px);
}

.bottom-nav__item.active .bottom-nav__icon i {
    color: var(--primary-light);
}

.bottom-nav__item.active .bottom-nav__text {
    font-weight: 600;
    transform: scale(1.05);
}

/* Hover State (for devices with pointer) */
@media (hover: hover) {
    .bottom-nav__item:hover {
        color: var(--nav-link-active);
    }

    .bottom-nav__item:hover::before {
        opacity: 0.6;
    }

    .bottom-nav__item:hover .bottom-nav__icon {
        transform: translateY(-2px);
    }

    .bottom-nav__item:hover .bottom-nav__icon i {
        color: var(--primary-light);
    }
}

/* Active Indicator */
.bottom-nav__item::after {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 32px;
    height: 3px;
    border-radius: 0 0 999px 999px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s ease;
}

.bottom-nav__item.active::after {
    transform: translateX(-50%) scaleX(1);
    opacity: 1;
}

/* Responsive Breakpoints */

/* Show bottom nav on mobile only (up to 880px) */
@media (max-width: 880px) {
    .bottom-nav {
        display: flex;
        flex-direction: column;
        bottom: calc(env(safe-area-inset-bottom, 0px) + var(--mobile-floating-inset-bottom, var(--mobile-floating-inset, 10px)));
        left: var(--mobile-floating-inset-x, var(--mobile-floating-inset, 10px));
        right: var(--mobile-floating-inset-x, var(--mobile-floating-inset, 10px));
        width: auto;
        height: auto;
        min-height: var(--bottom-nav-height);
        padding-bottom: 0;
        border-top: none;
        border: 1px solid var(--header-border);
        border-radius: var(--mobile-chrome-radius, var(--radius-xl));
        overflow: hidden;
        background: color-mix(in srgb, var(--header-bg) var(--chrome-surface-mix), transparent);
        backdrop-filter: blur(var(--backdrop-blur-chrome-floating)) saturate(var(--backdrop-saturate-chrome-floating));
        -webkit-backdrop-filter: blur(var(--backdrop-blur-chrome-floating)) saturate(var(--backdrop-saturate-chrome-floating));
        box-shadow: var(--mobile-chrome-shadow);
        z-index: 1001;
    }

    .bottom-nav__container {
        height: var(--bottom-nav-height);
        flex-shrink: 0;
    }

    .bottom-nav-sheet {
        position: static;
        width: 100%;
        pointer-events: none;
        background: transparent;
        border: none;
        box-shadow: none;
        border-radius: 0;
    }

    .bottom-nav.is-more-open .bottom-nav-sheet.is-expanded {
        pointer-events: auto;
        border-bottom: 1px solid var(--header-border);
    }

    .bottom-nav::before {
        opacity: 0.35;
        border-radius: inherit;
    }

    /* Hide the old mobile hamburger menu */
    .mobile-menu-toggle {
        display: none !important;
    }

    /* Hide the old slide-out mobile nav */
    .mobile-nav,
    .mobile-nav-overlay {
        display: none !important;
    }

    /* Add bottom padding to main content */
    .main-content {
        padding-bottom: calc(var(--mobile-bottom-stack, var(--bottom-nav-height)) + var(--spacing-xl));
    }
}

/* Optimize for smaller screens */
@media (max-width: 480px) {
    .bottom-nav__item {
        padding: 0.4rem 0.25rem;
        border-radius: var(--radius-xs);
    }

    .bottom-nav__icon {
        width: 26px;
        height: 26px;
    }

    .bottom-nav__icon i {
        font-size: 1.3rem;
    }

    .bottom-nav__text {
        font-size: 0.65rem;
    }
}

/* Extra small screens */
@media (max-width: 375px) {
    .bottom-nav {
        height: 66px;
    }

    .bottom-nav__container {
        gap: 0.15rem;
        padding: 0 0.35rem;
    }

    .bottom-nav__item {
        padding: 0.35rem 0.2rem;
    }

    .bottom-nav__icon {
        width: 24px;
        height: 24px;
        margin-bottom: 0.1rem;
    }

    .bottom-nav__icon i {
        font-size: 1.25rem;
    }

    .bottom-nav__text {
        font-size: 0.62rem;
    }
}

/* Very small screens */
@media (max-width: 320px) {
    .bottom-nav {
        height: 64px;
    }

    .bottom-nav__icon i {
        font-size: 1.2rem;
    }

    .bottom-nav__text {
        font-size: 0.6rem;
    }
}

/* Theme-specific adjustments (desktop fallback — bottom nav hidden on mobile) */
@media (min-width: 881px) {
    [data-theme="light"] .bottom-nav {
        box-shadow: 0 -4px 20px rgba(148, 163, 184, 0.15);
    }

    [data-theme="dark"] .bottom-nav {
        box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.35);
    }
}

@media (max-width: 880px) {
    [data-theme="light"] .bottom-nav {
        box-shadow: var(--mobile-chrome-shadow-light);
    }

    [data-theme="dark"] .bottom-nav {
        box-shadow: var(--mobile-chrome-shadow);
    }
}

/* Hide scroll when bottom nav is visible (prevent double scrollbar) */
@media (max-width: 880px) {
    body {
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
}

/* ========================================
   Bottom Nav: دکمه «بیشتر» (همان استایل آیتم‌ها)
   ======================================== */
.bottom-nav__item--more {
    border: none;
    background: none;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav__item--more:focus {
    outline: none;
}

.bottom-nav__item--more:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ========================================
   Bottom Sheet: منوی بیشتر (باز از داخل bottom nav)
   ======================================== */
.bottom-nav-sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 997;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.bottom-nav-sheet-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

.bottom-nav-sheet {
    display: none;
}

.bottom-nav-sheet__header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0.35rem 0.35rem 0;
}

.bottom-nav-sheet__close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.25s ease;
}

.bottom-nav-sheet__close:hover {
    background: var(--surface-muted);
}

.bottom-nav-sheet__close i {
    font-size: 1.25rem;
}

.bottom-nav-sheet__body {
    padding: 0.15rem 0.35rem 0.45rem;
}

.bottom-nav-sheet__item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.65rem;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.25s ease;
}

.bottom-nav-sheet__item:hover {
    background: var(--surface-card-hover);
}

.bottom-nav-sheet__item.active {
    color: var(--primary-light);
}

.bottom-nav-sheet__item i {
    font-size: 1.35rem;
    color: var(--text-tertiary);
}

.bottom-nav-sheet__item.active i {
    color: var(--primary-light);
}

/* فقط وقتی bottom nav نمایش داده می‌شود، sheet هم فعال است */
@media (max-width: 880px) {
    .bottom-nav-sheet {
        display: grid;
    }
}

@media (min-width: 881px) {
    .bottom-nav-sheet-overlay,
    .bottom-nav-sheet {
        display: none !important;
    }
}
