/* =====================================================================
   APP SHELL — навигационная оболочка
   Desktop: левый сайдбар (220px развёрнут / 64px свёрнут)
   Mobile < 1024px: bottom tab bar (iOS-паттерн, iPhone 16 Pro)
   ===================================================================== */

/* ── Корневой контейнер ────────────────────────────────────────────── */
.app-shell {
    display: flex;
    min-height: 100dvh;
}

/* ══════════════════════════════════════════════════════════════════════
   ЛЕВЫЙ САЙДБАР (desktop ≥ 1024px)
   ══════════════════════════════════════════════════════════════════════ */
.app-sidebar {
    width: 220px;
    background: #070b12;
    border-right: 1px solid rgba(255, 255, 255, 0.055);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 300;
    display: flex;
    flex-direction: column;
    transition: width 220ms cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    will-change: width;
}

.app-sidebar.collapsed {
    width: 64px;
}

/* ── Логотип ─────────────────────────────────────────────────────── */
.app-sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 18px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
    overflow: hidden;
    min-height: 64px;
}

.app-sidebar-logo-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.app-sidebar-logo-icon i {
    color: #fff;
    font-size: 13px;
}

.app-sidebar-logo-text {
    font-size: 14px;
    font-weight: 700;
    color: #e2e8f0;
    white-space: nowrap;
    letter-spacing: -0.02em;
    opacity: 1;
    max-width: 180px;
    overflow: hidden;
    line-height: 1;
    transition: opacity 180ms ease,
                max-width 220ms cubic-bezier(0.4, 0, 0.2, 1);
}

.app-sidebar-logo-sub {
    font-size: 10px;
    color: #4a5568;
    font-weight: 400;
    display: block;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-top: 2px;
}

.app-sidebar.collapsed .app-sidebar-logo-text {
    opacity: 0;
    max-width: 0;
    pointer-events: none;
}

.app-sidebar.collapsed .app-sidebar-logo {
    gap: 0;
}

/* ── Nav-список ──────────────────────────────────────────────────── */
.app-sidebar-nav {
    flex: 1;
    padding: 10px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    overflow-x: hidden;
}

.app-sidebar-nav::-webkit-scrollbar { display: none; }

.app-nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 11px;
    border-radius: 10px;
    cursor: pointer;
    color: #6b7280;
    border: none;
    background: none;
    white-space: nowrap;
    width: 100%;
    text-align: left;
    transition: background 150ms ease, color 150ms ease;
    position: relative;
}

.app-nav-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #c9d1db;
}

.app-nav-item.active {
    background: rgba(0, 212, 170, 0.1);
    color: #00d4aa;
}

.app-nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: #00d4aa;
    border-radius: 0 3px 3px 0;
}

.app-nav-item i {
    width: 20px;
    text-align: center;
    font-size: 15px;
    flex-shrink: 0;
    transition: color 150ms ease;
}

.app-nav-item span.app-nav-label {
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1;
    opacity: 1;
    max-width: 180px;
    overflow: hidden;
    white-space: nowrap;
    flex: 1;
    transition: opacity 180ms ease,
                max-width 220ms cubic-bezier(0.4, 0, 0.2, 1);
}

.app-sidebar.collapsed .app-nav-item span.app-nav-label {
    opacity: 0;
    max-width: 0;
    pointer-events: none;
}

/* Tooltip при свёрнутом сайдбаре */
.app-sidebar.collapsed .app-nav-item {
    justify-content: center;
    padding: 11px 0;
    gap: 0;
}

.app-sidebar.collapsed .app-nav-item::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    background: #1a2030;
    color: #e2e8f0;
    font-size: 12px;
    font-weight: 500;
    padding: 6px 10px;
    border-radius: 7px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    transition: opacity 150ms ease;
    z-index: 400;
}

.app-sidebar.collapsed .app-nav-item:hover::after {
    opacity: 1;
}

/* ── Хедер: FAQ только на mobile ────────────────────────────────── */
.header-controls--mobile-only {
    display: flex;
}

/* ── Разделитель в nav-списке ────────────────────────────────────── */
.app-nav-sep {
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    margin: 6px 8px;
    flex-shrink: 0;
}

/* ── Logout-кнопка (красный акцент при hover) ────────────────────── */
.app-nav-logout:hover {
    background: rgba(239, 68, 68, 0.1) !important;
    color: #f87171 !important;
}
.app-nav-logout:hover i {
    color: #f87171;
}

/* ── Нижняя часть сайдбара ───────────────────────────────────────── */
.app-sidebar-footer {
    padding: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}

.app-sidebar-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 11px;
    border-radius: 10px;
    border: none;
    background: none;
    color: #4a5568;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 150ms, color 150ms;
    white-space: nowrap;
}

.app-sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #94a3b8;
}

.app-sidebar-toggle i {
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    font-size: 13px;
    transition: transform 220ms cubic-bezier(0.4, 0, 0.2, 1);
}

.app-sidebar-toggle span {
    opacity: 1;
    max-width: 180px;
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 180ms ease,
                max-width 220ms cubic-bezier(0.4, 0, 0.2, 1);
}

.app-sidebar.collapsed .app-sidebar-toggle {
    justify-content: center;
    padding: 11px 0;
    gap: 0;
}

