/*
 * Menu layouts for the rail (views/cpos/_rail.php), picked in the 🎨 panel
 * (html[data-nav], partials/ui_head.php):
 *   rail  - the icon rail (rail.css, unchanged)
 *   side  - wide side menu with names, full height
 *   float - wide side menu floating on the page, rounded
 *   top   - menu bar along the top of the page
 * The wide menus need room: on tablets (768-1199px) they fall back to the
 * icon rail; phones always keep the bottom bar.
 * Designs A-H (skins.css, --sb-*) also colour the menu on tablet and up.
 */

/* Name beside the logo: hidden in the icon rail. */
.mp-brand { display: contents; }
.mp-brand-n { display: none; }

/* ---------- Designs: menu colours (tablet and up) ---------- */
@media (min-width: 768px) {
    html:is([data-skin^="ds-"], [data-skin="g-pastel"]) .mp-rail.mp-rail {
        background: var(--sb) !important; border-color: var(--sb-bd) !important; color: var(--sb-tx);
    }
    html:is([data-skin^="ds-"], [data-skin="g-pastel"]) .mp-rail .mp-ri { color: var(--sb-tx) !important; opacity: .92; }
    html:is([data-skin^="ds-"], [data-skin="g-pastel"]) .mp-rail .mp-ri:hover,
    html:is([data-skin^="ds-"], [data-skin="g-pastel"]) .mp-rail .mp-ri.open { background: color-mix(in srgb, var(--sb-tx) 12%, transparent); opacity: 1; }
    html:is([data-skin^="ds-"], [data-skin="g-pastel"]) .mp-rail .mp-ri.on { background: var(--sb-on) !important; color: var(--sb-on-tx) !important; box-shadow: none; opacity: 1; }
    html:is([data-skin^="ds-"], [data-skin="g-pastel"]) .mp-rail .mp-ri-n { background: var(--sb-badge); color: var(--sb-badge-tx); }
    html:is([data-skin^="ds-"], [data-skin="g-pastel"]) .mp-rail .mp-avatar { background: color-mix(in srgb, var(--sb-tx) 14%, transparent) !important; color: var(--sb-tx) !important; border-color: transparent !important; }
    html:is([data-skin^="ds-"], [data-skin="g-pastel"]) .mp-brand-n { color: var(--sb-tx) !important; }
    html:is([data-skin^="ds-"], [data-skin="g-pastel"]) .mp-brand-n small { color: var(--sb-mu); }
}

