/**
 * شريط تنقل علوي ثابت للجوال — الأقسام تحت الهيدer مباشرة
 */

@media (max-width: 768px) {
    #mainApp {
        padding-bottom: 0;
    }

    .app-header {
        position: sticky;
        top: 0;
        z-index: 9000;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        margin-bottom: 4px;
        box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22);
        padding: 12px 12px 10px !important;
        gap: 10px !important;
    }

    body.light-mode .app-header {
        box-shadow: 0 4px 18px rgba(15, 23, 42, 0.1);
    }

    .app-header .header-top-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .app-header .header-brand-strip {
        width: 100%;
        flex-direction: row;
        align-items: center;
        gap: 10px;
    }

    .app-header .logo-text {
        flex: 1;
        min-width: 0;
    }

    .app-header .header-title-line,
    .app-header .logo-title-row {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: 8px;
        width: 100%;
    }

    .app-header .logo-area h1 {
        font-size: 14px !important;
        line-height: 1.3;
        white-space: nowrap;
        margin: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        flex: 1 1 auto;
        min-width: 0;
    }

    .app-header .app-version-badge {
        flex-shrink: 0;
        margin-inline-start: 4px;
    }

    .app-header .header-toolbar-row,
    .app-header .header-actions {
        width: 100%;
        justify-content: flex-end;
        flex-wrap: nowrap;
        gap: 6px;
        flex-shrink: 0;
    }

    .app-header .brand-logo {
        width: auto !important;
        height: 54px !important;
        max-width: 132px !important;
        min-width: 48px;
        object-fit: contain;
    }

    .app-header .user-badge {
        max-width: min(128px, 34vw);
        flex-shrink: 1;
        min-width: 0;
        padding: 6px 9px;
    }

    .app-header .user-display-name {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
        font-size: 11px;
    }

    .app-header     .role-badge {
        font-size: 9px;
    }

    .app-header .header-toolbar-btn,
    .app-header .header-update-btn,
    .app-header .theme-toggle-btn,
    .app-header .header-chat-btn {
        width: 42px !important;
        height: 42px !important;
        min-width: 42px !important;
        border-radius: 11px !important;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        font-size: 16px !important;
        padding: 0 !important;
        flex-shrink: 0;
    }

    .app-header .header-update-btn {
        display: inline-flex !important;
        background: rgba(37, 99, 235, 0.14);
        border: 1px solid rgba(37, 99, 235, 0.32);
        color: #60a5fa;
    }

    body.light-mode .app-header .header-update-btn {
        background: rgba(37, 99, 235, 0.1);
        border-color: rgba(37, 99, 235, 0.28);
        color: #2563eb;
    }

    .app-header .logout-btn {
        width: 42px !important;
        height: 42px !important;
        min-width: 42px !important;
    }

    /* شريط المهام — أعلى تحت الاسم مباشرة */
    .app-header #mainNav {
        position: static;
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: stretch;
        gap: 6px;
        width: 100%;
        margin: 0;
        padding: 8px 4px 4px;
        border-radius: 12px;
        border: 1px solid rgba(255, 255, 255, 0.08);
        background: rgba(0, 0, 0, 0.18);
        box-shadow: none;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
    }

    body.light-mode .app-header #mainNav {
        background: rgba(15, 23, 42, 0.04);
        border-color: rgba(15, 23, 42, 0.08);
    }

    .app-header #mainNav .nav-hub-row,
    .app-header #mainNav .nav-hub-sections {
        display: contents;
    }

    .app-header #mainNav .nav-tile {
        flex: 0 0 auto;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
        gap: 4px;
        min-width: 68px;
        max-width: 82px;
        min-height: 58px;
        padding: 7px 5px;
        border-radius: 11px;
        font-size: 10px;
        line-height: 1.2;
        scroll-snap-align: start;
        box-shadow: none;
        opacity: 0.9;
    }

    .app-header #mainNav .nav-tile i {
        font-size: 18px;
        width: auto;
        margin: 0;
    }

    .app-header #mainNav .nav-tile span {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        max-width: 74px;
        line-height: 1.15;
        font-size: 9.5px;
        font-weight: 600;
    }

    .app-header #mainNav .nav-tile.active {
        opacity: 1;
        box-shadow: 0 3px 12px rgba(0, 0, 0, 0.22);
        border-width: 1.5px;
        transform: none;
    }

    .app-header #mainNav .nav-tile.hidden {
        display: none !important;
    }

    #rafidainUpdateFab {
        bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important;
    }
}

@media (max-width: 768px) and (display-mode: standalone) {
    .app-header {
        padding-top: calc(12px + env(safe-area-inset-top, 0px)) !important;
    }
}
