/* ========================================
   BOTTOM NAVIGATION BAR
   ======================================== */

/* Bottom Navigation Container */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
    z-index: 50;
    padding-bottom: env(safe-area-inset-bottom);
}

/* Hidden state for non-logged users */
.bottom-nav.nav-hidden {
    visibility: hidden;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Navigation Grid */
.bottom-nav-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    max-width: 500px;
    margin: 0 auto;
    padding: 0;
}

/* Navigation Item */
.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 8px 8px;
    text-decoration: none;
    color: #6b7280;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

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

/* Icon */
.bottom-nav-icon {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
    transition: all 0.2s ease;
}

.bottom-nav-item svg {
    width: 100%;
    height: 100%;
}

/* Label */
.bottom-nav-label {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.01em;
    transition: all 0.2s ease;
}

/* Active State */
.bottom-nav-item.active {
    color: #4f46e5;
}

.bottom-nav-item.active .bottom-nav-icon {
    transform: translateY(-2px);
}

.bottom-nav-item.active .bottom-nav-label {
    font-weight: 600;
}

/* Active Indicator */
.bottom-nav-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 40px;
    height: 3px;
    background: linear-gradient(to right, #4f46e5, #7c3aed);
    border-radius: 0 0 3px 3px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.bottom-nav-item.active::before {
    transform: translateX(-50%) scaleX(1);
}

/* Menu Toolbar Overlay */
.menu-toolbar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 45;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.menu-toolbar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Menu Toolbar */
.menu-toolbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.15);
    z-index: 46;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 500px;
    margin: 0 auto;
    padding-bottom: calc(70px + env(safe-area-inset-bottom));
}

.menu-toolbar.active {
    transform: translateY(0);
}

/* Menu Header */
.menu-toolbar-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.menu-toolbar-title {
    font-size: 18px;
    font-weight: 700;
    color: #111827;
}

.menu-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    color: #6b7280;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
}

.menu-close-btn:hover {
    background: #e5e7eb;
    color: #374151;
}

.menu-close-btn:active {
    transform: scale(0.9);
}

/* Menu Items */
.menu-toolbar-content {
    padding: 8px;
}

.menu-toolbar-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    border-radius: 12px;
    text-decoration: none;
    color: #374151;
    transition: all 0.2s ease;
    cursor: pointer;
}

.menu-toolbar-item:hover {
    background: #f9fafb;
}

.menu-toolbar-item:active {
    background: #f3f4f6;
    transform: scale(0.98);
}

.menu-toolbar-item-icon {
    width: 24px;
    height: 24px;
    color: #6b7280;
    flex-shrink: 0;
}

.menu-toolbar-item-content {
    flex: 1;
}

.menu-toolbar-item-title {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 2px;
}

.menu-toolbar-item-desc {
    font-size: 13px;
    color: #6b7280;
}

/* Desktop - hide bottom nav */
@media (min-width: 768px) {
    .bottom-nav {
        display: none;
    }

    .menu-toolbar-overlay:not(#desktop-menu-overlay),
    .menu-toolbar:not(#desktop-menu-toolbar) {
        display: none;
    }
}

/* Spacer to prevent content from being hidden behind bottom nav */
.bottom-nav-spacer {
    height: calc(60px + env(safe-area-inset-bottom));
}

@media (min-width: 768px) {
    .bottom-nav-spacer {
        display: none;
    }
}

/* ========================================
   DESKTOP MENU DROPDOWN
   ======================================== */

/* Desktop menu overlay */
#desktop-menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    display: none;
}

#desktop-menu-overlay.active {
    opacity: 1;
    visibility: visible;
    display: block;
}

/* Desktop menu toolbar */
#desktop-menu-toolbar {
    position: fixed;
    top: 70px;
    right: 20px;
    max-width: 380px;
    width: calc(100% - 40px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    transform: translateY(-20px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding-bottom: 8px;
    display: none;
}

#desktop-menu-toolbar.active {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
    display: block;
}

/* Скрываем desktop menu на мобильных */
@media (max-width: 767px) {
    #desktop-menu-overlay,
    #desktop-menu-toolbar {
        display: none !important;
    }
}

/* ========================================
   MOBILE BACK BUTTON (NEW)
   ======================================== */

/* Кнопка "Назад" для мобильных */
#mobile-back-btn {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 90;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #374151;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
}

#mobile-back-btn:active {
    transform: scale(0.9);
}

#mobile-back-btn svg {
    width: 24px;
    height: 24px;
}

/* Скрываем кнопку по умолчанию */
#mobile-back-btn {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Показываем кнопку когда нужно */
#mobile-back-btn.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* Auto-hide при скролле вниз */
#mobile-back-btn.hidden-scroll {
    opacity: 0;
    transform: translateY(-60px);
}

/* Скрываем на desktop */
@media (min-width: 768px) {
    #mobile-back-btn {
        display: none !important;
    }
}

/* Показываем только для залогиненных на мобильных */
@media (max-width: 767px) {
    body.logged-in #mobile-back-btn {
        /* Стили уже заданы выше */
    }

    body:not(.logged-in) #mobile-back-btn {
        display: none !important;
    }
}