/* ---------- Wide side menu: "side" (full height) and "float" ---------- */
@media (min-width: 1200px) {
    html:is([data-nav="side"], [data-nav="float"]) .mp-rail {
        width: 232px; align-items: stretch; padding: 16px 12px; gap: 2px;
    }
    html[data-nav="side"]:not(#ui-x) .mp-rail.mp-rail.mp-rail {
        margin: 0; border-radius: 0 !important; border-width: 0 1px 0 0; box-shadow: none; height: 100vh; height: 100dvh;
    }
    html[data-nav="float"] .mp-rail { margin: 14px 0 14px 14px; }

    html:is([data-nav="side"], [data-nav="float"], [data-nav="top"]) .mp-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
    html:is([data-nav="side"], [data-nav="float"]) .mp-brand { padding: 2px 6px 16px; }
    html:is([data-nav="side"], [data-nav="float"], [data-nav="top"]) .mp-brand .mp-mark { margin: 0; width: 40px; height: 40px; }
    html:is([data-nav="side"], [data-nav="float"], [data-nav="top"]) .mp-brand-n {
        display: block; min-width: 0; font-weight: 800; font-size: 15px; line-height: 1.25; color: var(--tx);
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    html:is([data-nav="side"], [data-nav="float"], [data-nav="top"]) .mp-brand-n small {
        display: block; font-weight: 500; font-size: 12px; color: var(--mu); overflow: hidden; text-overflow: ellipsis;
    }

    html:is([data-nav="side"], [data-nav="float"]) .mp-rail-nav { align-items: stretch; gap: 2px; }
    html:is([data-nav="side"], [data-nav="float"]) .mp-rail-nav .mp-ri {
        width: 100%; height: 44px; padding: 0 12px; gap: 12px; justify-content: flex-start;
    }
    html:is([data-nav="side"], [data-nav="float"]) .mp-rail-nav .mp-ri > span {
        display: block; font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    html:is([data-nav="side"], [data-nav="float"]) .mp-rail-nav .mp-ri.on > span { font-weight: 700; }
    html:is([data-nav="side"], [data-nav="float"]) .mp-rail-nav .mp-ri-n { top: 13px; right: 10px; }
    html:is([data-nav="side"], [data-nav="float"]) .mp-rail-end {
        flex-direction: column; flex-wrap: nowrap; align-items: stretch; justify-content: center; gap: 4px;
        border-top: 1px solid var(--sb-bd, var(--bd)); padding-top: 12px; margin-top: 8px;
    }
    html:is([data-nav="side"], [data-nav="float"]) .mp-rail-end .mp-ri {
        width: 100%; height: 40px; padding: 0 12px; gap: 12px; justify-content: flex-start;
    }
    html:is([data-nav="side"], [data-nav="float"]) .mp-rail-end .mp-ri > span,
    html:is([data-nav="side"], [data-nav="float"]) .mp-rail-end .mp-avatar > span {
        display: block; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    html:is([data-nav="side"], [data-nav="float"]) .mp-rail-end .mp-avatar {
        width: 100%; height: 40px; margin: 0; padding: 0 12px; border-radius: 14px;
        display: flex; align-items: center; justify-content: flex-start; gap: 12px; text-align: left;
    }

    /* Admin pages: the menu is fixed at the left (bq.css), so the page moves over. */
    html[data-nav="side"] body.skin-bq .content-wrapper,
    html[data-nav="side"] body.skin-bq .main-footer { margin-left: 232px !important; }
    html[data-nav="float"] body.skin-bq .content-wrapper,
    html[data-nav="float"] body.skin-bq .main-footer { margin-left: 260px !important; }
    html[data-nav="side"] body.skin-bq .wrapper > .mp-rail { margin: 0; }
}

/* ---------- Top menu ---------- */
@media (min-width: 768px) {
    html[data-nav="top"]:not(#ui-x) .mp-rail.mp-rail.mp-rail {
        flex-direction: row; align-items: center; width: auto; height: 64px; margin: 0; padding: 0 16px; gap: 6px;
        border-radius: 0 !important; border-width: 0 0 1px; box-shadow: none; overflow: visible;
    }
    html[data-nav="top"] .mp-brand { display: flex; align-items: center; gap: 10px; flex: none; margin-right: 10px; }
    html[data-nav="top"] .mp-brand .mp-mark { margin: 0; width: 40px; height: 40px; }
    html[data-nav="top"] .mp-rail-nav {
        flex-direction: row; align-items: center; margin: 0 auto 0 0; gap: 4px; min-width: 0; flex: 1 1 auto;
        overflow-x: auto; scrollbar-width: none; padding: 4px 0;
    }
    html[data-nav="top"] .mp-rail-nav::-webkit-scrollbar { display: none; }
    html[data-nav="top"] .mp-rail-nav .mp-ri { width: auto; height: 40px; padding: 0 12px; gap: 8px; }
    html[data-nav="top"] .mp-rail-end { flex-direction: row; align-items: center; padding: 0; gap: 4px; flex: none; }
    html[data-nav="top"] .mp-rail-end .mp-ri { width: 40px; height: 40px; }
    html[data-nav="top"] .mp-avatar { margin: 0 0 0 4px; }

    /* POS and dashboard: the menu bar sits on top of the page. */
    html[data-nav="top"] .mp-app { flex-direction: column; }
    html[data-nav="top"] .mp-app > .mp-rail { flex: none; }
    /* POS: products on the left, cart on the right, under the menu bar. */
    html[data-nav="top"] .mp-app:has(> .mp-cart) { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto minmax(0, 1fr); }
    html[data-nav="top"] .mp-app:has(> .mp-cart) > .mp-rail { grid-column: 1 / -1; }
    html[data-nav="top"] .mp-app:has(> .mp-cart) > .mp-main { grid-column: 1; grid-row: 2; }
    html[data-nav="top"] .mp-app:has(> .mp-cart) > .mp-cart { grid-column: 2; grid-row: 2; }
    html[data-nav="top"] .mp-main { min-height: 0; }
    html[data-nav="top"] .mp-dash-main { height: auto; flex: 1; min-height: 0; }

    /* Admin pages: a fixed bar; the page starts under it. */
    html[data-nav="top"] body.skin-bq .wrapper > .mp-rail { top: 0; left: 0; right: 0; bottom: auto; }
    html[data-nav="top"] body.skin-bq .content-wrapper,
    html[data-nav="top"] body.skin-bq .main-footer { margin-left: 0 !important; }
    html[data-nav="top"] body.skin-bq .content-wrapper { padding-top: 64px !important; }
    html[data-nav="top"] :is(.set-nav, .sx-c2) { top: 80px; }
}
/* Names in the top bar once there is room for them. */
@media (min-width: 1280px) {
    html[data-nav="top"] .mp-rail-nav .mp-ri > span { display: block; font-size: 14px; font-weight: 500; white-space: nowrap; }
    html[data-nav="top"] .mp-rail-nav .mp-ri.on > span { font-weight: 700; }
    html[data-nav="top"] .mp-brand-n { display: block; max-width: 180px; }
}
@media (min-width: 768px) and (max-width: 1279px) {
    html[data-nav="top"] .mp-brand-n { display: none; }
}

/* ---------- 🎨 panel: design and menu cards ---------- */
.ui-grid-ds { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ui-ds { display: flex; height: 78px; border-radius: 11px; overflow: hidden; background: var(--page); border: 1px solid var(--bd); }
.ui-ds i { font-style: normal; display: block; }
.ui-ds-sb { width: 26%; background: var(--sb); display: flex; flex-direction: column; gap: 4px; padding: 6px 5px; }
.ui-ds-sb b { height: 6px; border-radius: 3px; background: var(--sb-tx); opacity: .35; }
.ui-ds-sb b:first-child { background: var(--sb-on); opacity: 1; height: 8px; }
.ui-ds-m { flex: 1; padding: 7px; display: flex; flex-direction: column; gap: 5px; }
.ui-ds-hero { height: 22px; border-radius: 7px; background: var(--grad); }
.ui-ds-row { display: flex; gap: 5px; flex: 1; }
.ui-ds-row s { flex: 1; border-radius: 6px; background: var(--sf); border: 1px solid var(--bd); }
.ui-ds[data-nav="top"] { flex-direction: column; }
.ui-ds[data-nav="top"] .ui-ds-sb { width: auto; height: 14px; flex-direction: row; padding: 4px 6px; }
.ui-ds[data-nav="top"] .ui-ds-sb b { width: 14px; height: 6px; }
.ui-ds[data-nav="float"] .ui-ds-sb, .ui-ds[data-nav="float"] { gap: 0; }
.ui-ds[data-nav="float"] .ui-ds-sb { margin: 5px 0 5px 5px; border-radius: 7px; }
.ui-ds-l { position: absolute; top: 6px; left: 8px; width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center;
    background: rgba(0, 0, 0, .55); color: #fff; font: 800 12px/1 'Inter', sans-serif; }
.ui-card { position: relative; }
.ui-nav-pv { display: flex; height: 64px; border-radius: 10px; overflow: hidden; border: 1px solid var(--bd); background: var(--sf2); }
.ui-nav-pv i { font-style: normal; display: block; background: var(--ac); opacity: .75; }
.ui-nav-pv s { flex: 1; }
.ui-nav-rail i { width: 12%; }
.ui-nav-side i { width: 30%; }
.ui-nav-float { padding: 5px; } .ui-nav-float i { width: 28%; border-radius: 6px; }
.ui-nav-top { flex-direction: column; } .ui-nav-top i { height: 14px; }
@media (max-width: 767px) { .ui-grid-ds { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
