/*
 * =============================================================================
 * MOBILNÍ NAVIGACE (< 768px / max-width: 767.98px)
 *
 * Záměr: desktopový .sidebar se na mobilu stane vysouvacím drawerem;
 * nahoře je fixed topbar (hamburger + brand).
 *
 * Logiku (vytvoření DOM, open/close, Escape) řídí výhradně js/shared/ui/mobile-nav.js.
 * Tento soubor je čistě prezentace — žádná datová vrstva / localStorage.
 *
 * Z-index vrstvy (zdola nahoru):
 *   topbar 1200 → backdrop 1350 → drawer .sidebar 1400
 *
 * Na desktopu zůstanou .mobile-topbar / .backdrop / .close skryté
 * následujícími display: none pravidly.
 * =============================================================================
 */

/* --- Desktop: mobilní chrome skrytý (JS prvky se stejně nevytvoří, dokud MQ nesedí) --- */
.mobile-topbar {
    display: none;
}

.mobile-nav-backdrop {
    display: none;
}

.mobile-nav-close {
    display: none;
}

@media (max-width: 767.98px), (hover: none) and (pointer: coarse) and (max-width: 1280px) {
    body {
        overflow-x: hidden;
    }

    /* --- Drawer: desktop sidebar se na mobilu schová a vysune jako panel --- */
    .sidebar {
        display: none !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: min(88vw, 310px) !important;
        max-width: 310px !important;
        height: 100vh !important;
        height: 100dvh !important;
        z-index: 1400 !important;
        margin: 0 !important;
        padding: 1.15rem 1rem 1.35rem !important;
        flex-direction: column !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
        background: #4F46E5 !important;
        box-shadow: 16px 0 40px rgba(15, 23, 42, 0.28);
        transform: translateX(-104%);
    }

    .sidebar-nav {
        flex-direction: column !important;
        flex-wrap: nowrap !important;
    }

    body.mobile-nav-open {
        overflow: hidden;
    }

    body.mobile-nav-open .sidebar {
        display: flex !important;
        transform: translateX(0);
        animation: mobileNavIn 0.3s ease both;
    }

    @keyframes mobileNavIn {
        from { transform: translateX(-104%); }
        to { transform: translateX(0); }
    }

    /* --- Hlavní obsah: prostor pod fixed topbarem --- */
    .main {
        margin-left: 0 !important;
        padding-top: 4.75rem !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /*
     * Obecné odsazení pod topbar. Specifika swipe feedu (kartičky, dock filtrů)
     * řeší css/layout/app-mobile.css — tady jen bezpečný fallback, ať se main
     * nepřekrývá s hamburger lištou.
     */
    .main.is-swipe-mode {
        padding-top: calc(4.75rem + env(safe-area-inset-top, 0px)) !important;
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
        padding-bottom: 0 !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        overflow: hidden !important;
    }

    /* --- Horní lišta (hamburger + brand) --- */
    .mobile-topbar {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1200;
        align-items: center;
        gap: 0.5rem;
        min-height: 3.55rem;
        padding: 0.55rem 0.7rem;
        padding-top: calc(0.55rem + env(safe-area-inset-top, 0px));
        background: var(--sidebar-bg, #3A2E7A);
        color: #fff;
        box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
    }

    .mobile-topbar-brand {
        flex: 0 1 auto;
        min-width: 0;
        /* Typografie 1:1 landing → brand-logo.css; vedle je zvonek */
        display: inline-flex;
        align-items: center;
        gap: 8px;
        text-decoration: none;
        white-space: nowrap;
        overflow: visible;
    }

    .mobile-topbar-brand .sidebar-brand-mark {
        flex-shrink: 0;
    }

    .mobile-topbar-brand .sidebar-brand-wordmark {
        display: inline-flex;
        align-items: baseline;
        flex-shrink: 0;
        letter-spacing: -0.04em;
    }

    .mobile-topbar-brand-wrap {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 0.55rem;
        flex: 1 1 auto;
        min-width: 0;
        width: 100%;
    }

    .mobile-topbar-brand-wrap .sidebar-profile-link {
        display: none !important;
    }

    .mobile-topbar-brand-wrap .mobile-topbar-brand {
        flex: 0 1 auto;
        justify-content: flex-start;
        min-width: 0;
        max-width: calc(100% - 2.75rem);
    }

    .mobile-topbar-brand-wrap .notif-bell-btn {
        flex: 0 0 auto;
    }

    .mobile-topbar-brand:hover,
    .mobile-topbar-brand:focus-visible {
        opacity: 0.9;
        outline: none;
    }

    .mobile-topbar-actions {
        display: inline-flex;
        align-items: center;
        justify-content: flex-end;
        gap: 0.45rem;
        flex-shrink: 0;
        margin-left: auto;
    }

    .mobile-hamburger {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 2.55rem;
        height: 2.55rem;
        flex-shrink: 0;
        border: 1px solid rgba(255, 255, 255, 0.28);
        border-radius: 0.75rem;
        background: rgba(255, 255, 255, 0.12);
        color: #fff;
        cursor: pointer;
        transition: background 0.16s ease, border-color 0.16s ease;
    }

    .mobile-hamburger svg {
        width: 1.25rem;
        height: 1.25rem;
    }

    .mobile-hamburger:hover,
    .mobile-hamburger:focus-visible {
        background: rgba(255, 255, 255, 0.2);
        border-color: rgba(255, 255, 255, 0.45);
        outline: none;
    }

    /* --- Backdrop za otevřeným drawerem --- */
    .mobile-nav-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1350;
        background: rgba(15, 23, 42, 0.48);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.28s ease, visibility 0.28s ease;
        backdrop-filter: blur(2px);
    }

    body.mobile-nav-open .mobile-nav-backdrop {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    /* --- Tlačítko zavření uvnitř draweru --- */
    .mobile-nav-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        align-self: flex-end;
        width: 2.45rem;
        height: 2.45rem;
        margin: 0 0 0.85rem;
        border: 1px solid rgba(255, 255, 255, 0.28);
        border-radius: 0.75rem;
        background: rgba(255, 255, 255, 0.12);
        color: #fff;
        cursor: pointer;
        flex-shrink: 0;
        transition: background 0.16s ease, border-color 0.16s ease;
    }

    .mobile-nav-close svg {
        width: 1.15rem;
        height: 1.15rem;
    }

    .mobile-nav-close:hover,
    .mobile-nav-close:focus-visible {
        background: rgba(255, 255, 255, 0.22);
        border-color: rgba(255, 255, 255, 0.45);
        outline: none;
    }

    /* --- Layout úpravy stránek (zprávy / board) na úzkém viewportu --- */
    .inbox {
        height: auto !important;
        min-height: calc(100vh - 6.5rem);
    }

    .board-layout {
        grid-template-columns: 1fr !important;
    }

    .filter-panel {
        position: static !important;
    }
}
