/* ═══════════════════════════════════════════════════════════════
   EngiGROUP — mobile-nav.css  (финальная версия 4 — ИСПРАВЛЕННАЯ)
   Подключить в App.razor:
     <link rel="stylesheet" href="css/mobile-nav.css?v=4" />
   ═══════════════════════════════════════════════════════════════ */


/* ─────────────────────────────────────────────────────────────
   НИЖНЯЯ НАВИГАЦИЯ — скрыта на десктопе
   ───────────────────────────────────────────────────────────── */
.ec-bnav {
    display: none;
}


/* ─────────────────────────────────────────────────────────────
   ВЕРХНЯЯ ПАНЕЛЬ (публичная зона — неавторизованные)
   Фикс: перенос «О продукте», масштабирование по ширине экрана
   ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {

    .ec-pub-nav-inner {
        padding: 0 12px;
        gap: 4px;
    }

    .ec-pub-nav-logo {
        font-size: 16px;
        flex-shrink: 0;
    }

    .ec-pub-nav-links {
        gap: 2px;
        flex-shrink: 1;
        min-width: 0;
    }

    .ec-pub-nav-link,
    .ec-pub-nav-cta {
        font-size: 12px;
        white-space: nowrap; /* запрет переноса внутри ссылки */
    }

    .ec-pub-nav-link {
        padding: 7px 8px;
    }

    .ec-pub-nav-cta {
        padding: 7px 12px;
        flex-shrink: 0;
    }
}

@media (max-width: 360px) {
    /* На совсем маленьких — убираем «О продукте», остаются Войти + Регистрация */
    .ec-pub-nav-link:first-child {
        display: none;
    }

    .ec-pub-nav-inner {
        padding: 0 10px;
    }
}


/* ─────────────────────────────────────────────────────────────
   FAB «Связь с оператором»
   Логика через CSS-каскад без JS:
   — внутри .ec-layout-shell (авторизован, есть bottom nav)
     → поднять на 88px
   — вне .ec-layout-shell (не авторизован, bottom nav нет)
     → оставить на штатном bottom:22px, label скрыть
   ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {

    /* Неавторизованная зона — стандартная позиция, без label */
    .ec-admin-fab {
        right: 14px;
        width: 44px;
        height: 44px;
        padding: 0;
    }

        .ec-admin-fab:hover,
        .ec-admin-fab:active {
            width: 44px;
            padding: 0;
            gap: 0;
            justify-content: center;
            transform: none;
        }

            .ec-admin-fab:hover .ec-admin-fab-label,
            .ec-admin-fab:active .ec-admin-fab-label {
                max-width: 0;
                opacity: 0;
            }

    /* Авторизованная зона — FAB над bottom nav */
    .ec-layout-shell .ec-admin-fab {
        bottom: 88px; /* 76px панель + 12px зазор */
    }
}


