/* ============================================================================
   Bara de sus pe telefon — sigla MindloopOne pe orice pagină (≤ 768 px)
   ----------------------------------------------------------------------------
   Markup: `#mobileBrandBar` = primul copil al `#dashboardContainer` (index.html) ⇒ apare DOAR după login
   (containerul e `display:none` fără clasa `active`). Clic pe siglă: public/js/mobileBrandBar.js.
   Pragul (768 px) = același ca bara de jos (`.mobile-bottom-nav`), sidebar ascuns și watcher-ul de
   overlay-uri din app.js.
   - Înălțimea: `--mlbb-h` (52 px) + zona sigură iOS de sus. Conținutul coboară prin padding-top pe
     `.dashboard.active` (coloana flex), NU pe `.main-content`: `.main-content` e containerul care
     derulează, deci antetele `position:sticky; top:0` din pagini se lipesc SUB bară, nu dedesubtul ei.
   - z-index 800: peste conținutul paginilor (≤ 200), SUB orice fereastră / panou / foaie de jos
     (modale 1000+, panoul „Mai mult”, `#mobileNavOverlay`, Agentul Suport 9000+, apelul Centrala 10000+,
     overlay-urile webinar 850+).
   - Rândul: [siglă] [pastila „Caută…” — flex] [clopoțelele]. Pastila deschide fereastra de căutare (ErpSearch) și
     clopoțelele WhatsApp `.wa-bell-root` / ERP `.erp-notif-root` stau ÎN bară, în flux (mutate în `#mobileBrandBells`
     de public/js/mlTopBar.js). Sub ~400 px numele „MindloopOne” se ascunde (rămâne simbolul).
   - Desktop: nimic (bara e `display:none` peste 768 px).
   ============================================================================ */

.mlbb { display: none; }

