/*
 * Left icon rail + pop-out panels (views/cpos/_rail.php), shared by the new
 * POS, the dashboard and every admin page. Self-contained: it carries its own
 * colour tokens so it looks the same with or without cpos.css / Bootstrap.
 * Dark when <html data-scheme="dark">.
 */
.mp-rail, .mp-fly {
    --sf: #fffdfa; --sf2: #f3ebe4; --bd: #eadfd5; --tx: #3b2a26; --mu: #9a857c; --chip: #f1e7df;
    --ac: #b76e79; --ac-soft: #f6e6e6; --grad: linear-gradient(135deg, #c98690 0%, #9c5662 100%);
    --glow: 0 12px 24px rgba(156, 86, 98, .30); --r: 20px;
    --sh: 0 1px 2px rgba(90, 50, 40, .04), 0 8px 24px rgba(120, 70, 60, .08);
    --sh-lg: 0 24px 60px rgba(60, 30, 25, .22);
    font-family: 'Inter', 'Kantumruy Pro', system-ui, sans-serif;
    box-sizing: border-box;
}
[data-scheme="dark"] .mp-rail, [data-scheme="dark"] .mp-fly {
    --sf: #14141f; --sf2: #1b1b29; --bd: #23233a; --tx: #ecebff; --mu: #8b8ba7; --chip: #1f1f30;
    --ac: #a78bfa; --ac-soft: #221f3a; --grad: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
    --glow: 0 12px 26px rgba(139, 92, 246, .38);
    --sh: 0 1px 0 rgba(255, 255, 255, .02) inset; --sh-lg: 0 24px 60px rgba(0, 0, 0, .6);
}
.mp-rail *, .mp-fly * { box-sizing: border-box; }
:where(.mp-rail, .mp-fly) button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
:where(.mp-rail, .mp-fly) a { color: inherit; text-decoration: none; }
.mp-rail .i, .mp-fly .i { flex: none; display: block; }

