/* ---------- The panel on a phone (2026-11-20) ----------
   The owner: "make the whole panel on the phone just be better - ui and ux, motion,
   animation, speed, design". Loaded after app.css and admin-motion.css (App.razor); every
   rule here is for a phone's width (760px and less - the side menu takes over above it),
   so a computer, the kiosks and an iPad across are as they were.

   What changes on a phone:
   - A tab bar along the bottom (AdminLayout.razor): the pages used most a thumb's tap away,
     and "עוד" - every page and the account - in a sheet that opens out of that button and
     goes back into it (js/admin-nav.js; drag it down to close, js/admin-phone.js).
   - The top bar is the business and quick search; scrolled past a page's title, the title
     takes the business's place in it (js/admin-flair.js).
   - Going deeper (a report from the reports) slides the new page in from the side it
     comes from, and back slides it away again (js/admin-nav.js). A window opens out of the row it was opened from, and closes back into
     it (js/admin-phone.js, js/admin-motion.js). "Nothing just appears."
   - A page's description is two lines, "עוד" opens the rest; the ring's warning is one line.
   The ideas behind the motion: The Glide Studio's reel the owner sent - tap a card and
   the card becomes the page, back goes back, menus start at their button. */

/* Wider screens: the side menu, no tab bar; the ring's long warning. */
.admin-tabbar, .chime-bar-short { display: none; }