@media (max-width: 768px) {
    :root { --mlbb-h: 52px; }

    .dashboard.active > .mlbb {
        display: flex;
        align-items: center;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 800;
        box-sizing: border-box;
        height: calc(var(--mlbb-h) + env(safe-area-inset-top, 0px));
        gap: 8px;
        padding: env(safe-area-inset-top, 0px) 10px 0 12px;
        margin: 0;
        background: #ffffff;
        border-bottom: 1px solid #e2e8f0;
        box-shadow: none;
    }

    /* Conținutul începe sub bară — o singură dată (coloana flex, nu fiecare pagină) */
    #dashboardContainer.dashboard.active {
        padding-top: calc(var(--mlbb-h) + env(safe-area-inset-top, 0px)) !important;
        box-sizing: border-box;
    }

    .mlbb .mlbb-brand {
        display: inline-flex !important;
        align-items: center;
        gap: 8px;
        min-height: 44px;
        max-width: 100%;
        margin: 0 0 0 -6px;
        padding: 0 8px !important;
        border: 0 !important;
        border-radius: 8px !important;
        background: transparent !important;
        box-shadow: none !important;
        color: #0f172a !important;
        font: inherit;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        text-decoration: none;
    }
    .mlbb .mlbb-brand:hover { background: #f1f5f9 !important; }
    .mlbb .mlbb-brand:active { background: #e2e8f0 !important; }
    .mlbb .mlbb-brand:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(37, 99, 235, .25) !important; }

    .mlbb .mlbb-mark {
        flex: 0 0 auto;
        display: block;
        width: auto;
        height: 28px;
        margin: 0;
    }
    .mlbb .mlbb-name {
        font-size: 18px;
        line-height: 1;
        color: #141c30 !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mlbb .mlbb-brand { flex: 0 1 auto; min-width: 0; }

    /* Pastila „Caută…” (public/js/mlTopBar.js → fereastra ErpSearch) — ocupă spațiul rămas, discretă */
    .mlbb .mlbb-find {
        display: inline-flex !important;
        align-items: center;
        gap: 8px;
        flex: 1 1 auto;
        min-width: 0;
        height: 38px;
        margin: 0;
        padding: 0 12px !important;
        border: 1px solid #d3dbe5 !important;
        border-radius: 999px !important;
        background: #f8fafc !important;
        box-shadow: none !important;
        color: #64748b !important;
        font-family: inherit;
        font-size: 15px;
        font-weight: 400 !important;
        line-height: 1;
        text-align: left;
        cursor: text;
        -webkit-tap-highlight-color: transparent;
    }
    .mlbb .mlbb-find:active { background: #eef2f7 !important; }
    .mlbb .mlbb-find:focus-visible { outline: none; border-color: #2563eb !important; box-shadow: 0 0 0 3px rgba(37, 99, 235, .2) !important; }
    .mlbb .mlbb-find-ico { flex: 0 0 16px; width: 16px; height: 16px; fill: none; stroke: #64748b; stroke-width: 2.2; stroke-linecap: round; }
    .mlbb .mlbb-find-ph { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #64748b !important; }

    /* Clopoțelele (WhatsApp, ERP) în bară, în flux — 40 px; panourile se deschid imediat sub bară */
    .mlbb .mlbb-bells { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
    .mlbb .mlbb-bells:empty { display: none; }
    html body .mlbb-bells .erp-notif-root,
    html body .mlbb-bells .wa-bell-root { position: relative !important; top: auto !important; right: auto !important; left: auto !important; z-index: auto !important; }
    html body .mlbb-bells .erp-notif-bell,
    html body .mlbb-bells .wa-bell-btn { width: 40px !important; height: 40px !important; font-size: 18px !important; box-shadow: none !important; }
    html body .mlbb-bells .erp-notif-panel,
    html body .mlbb-bells .wa-bell-panel {
        position: fixed !important;
        top: calc(var(--mlbb-h) + env(safe-area-inset-top, 0px) + 4px) !important;
        left: 10px !important;
        right: 10px !important;
        width: auto !important;
        max-width: none !important;
        max-height: calc(100vh - 150px) !important;
        z-index: 9400;
    }
    /* Bara are z 800 (context de suprapunere): cât e deschis panoul unui clopoțel ea urcă la 9400, ca panoul să stea
       peste conținut și butoanele plutitoare (➕), dar SUB ferestre (ErpUi 9500, 10000+). Panoul se închide la clic în afară. */
    .dashboard.active > .mlbb:has(.erp-notif-panel:not([hidden]), .wa-bell-panel:not([hidden])) { z-index: 9400; }

    /* Ecrane foarte înguste: doar simbolul siglei, ca pastila să rămână lizibilă */
    @media (max-width: 400px) {
        .mlbb .mlbb-name { display: none; }
        .mlbb .mlbb-brand { padding: 0 4px !important; margin-left: -4px; }
    }

    /* Panourile de meniu (ERP, CRM, Clinică…): sigla în rândul titlului (mobileBrandBar.js → decorateSheetHeaders) */
    .mobile-nav-group-sheet-header .mlbb-sheet-brand {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        flex: 0 0 auto;
        height: 28px;
        padding-right: 10px;
        border-right: 1px solid #e2e8f0;
    }
    .mobile-nav-group-sheet-header .mlbb-sheet-mark { width: auto; height: 22px; margin: 0; }
    .mobile-nav-group-sheet-header .mlbb-sheet-name { font-size: 15px; line-height: 1; color: #141c30 !important; white-space: nowrap; }
    .mobile-nav-group-sheet-header h3.mlbb-sheet-title {
        flex: 1 1 auto;
        min-width: 0;
        margin: 0 0 0 2px !important;
        font-size: 17px !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Mod kiosk POS (doar ecranul de vânzare): fără bară, fără spațiu */
    body.pos-kiosk .dashboard.active > .mlbb { display: none !important; }
    body.pos-kiosk #dashboardContainer.dashboard.active { padding-top: 0 !important; }

    @media print {
        .dashboard.active > .mlbb { display: none !important; }
        #dashboardContainer.dashboard.active { padding-top: 0 !important; }
    }
}