/* ─────────────────────────────────────────────────────────────
   ОСНОВНОЙ МОБИЛЬНЫЙ БЛОК ≤768px
   ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {

    /* ══════════════════════════════════════════════════════
       TOUCH-ОПТИМИЗАЦИЯ — увеличение областей нажатия
       ══════════════════════════════════════════════════════ */
    .ec-bnav-item {
        position: relative;
        min-height: 54px;
        min-width: 48px;
    }

        .ec-bnav-item::after {
            content: '';
            position: absolute;
            inset: -6px;
            z-index: -1;
        }

        .ec-bnav-item:active {
            opacity: .7;
            transform: scale(.94);
            transition: transform 60ms ease, opacity 60ms ease;
        }

    /* Фикс overlay — принудительный pointer-events */
    .ec-sheet-overlay.open {
        pointer-events: auto !important;
    }

    .ec-sheet.open {
        pointer-events: auto !important;
        transform: translateY(0) !important;
    }

    /* FAB — GPU-ускорение и страховка z-index */
    .ec-admin-fab {
        will-change: transform;
        transform: translateZ(0);
    }

    /* Ускорение анимаций шторки */
    .ec-sheet {
        transition-duration: .22s;
    }

    /* Убираем боковую навигацию и хедер-гамбургер */
    .ec-side-nav,
    .ec-side-nav-overlay,
    .ec-mobile-header {
        display: none !important;
    }

    /* Контентная зона: убрать отступ под сайдбар */
    .ec-layout-content {
        margin-left: 0 !important;
        padding-bottom: 76px !important;
    }

    /* Основная зона: отступ снизу + 100% ширины */
    .ec-layout-main {
        padding-bottom: 88px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
        padding-left: 14px;
        padding-right: 14px;
    }

        /* Все корневые контейнеры не вылезают за экран */
        .ec-layout-shell,
        .ec-layout-content,
        .ec-layout-main > * {
            box-sizing: border-box;
            max-width: 100% !important;
        }


    /* ══════════════════════════════════════════════════════
       НИЖНЯЯ ПАНЕЛЬ НАВИГАЦИИ .ec-bnav
       ══════════════════════════════════════════════════════ */
    .ec-bnav {
        display: flex;
        justify-content: space-around;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 100;
        background: rgba(255, 255, 255, .92);
        -webkit-backdrop-filter: saturate(180%) blur(24px);
        backdrop-filter: saturate(180%) blur(24px);
        border-top: 1px solid var(--ec-border-soft);
        padding: 6px 4px 8px;
        padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
        box-shadow: 0 -4px 24px rgba(0, 0, 0, .06);
    }

    .ec-bnav-item {
        flex: 0 1 auto;
        min-height: 54px;
        min-width: auto;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        padding: 4px 6px;
        color: var(--ec-sub);
        text-decoration: none;
        background: transparent;
        border: none;
        cursor: pointer;
        font-family: var(--ec-font-sans);
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        transition: color 120ms ease;
        border-radius: 10px;
    }

        .ec-bnav-item.is-active {
            color: var(--ec-accent);
        }

        .ec-bnav-item:active {
            opacity: .7;
            transform: scale(.94);
            transition: transform 80ms ease, opacity 80ms ease;
        }

    .ec-bnav-icon {
        width: 22px;
        height: 22px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        position: relative;
    }

    .ec-bnav-label {
        font-size: 9px;
        font-weight: 500;
        letter-spacing: -.01em;
        line-height: 1;
        white-space: nowrap;
    }

    .ec-bnav-item.is-active .ec-bnav-label {
        font-weight: 600;
    }

    .ec-bnav-badge {
        position: absolute;
        top: -3px;
        right: -7px;
        min-width: 15px;
        height: 15px;
        padding: 0 4px;
        border-radius: 999px;
        background: var(--ec-danger);
        color: #fff;
        font-size: 9px;
        font-weight: 700;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border: 1.5px solid rgba(255, 255, 255, .95);
        pointer-events: none;
    }


    /* ══════════════════════════════════════════════════════
       BOTTOM SHEET
       ══════════════════════════════════════════════════════ */
    .ec-sheet-overlay {
        position: fixed;
        inset: 0;
        z-index: 200;
        background: rgba(0, 0, 0, .42);
        -webkit-backdrop-filter: blur(2px);
        backdrop-filter: blur(2px);
        opacity: 0;
        pointer-events: none;
        transition: opacity .22s cubic-bezier(.4, 0, .2, 1);
    }

        .ec-sheet-overlay.open {
            opacity: 1;
            pointer-events: auto;
        }

    .ec-sheet {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 201;
        background: var(--ec-surface);
        border-radius: 24px 24px 0 0;
        box-shadow: 0 -8px 32px rgba(0, 0, 0, .16);
        transform: translateY(100%);
        transition: transform .28s cubic-bezier(.16, 1, .3, 1);
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 76px);
        max-height: 88vh;
        overflow-y: auto;
    }

        .ec-sheet.ec-sheet--card {
            border-radius: 20px 20px 0 0;
        }

        .ec-sheet.open {
            transform: translateY(0);
        }

    .ec-sheet-handle-row {
        display: flex;
        justify-content: center;
        padding: 10px 0 0;
    }

    .ec-sheet-handle {
        width: 36px;
        height: 4px;
        border-radius: 2px;
        background: var(--ec-border);
        display: block;
    }

    .ec-sheet-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 10px 20px 6px;
    }

    .ec-sheet-title {
        margin: 0;
        font-size: 17px;
        font-weight: 700;
        letter-spacing: -.02em;
        color: var(--ec-text);
    }

    .ec-sheet-close {
        width: 32px;
        height: 32px;
        border-radius: 16px;
        border: none;
        background: var(--ec-surface-2);
        color: var(--ec-sub);
        cursor: pointer;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .ec-sheet-body {
        padding: 4px 8px 12px;
    }

    .ec-sheet-body--card {
        padding: 6px 14px 16px;
    }

    .ec-sheet-item {
        display: flex;
        gap: 14px;
        align-items: center;
        width: 100%;
        text-decoration: none;
        border-radius: 14px;
        color: var(--ec-text);
        background: transparent;
        border: none;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        transition: background 120ms ease;
    }

        .ec-sheet-item.ec-sheet-item--card {
            padding: 14px;
            margin-bottom: 8px;
            min-height: 64px;
            background: var(--ec-bg-soft);
            border: 1px solid var(--ec-border-soft);
        }

            .ec-sheet-item.ec-sheet-item--card:hover,
            .ec-sheet-item.ec-sheet-item--card:active {
                background: var(--ec-accent-soft);
            }

        .ec-sheet-item:not(.ec-sheet-item--card) {
            padding: 14px 16px;
            min-height: 56px;
        }

            .ec-sheet-item:not(.ec-sheet-item--card):hover,
            .ec-sheet-item:not(.ec-sheet-item--card):active {
                background: var(--ec-surface-2);
            }

        .ec-sheet-item.ec-sheet-item--danger {
            color: var(--ec-danger) !important;
        }

    .ec-sheet-item-icon {
        width: 40px;
        height: 40px;
        border-radius: 10px;
        flex-shrink: 0;
        background: var(--ec-accent-soft);
        color: var(--ec-accent-deep);
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

        .ec-sheet-item-icon.ec-sheet-item-icon--danger {
            background: var(--ec-danger-bg);
            color: var(--ec-danger);
        }

    .ec-sheet-item-icon-list {
        width: 32px;
        height: 32px;
        flex-shrink: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        color: var(--ec-sub);
    }

    .ec-sheet-item--danger .ec-sheet-item-icon-list {
        color: var(--ec-danger);
    }

    .ec-sheet-item-text {
        flex: 1;
        min-width: 0;
    }

    .ec-sheet-item-label {
        font-size: 15px;
        font-weight: 600;
        color: inherit;
    }

    .ec-sheet-item-sub {
        font-size: 12px;
        color: var(--ec-sub);
        margin-top: 1px;
        font-weight: 400;
    }

    .ec-sheet-item--danger .ec-sheet-item-sub {
        color: var(--ec-danger);
        opacity: .75;
    }

    .ec-sheet-item-chev {
        width: 16px;
        height: 16px;
        display: inline-flex;
        color: var(--ec-faint);
        flex-shrink: 0;
    }


    /* ══════════════════════════════════════════════════════
       ФИКСЫ СТРАНИЦ — пропадающая нижняя навигация
       height:calc(100vh) + overflow:hidden создают stacking
       context, в котором position:fixed не прилипает к viewport
       ══════════════════════════════════════════════════════ */
    .ec-notes-shell {
        height: auto !important;
        min-height: 0 !important;
        flex-direction: column !important;
    }

    .ec-notes-sidebar {
        width: 100% !important;
        max-height: 220px !important;
        overflow-y: auto !important;
    }

    .ec-notes-editor {
        height: auto !important;
        overflow: visible !important;
        min-height: 360px;
    }

    .ec-calc-root,
    .ec-std-root,
    .ec-boards-root,
    .ec-lib-root {
        overflow: visible !important;
        height: auto !important;
    }

    /* Страховка: inline overflow:hidden на прямых потомках main */
    .ec-layout-main > [style*="overflow: hidden"],
    .ec-layout-main > [style*="overflow:hidden"] {
        overflow: visible !important;
    }


    /* ══════════════════════════════════════════════════════
       TOUCH / ACCESSIBILITY / АДАПТИВНОСТЬ
       ══════════════════════════════════════════════════════ */
    button, a, [role="button"] {
        touch-action: manipulation;
    }

    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="search"],
    input[type="tel"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px !important; /* предотвращаем авто-зум iOS */
    }

    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }

    img {
        max-width: 100%;
        height: auto;
    }

    .ec-card {
        box-sizing: border-box;
        max-width: 100%;
    }
}


/* ─────────────────────────────────────────────────────────────
   ОЧЕНЬ МАЛЕНЬКИЕ ЭКРАНЫ ≤360px
   ───────────────────────────────────────────────────────────── */
@media (max-width: 360px) {
    .ec-bnav-label {
        font-size: 8px;
    }
}