/* ---------- Rail ---------- */
.mp-rail {
    width: 76px; flex: none; margin: 14px 0 14px 14px; padding: 14px 0; border-radius: var(--r);
    background: var(--sf); border: 1px solid var(--bd); box-shadow: var(--sh);
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    overflow-y: auto; scrollbar-width: none;
}
.mp-rail::-webkit-scrollbar { display: none; }
.mp-mark {
    width: 44px; height: 44px; border-radius: 14px; background: var(--grad); color: #fff !important; font-weight: 800; font-size: 14px;
    display: grid; place-items: center; margin-bottom: 12px; letter-spacing: -.02em; box-shadow: var(--glow); flex: none;
}
.mp-mark.has-logo { background: #fff; padding: 4px; overflow: hidden; box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.mp-mark.has-logo img { width: 100%; height: 100%; object-fit: contain; border-radius: 10px; display: block; }
.mp-ri {
    width: 46px; height: 46px; border-radius: 14px; display: flex; align-items: center; justify-content: center; flex: none; padding: 0;
    color: var(--mu) !important; position: relative; transition: background .15s, color .15s;
}
.mp-ri:hover, .mp-ri.open { background: var(--sf2); color: var(--tx) !important; }
.mp-ri.on { background: var(--grad); color: #fff !important; box-shadow: var(--glow); }
.mp-ri > span { display: none; }
.mp-ri-n {
    position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
    background: var(--grad); color: #fff; font: 700 10px/18px 'Inter', sans-serif; text-align: center;
}
/* The area icons start right under the logo; the end icons stay at the bottom. */
.mp-rail-nav { margin: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.mp-rail-end { display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 10px; }
.mp-avatar {
    width: 40px; height: 40px; border-radius: 50%; flex: none; margin-top: 4px;
    background: var(--chip) !important; color: var(--mu) !important; font-weight: 700; font-size: 12px; border: 2px solid var(--bd) !important;
}
.mp-avatar.open { border-color: var(--ac) !important; color: var(--ac) !important; }
.mp-avatar > span { display: none; }
.mp-avatar { display: flex; align-items: center; justify-content: center; }
.mp-account-photo { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; display: block; flex: none; margin: 0; }
.mp-fly-av .mp-account-photo, .mb-av .mp-account-photo { width: 100%; height: 100%; }

/* ---------- Pop-out panel ---------- */
.mp-fly {
    position: fixed; z-index: 2000; min-width: 230px; max-width: calc(100vw - 110px); max-height: calc(100vh - 20px); overflow-y: auto;
    padding: 10px; border-radius: 18px; background: var(--sf); border: 1px solid var(--bd); box-shadow: var(--sh-lg);
    color: var(--tx); font-size: 14px; line-height: 1.4; animation: mp-fly-in .14s ease-out;
}
.mp-fly[hidden] { display: none !important; }
@keyframes mp-fly-in { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }
.mp-fly-h { display: flex; align-items: center; gap: 10px; padding: 6px 10px 10px; font-weight: 800; font-size: 15px; color: var(--tx); }
.mp-fly-h .i { color: var(--ac); }
.mp-fly-b.cols { display: grid; grid-template-columns: repeat(2, minmax(200px, 1fr)); gap: 4px 10px; }
.mp-fly-s + .mp-fly-s { margin-top: 6px; }
.mp-fly-b.cols .mp-fly-s + .mp-fly-s { margin-top: 0; }
.mp-fly-s + .mp-fly-s { border-top: 1px solid var(--bd); padding-top: 6px; }
.mp-fly-b.cols .mp-fly-s { border-top: 0; padding-top: 0; }
.mp-fly-t { display: flex; align-items: center; gap: 6px; padding: 8px 10px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--mu); }
.mp-fly a {
    display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px;
    color: var(--tx) !important; font-weight: 500; white-space: nowrap;
}
.mp-fly a:hover { background: var(--sf2); }
.mp-fly a.on { background: var(--ac-soft); color: var(--ac) !important; font-weight: 700; }
.mp-fly a .i { color: var(--mu); }
.mp-fly-n { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--grad); color: #fff; font-size: 11px; text-align: center; }
.mp-fly-av { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--chip); color: var(--mu); font-size: 11px; }
.mp-fly-langs { display: flex; flex-wrap: wrap; gap: 4px; padding: 2px 6px 4px; }
.mp-fly-langs a { padding: 6px 10px; border: 1px solid var(--bd); font-size: 13px; }
.mp-fly-out { color: #d0555e !important; }
.mp-fly-out .i { color: #d0555e !important; }

/* ---------- Phone: floating bottom bar (segmented look), panels as sheets ----------
   One soft track; the open area is a raised white pill with its name under
   the icon. */
@media (max-width: 767px) {
    .mp-rail {
        position: fixed !important; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); top: auto !important; z-index: 1500;
        width: auto; height: 62px; margin: 0 !important; padding: 5px; border-radius: 22px;
        background: var(--sf2); border: 1px solid var(--sf); box-shadow: 0 10px 28px rgba(80, 40, 50, .18);
        flex-direction: row; justify-content: space-around; gap: 2px; overflow: visible;
    }
    .mp-mark { display: none; }
    .mp-rail-nav, .mp-rail-end { margin: 0; padding: 0; flex-direction: row; gap: 2px; }
    .mp-rail-nav { flex: 1; justify-content: space-around; }
    .mp-rail-end .mp-ui-open, .mp-rail-end .mp-ri-set { display: none; }
    .mp-ri {
        flex: 1 1 0; min-width: 0; width: auto; height: 50px; border-radius: 17px; flex-direction: column; gap: 1px;
        color: var(--mu) !important; box-shadow: none;
    }
    .mp-rail-end .mp-ri { flex: none; width: 44px; }
    .mp-ri > span {
        display: block; max-width: 100%; padding: 0 2px; font-size: 9.5px; font-weight: 700; line-height: 1.2;
        white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    }
    .mp-ri:hover, .mp-ri.open { background: transparent; }
    .mp-ri.on { background: var(--sf); color: var(--ac) !important; box-shadow: 0 2px 10px rgba(120, 60, 70, .18); }
    .mp-ri-n { top: 3px; right: 4px; }
    .mp-avatar { width: 34px; height: 34px; margin: 0 4px 0 2px; align-self: center; }
    .mp-fly {
        left: 8px !important; right: 8px; top: auto !important; bottom: 84px; max-width: none; max-height: 70vh;
        animation-name: mp-fly-up;
    }
    .mp-fly-b.cols { grid-template-columns: 1fr; }
    .mp-fly a { white-space: normal; }
    @keyframes mp-fly-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
}

.mp-fly-sub { margin: 0; }
.mp-fly-sub > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; font-weight: 500; color: var(--tx); }
.mp-fly-sub > summary::-webkit-details-marker { display: none; }
.mp-fly-sub > summary::after { content: '›'; margin-left: auto; color: var(--mu); transition: transform .15s; font-size: 16px; }
.mp-fly-sub[open] > summary::after { transform: rotate(90deg); }
.mp-fly-sub > summary:hover { background: var(--sf2); }
.mp-fly-sub > a { padding-left: 26px !important; font-size: 13px; }
/* The POS / dashboard pages have nothing for "This page"; phones keep the bottom bar short. */
body.mp .cz-start { display: none !important; }
/* Phones: the bottom bar keeps the areas, alerts and the account button. */
@media (max-width: 767px) {
    .mp-rail .mp-ri-set { display: none; }
    .mp-rail { overflow-x: auto; scrollbar-width: none; }
    .mp-rail::-webkit-scrollbar { display: none; }
}

/* Colour icons (Settings > Shop > Icon style). */
img.i-3d { display: inline-block; flex: none; object-fit: contain; vertical-align: middle; }
.i-emo { display: inline-grid; place-items: center; text-align: center; overflow: hidden; flex: none; line-height: 1; font-style: normal; font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif; }

/* Icons in the middle of their button: picture icons (emoji) are laid out
   as a box of their own size, whatever the system emoji font does with
   its baseline (Windows draws them higher than other systems). */
.mp-ri > .i, .mp-avatar > .i { margin: 0; flex: none; }
.mp-ri > .i-emo { display: flex; align-items: center; justify-content: center; line-height: 1; text-indent: 0; letter-spacing: 0; }

/* ---------- Phone: bottom bar of 4-6 buttons (cpos/_rail.php .mb-nav) ---------- */
.mb-nav, .mb-only { display: none; }
@media (max-width: 767px) {
    .mp-rail { display: none !important; }
    .mb-only { display: block; }
    .mb-nav {
        display: flex; position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 1030; height: 66px; padding: 6px;
        align-items: center; gap: 2px; border-radius: 24px;
        background: color-mix(in srgb, var(--sf, #fff) 90%, transparent); -webkit-backdrop-filter: blur(18px) saturate(160%); backdrop-filter: blur(18px) saturate(160%);
        box-shadow: 0 12px 32px rgba(15, 23, 42, .16), 0 0 0 1px color-mix(in srgb, var(--tx, #0f172a) 6%, transparent);
    }
    .mb-i {
        position: relative; flex: 1 1 0; min-width: 0; height: 54px; border: 0; background: none; padding: 0; border-radius: 18px;
        display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--mu, #64748b) !important; text-decoration: none !important; cursor: pointer;
    }
    .mb-i > i { width: 48px; height: 28px; border-radius: 14px; display: grid; place-items: center; font-style: normal; position: relative; transition: background .2s, color .2s; }
    .mb-i > i .i { display: block; }
    .mb-i > b { max-width: 100%; padding: 0 2px; font-size: 10.5px; font-weight: 700; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .mb-i.on { color: var(--ac, #2563eb) !important; }
    .mb-i.on > i { background: var(--ac-soft, #dbeafe); }
    .mb-i > u { position: absolute; top: 2px; left: calc(50% + 8px); min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: #ef4444; color: #fff; text-decoration: none; font: 800 10px/14px Inter, sans-serif; text-align: center; border: 2px solid var(--sf, #fff); }
    .mb-av { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--grad, linear-gradient(135deg, #60a5fa, #2563eb)); color: #fff; font: 800 11px Inter, sans-serif; }
    .mb-me > i { background: none !important; }
    .mb-me > i em { position: absolute; top: -1px; right: 8px; width: 10px; height: 10px; border-radius: 50%; background: #ef4444; border: 2px solid var(--sf, #fff); }
    .mb-me.open { color: var(--ac, #2563eb) !important; }
    body:has(#mp-ui:not([hidden])) .mb-nav { z-index: 4002; }
    body.mp-sheet .mb-nav { display: none !important; }
    .mp-fly { bottom: 90px; }
}