@media (max-width: 760px) {
    .chime-bar-short { display: inline; }
    /* The tab bar's height, above the iPhone's home line - what the page leaves room for at
       the bottom. 0 while typing (below). */
    html:has(.admin-tabbar) { --tabbar-h: calc(62px + env(safe-area-inset-bottom)); }
    /* Typing: the keyboard is the bottom of the screen; the tab bar steps aside so it never
       floats over the field (an iPhone moves fixed bars about with its keyboard up). */
    html:has(.admin-shell .admin-content :is(input:not([type=checkbox], [type=radio], [type=range], [type=file], [type=button], [type=submit]), textarea, select):focus) { --tabbar-h: 0px; }

    /* ---------- The tab bar ---------- */
    .admin-tabbar {
        position: fixed; inset-inline: 0; bottom: 0; z-index: 30;
        display: flex; align-items: stretch;
        height: calc(62px + env(safe-area-inset-bottom));
        padding: 0 6px env(safe-area-inset-bottom);
        background: color-mix(in srgb, var(--surface) 93%, transparent);
        -webkit-backdrop-filter: saturate(1.8) blur(18px);
        backdrop-filter: saturate(1.8) blur(18px);
        border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
        box-shadow: 0 -10px 30px -18px rgba(74, 58, 26, .35);
        transition: transform .28s var(--ease-drawer);
    }
    html:has(.admin-shell .admin-content :is(input:not([type=checkbox], [type=radio], [type=range], [type=file], [type=button], [type=submit]), textarea, select):focus) .admin-tabbar { transform: translateY(110%); }
    .admin-tab {
        flex: 1 1 0; min-width: 0;
        display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
        padding: 6px 2px 4px; margin: 0;
        border: none; border-radius: 0; background: none;
        color: var(--ink-soft); text-decoration: none;
        font: inherit; font-size: .7rem; font-weight: 700; line-height: 1.1;
        cursor: pointer; -webkit-tap-highlight-color: transparent;
        transition: color .2s ease;
    }
    .admin-tab-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    /* The icon in its own pill: the light behind it grows out from the middle when the tab is
       chosen (and the moment it's tapped - admin-phone.js), and the icon gives a little lift. */
    .admin-tab-icon {
        position: relative; display: grid; place-items: center;
        width: 58px; height: 30px; border-radius: 999px;
        transition: transform .16s var(--ease-out);
    }
    .admin-tab-icon::before {
        content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit;
        background: color-mix(in srgb, var(--gold) 18%, var(--surface));
        opacity: 0; transform: scaleX(.4);
        transition: transform .34s cubic-bezier(.2, .9, .3, 1.15), opacity .2s ease;
    }
    .admin-tab-icon .icon { width: 1.35rem; height: 1.35rem; transition: transform .34s cubic-bezier(.34, 1.56, .64, 1); }
    .admin-tab:active .admin-tab-icon { transform: scale(.9); }
    .admin-tab.active, .admin-tab.is-going, .admin-tabbar-more[aria-expanded="true"] { color: var(--chocolate); }
    :is(.admin-tab.active, .admin-tab.is-going, .admin-tabbar-more[aria-expanded="true"]) .admin-tab-icon::before { opacity: 1; transform: none; }
    :is(.admin-tab.active, .admin-tab.is-going) .admin-tab-icon .icon { transform: translateY(-1px) scale(1.06); color: var(--accent-dark); }
    /* The tab you're leaving lets go the moment another is tapped. */
    .admin-tabbar:has(.is-going) .admin-tab.active:not(.is-going) { color: var(--ink-soft); }
    .admin-tabbar:has(.is-going) .admin-tab.active:not(.is-going) .admin-tab-icon::before { opacity: 0; transform: scaleX(.4); }
    .admin-tabbar:has(.is-going) .admin-tab.active:not(.is-going) .admin-tab-icon .icon { transform: none; color: inherit; }
    /* A page that isn't in the bar (settings, say): "עוד" is where it is. */
    .admin-tabbar:not(:has(.admin-tab.active, .is-going)) .admin-tabbar-more { color: var(--chocolate); }
    .admin-tabbar:not(:has(.admin-tab.active, .is-going)) .admin-tabbar-more .admin-tab-icon::before { opacity: 1; transform: none; }
    /* "עוד" open: its icon turns to say "close". */
    .admin-tabbar-more .icon { transition: transform .3s var(--ease-out); }
    .admin-tabbar-more[aria-expanded="true"] .icon { transform: rotate(90deg); }
    .admin-tab:focus-visible { outline: none; }
    .admin-tab:focus-visible .admin-tab-icon { outline: 2px solid var(--gold); outline-offset: 2px; }

    /* Room for it at the bottom of every page, and what sits at the bottom stays above it. */
    .admin-content { padding-bottom: calc(var(--tabbar-h, 0px) + 32px); }
    .settings-savebar { bottom: var(--tabbar-h, 0px); }
    .device-requests { inset-block-end: calc(var(--tabbar-h, 0px) + 12px); max-height: calc(100dvh - var(--tabbar-h, 0px) - 90px); }
    .admin-held { bottom: var(--tabbar-h, 0px); }

    /* ---------- The top bar ---------- */
    /* The business and quick search; the page's name is the tab (or "עוד"), and once
       scrolled, the title in the bar (below). The old "pages" button gives way to the tab bar. */
    .admin-nav-toggle { display: none !important; }
    /* A solid brown strip fixed at the top, under the bar (which covers it): Safari on an iPhone
       (iOS 26) colours the strip behind the clock from a solid bar fixed at the top - without
       one it showed the page through there (the owner's screenshot, 2026-11-21). */
    .admin-shell::before {
        content: ""; position: fixed; top: 0; left: 0; right: 0; z-index: 19;
        height: 60px; background: var(--chocolate); pointer-events: none;
    }
    /* One plain brown: the title sliding in over it (below) meets it without a seam. */
    .admin-nav { min-height: 60px; gap: 10px; padding-inline: 16px 12px; background: var(--chocolate); box-shadow: 0 8px 22px -16px rgba(20, 14, 6, .6); }
    .admin-nav-brand { gap: 10px; font-size: 1.08rem; letter-spacing: -.01em; }
    .admin-nav-brand-mark { width: 32px; height: 32px; }
    .admin-quick-icon { width: 42px; height: 42px; border-color: rgba(255, 255, 255, .16); background: rgba(255, 255, 255, .1); }

    /* Scrolled past the page's title: it slides into the top bar in the business's place,
       and a tap there goes back up. */
    .admin-title-bar {
        left: 0 !important; width: auto !important; right: 64px;
        display: flex; align-items: center;
        height: calc(60px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 18px 0 12px;
        z-index: 25;
        background: var(--chocolate);
        color: var(--cream); border: none; box-shadow: none;
        font-size: 1.05rem; font-weight: 800;
        overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
        transform: translateY(8px); opacity: 0;
        transition: transform .26s var(--ease-out), opacity .18s ease;
    }
    html[dir="rtl"] .admin-title-bar { left: 64px !important; right: 0; padding-inline: 16px 8px; }
    /* Inside the top bar (js/admin-flair.js): it covers the bar's own height, and the iPhone
       sees one bar at the top, whose brown colours the strip behind its clock. */
    .admin-nav > .admin-title-bar { position: absolute; top: 0; bottom: 0; height: auto; padding-top: env(safe-area-inset-top); }
    .admin-title-bar[data-shown] { transform: none; opacity: 1; }

    /* ---------- "עוד": every page, the account ---------- */
    /* A sheet just above the tab bar that opens out of the "עוד" button (its place on the
       bar: --more-x, admin-nav.js) and goes back into it; the tab bar stays in sight, and
       "עוד" again closes it. Dark like the side menu it stands for. */
    .admin-nav-panel {
        top: auto !important;
        bottom: calc(var(--tabbar-h, 62px) + 10px);
        inset-inline: 10px;
        max-height: calc(100dvh - var(--tabbar-h, 62px) - 60px - env(safe-area-inset-top) - 24px);
        padding: 22px 14px 16px;
        border: 1px solid rgba(255, 255, 255, .08);
        border-radius: 26px;
        background: #3a2d16 linear-gradient(180deg, #47381c 0%, #33270f 100%);
        box-shadow: 0 30px 60px -20px rgba(20, 14, 6, .7), 0 0 0 .5px rgba(0, 0, 0, .3);
        transform-origin: var(--more-x, 12%) calc(100% + 40px);
        touch-action: pan-y;
    }
    /* The handle: drag the sheet down to close it. */
    .admin-nav-panel::before {
        content: ""; position: absolute; top: 8px; left: 50%; width: 38px; height: 5px; margin-left: -19px;
        border-radius: 999px; background: rgba(255, 255, 255, .28);
    }
    html.admin-nav-open .admin-nav-panel { animation: admin-more-in .42s cubic-bezier(.2, .9, .25, 1.06) both; transform-origin: var(--more-x, 12%) calc(100% + 40px); }
    html.admin-nav-closing .admin-nav-panel { display: block; transform-origin: var(--more-x, 12%) calc(100% + 40px); animation: admin-more-out .2s cubic-bezier(.4, 0, 1, 1) both; pointer-events: none; }
    html.admin-nav-closing .admin-nav-backdrop { display: block; position: fixed; inset: 0; z-index: 19; background: rgba(30, 22, 10, .45); animation: admin-fade-out .2s ease both; }
    html.admin-nav-open .admin-nav-backdrop { -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
    /* Its links come in a beat after it, row by row - quicker than the sheet. */
    html.admin-nav-open .admin-nav-panel :is(.admin-nav-links, .admin-nav-foot) > * { animation: admin-in .3s cubic-bezier(.22, .61, .36, 1) backwards; }
    /* The pages already on the tab bar aren't listed again, and a group left empty goes. */
    .admin-nav-panel a[data-tabbed] { display: none; }
    .admin-nav-panel .admin-nav-group:not(:has(a:not([data-tabbed]))) { display: none; }
    .admin-nav-panel .admin-nav-group-title { font-size: .74rem; color: rgba(255, 255, 255, .55); }
    .admin-nav-panel a {
        min-height: 54px; border-radius: 16px;
        background: rgba(255, 255, 255, .06);
        transition: background-color .15s ease, transform .14s var(--ease-out);
    }
    .admin-nav-panel a:active { background: rgba(255, 255, 255, .14); transform: scale(.97); }
    .admin-nav-panel a.active { background: rgba(255, 255, 255, .16); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12); }
    .admin-nav-panel a .icon { width: 1.25rem; height: 1.25rem; }
    .admin-nav-panel .admin-nav-account a { min-height: 46px; }
    /* The sheet follows a finger dragging it down (admin-phone.js). */
    .admin-nav-panel[data-dragging] { animation: none !important; transition: none; }
    .admin-nav-panel[data-dropping] { transition: transform .22s var(--ease-out); }

    /* ---------- A page's head ---------- */
    .admin-page-head { margin-bottom: 18px; }
    .admin-page-head h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; margin-bottom: 6px; }
    /* Two lines of the description; "עוד" (admin-phone.js) opens the rest. */
    .admin-page-head > p {
        display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
    }
    .admin-page-head > p[data-open] { display: block; -webkit-line-clamp: unset; }
    .admin-page-head > p[data-more] { cursor: pointer; position: relative; }
    .admin-page-head > p[data-more]:not([data-open])::after {
        content: "עוד"; position: absolute; bottom: 0; inset-inline-end: 0;
        padding-inline-start: 36px;
        background: linear-gradient(to left, var(--cream) 55%, transparent);
        color: var(--accent-dark); font-weight: 700;
    }
    /* Right to left, the line ends on the left: solid there, fading into the text on its right. */
    html[dir="rtl"] .admin-page-head > p[data-more]:not([data-open])::after { background: linear-gradient(to right, var(--cream) 55%, transparent); }

    /* ---------- The ring's warning: one line ---------- */
    .chime-bar-long { display: none; }
    .chime-bar {
        min-height: 40px; margin-bottom: 14px; padding: 8px 14px;
        border-radius: 999px; font-size: .88rem;
        animation: admin-chime-in .3s var(--ease-out) backwards;
    }
    .chime-bar .icon, .chime-bar svg { width: 1.05rem; height: 1.05rem; animation: admin-chime-ring 2.4s ease-in-out 1s infinite; transform-origin: 50% 10%; }
    /* The dashboard's own "tap to wake" said the same: the bar says it once. */
    .admin-content:has(.chime-bar) .chime-toggle.chime-locked { display: none; }

    /* ---------- Cards and lists ---------- */
    .admin-content { padding-inline: 16px; }
    .stat-card { border-radius: 18px; }
    .settings-section { border-radius: 20px; }

    /* Approved devices: the two choices fill the row instead of running out of the card. */
    .device-row-mode { flex: 1 1 100%; min-width: 0; }
    .device-row-mode select { width: 100%; min-width: 0; }
    .device-row > .btn { flex: 1 1 auto; justify-content: center; }

    /* Press feedback on everything that's a card one taps. */
    :is(.order-card, .device-row, .addon-card, .stat-card, .admin-dish-row) { -webkit-tap-highlight-color: transparent; }

    /* ---------- A window over the page ---------- */
    /* A sheet from the bottom with a handle, as the phone's own. */
    .admin-content .modal-sheet { border-radius: 26px 26px 0 0; box-shadow: 0 -24px 60px -12px rgba(42, 32, 25, .35); }
    /* Opening out of its row instead (admin-phone.js): not also rising from below. */
    :is(.modal-sheet, .order-editor)[data-morph] { animation: none !important; }
}

@keyframes admin-more-in {
    from { opacity: 0; transform: translateY(18px) scale(.35); border-radius: 40px; }
    45% { opacity: 1; }
    to { opacity: 1; transform: none; }
}
@keyframes admin-more-out {
    from { opacity: 1; transform: none; }
    to { opacity: 0; transform: translateY(14px) scale(.4); }
}
@keyframes admin-fade-out { to { opacity: 0; } }
@keyframes admin-chime-in { from { opacity: 0; transform: translateY(-6px) scale(.96); } }
@keyframes admin-chime-ring {
    0%, 18%, 100% { transform: rotate(0); }
    3% { transform: rotate(14deg); }
    7% { transform: rotate(-12deg); }
    11% { transform: rotate(8deg); }
    15% { transform: rotate(-4deg); }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    html.admin-nav-open .admin-nav-panel, html.admin-nav-closing .admin-nav-panel { animation: none; }
    .chime-bar .icon, .chime-bar svg { animation: none; }
}
html[data-motion="reduced"] .chime-bar .icon, html[data-motion="reduced"] .chime-bar svg { animation: none; }