.app-sidebar.collapsed .app-sidebar-toggle span {
    opacity: 0;
    max-width: 0;
    pointer-events: none;
}

.app-sidebar.collapsed .app-sidebar-toggle i {
    transform: rotate(180deg);
}

/* ══════════════════════════════════════════════════════════════════════
   ОСНОВНАЯ ОБЛАСТЬ КОНТЕНТА
   ══════════════════════════════════════════════════════════════════════ */
.app-main {
    flex: 1;
    margin-left: 220px;
    min-height: 100dvh;
    transition: margin-left 220ms cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.app-sidebar.collapsed ~ .app-main {
    margin-left: 64px;
}

/* ── Views ───────────────────────────────────────────────────────── */
.app-view {
    display: none;
}

.app-view.active {
    display: block;
}

/* ── Анимация смены вью ──────────────────────────────────────────── */
.app-view.view-enter {
    animation: viewFadeIn 200ms ease forwards;
}

@keyframes viewFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════════════════════════════════════════════
   BOTTOM TAB BAR (mobile < 1024px, iOS-паттерн)
   ══════════════════════════════════════════════════════════════════════ */
.app-bottom-nav {
    display: none; /* скрыт на desktop */
}

/* ══════════════════════════════════════════════════════════════════════
   MOBILE BREAKPOINT ≤ 1023px
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 1023px) {

    /* Скрываем sidebar */
    .app-sidebar {
        display: none;
    }

    /* app-main растягивается на весь экран — сбрасываем ОБА варианта margin */
    .app-main,
    .app-sidebar.collapsed ~ .app-main {
        margin-left: 0;
        /* Отступ снизу под bottom nav */
        padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    }

    /* ── Bottom Tab Bar ─────────────────────────────────────── */
    .app-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 300;
        background: rgba(7, 11, 18, 0.96);
        backdrop-filter: blur(16px) saturate(1.4);
        -webkit-backdrop-filter: blur(16px) saturate(1.4);
        border-top: 1px solid rgba(255, 255, 255, 0.07);
        /* iOS safe area */
        height: calc(64px + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        align-items: flex-start;
        padding-top: 0;
    }

    .app-bnav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        height: 64px;
        padding: 8px 4px;
        background: none;
        border: none;
        color: #4b5563;
        cursor: pointer;
        transition: color 150ms ease;
        -webkit-tap-highlight-color: transparent;
        position: relative;
        min-width: 0;
    }

    .app-bnav-item.active {
        color: #00d4aa;
    }

    /* Активный индикатор — точка над иконкой */
    .app-bnav-item.active::before {
        content: '';
        position: absolute;
        top: 6px;
        left: 50%;
        transform: translateX(-50%);
        width: 4px;
        height: 4px;
        border-radius: 50%;
        background: #00d4aa;
    }

    .app-bnav-item i {
        font-size: 20px;
        line-height: 1;
        transition: transform 150ms ease;
    }

    .app-bnav-item.active i {
        transform: scale(1.1);
    }

    .app-bnav-item span {
        font-size: 10px;
        font-weight: 500;
        line-height: 1;
        letter-spacing: 0.01em;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
        padding: 0 2px;
    }

    /* Tap-эффект */
    .app-bnav-item:active i {
        transform: scale(0.92);
    }

    /* ── Компактный хедер на мобильном ─────────────────────── */
    .header {
        padding: 10px 0;
        /* Отступ под Dynamic Island / notch */
        padding-top: max(10px, env(safe-area-inset-top, 0px));
    }

    .header h1 {
        font-size: 16px;
    }

    /* ── Контейнер контента ─────────────────────────────────── */
    .container {
        padding: 12px;
    }
}

/* ══════════════════════════════════════════════════════════════════════
   TABLET 768px – 1023px (промежуточное состояние)
   ══════════════════════════════════════════════════════════════════════ */
@media (min-width: 768px) and (max-width: 1023px) {
    .app-bnav-item span {
        font-size: 11px;
    }

    .app-bnav-item i {
        font-size: 22px;
    }
}

/* ══════════════════════════════════════════════════════════════════════
   КОНТЕЙНЕР ВНУТРИ APP-SHELL — всегда на всю доступную ширину.
   Используем .app-shell .container (специфитет 0,2,0) чтобы
   гарантированно перебить max-width:1400px из main.css (0,1,0).
   ══════════════════════════════════════════════════════════════════════ */
.app-shell .container {
    max-width: 100%;
    margin: 0;
    padding: 20px 24px;
}

/* ══════════════════════════════════════════════════════════════════════
   DESKTOP ≥ 1024px — тонкая подстройка
   ══════════════════════════════════════════════════════════════════════ */
@media (min-width: 1024px) {
    /* На desktop хедер скрыт — сайдбар берёт на себя брендинг и аккаунт */
    .header {
        display: none !important;
    }
}

/* ══════════════════════════════════════════════════════════════════════
   LARGE DESKTOP ≥ 1440px — чуть больше padding для воздуха
   ══════════════════════════════════════════════════════════════════════ */
@media (min-width: 1440px) {
    .app-shell .container {
        padding: 20px 32px;
    }
}
