/*
 * Portal shell: collapsible sidebar with the signed-in user at the bottom, menus that open beside it,
 * and the record drawer that slides in from the right. Markup: admin-color/inc/sidebar.blade.php and
 * layouts/top_left.blade.php. Behaviour: public/assets/js/portal-shell.js.
 *
 * The sidebar animates its width only. Every row keeps the same left padding in both states, so icons
 * stay where they are while labels are clipped and fade; nothing jumps.
 */

:root {
    --portal-sidebar-full: 272px;
    --portal-sidebar-rail: 72px;
    --portal-sidebar-w: var(--portal-sidebar-full);
    --portal-ease: cubic-bezier(.32, .72, 0, 1);
    --portal-speed: 240ms;
    /* 70% of the window, but never narrower than 920px (or the window minus the sidebar rail on smaller screens). */
    --portal-drawer-w: max(70vw, min(920px, 100vw - 72px));
    --portal-shadow-pop: 0 12px 32px -8px rgba(15, 23, 42, .22), 0 2px 6px rgba(15, 23, 42, .08);
    --portal-scrim: rgba(24, 24, 27, .32);
}

html[data-sidebar="collapsed"] {
    --portal-sidebar-w: var(--portal-sidebar-rail);
}

html[data-bs-theme="dark"] {
    --portal-shadow-pop: 0 12px 32px -8px rgba(0, 0, 0, .7), 0 0 0 1px var(--admin-border);
    --portal-scrim: rgba(0, 0, 0, .6);
}

/* ---------- Page frame ---------- */

/* Color Admin fixes the body at the window height. The body has to grow with the page, or the
   sticky phone/tablet top bar (.portal-mobilebar) scrolls away after one screen. */
body.portal-shell {
    height: auto;
    min-height: 100%;
}

body.portal-shell .wrapper {
    margin-inline-start: var(--portal-sidebar-w);
    transition: margin-inline-start var(--portal-speed) var(--portal-ease);
    min-width: 0;
}

body.portal-shell .app-content {
    margin-left: 0;
    margin-right: 0;
}

/* ---------- Shared small controls ---------- */

.portal-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 999px;
    background: transparent;
    color: var(--admin-text-secondary);
    text-decoration: none;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}

.portal-icon-btn:hover {
    background: var(--admin-hover);
    color: var(--admin-text-primary);
}

.portal-icon-btn:focus-visible,
.portal-link:focus-visible,
.portal-group-toggle:focus-visible,
.portal-user-main:focus-visible,
.portal-user-rail:focus-visible,
.portal-edge-toggle:focus-visible,
.portal-menu-item:focus-visible,
.portal-segmented button:focus-visible {
    outline: 2px solid var(--admin-accent);
    outline-offset: 2px;
}

.portal-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 999px;
    background: rgba(var(--admin-accent-rgb), .14);
    color: var(--admin-accent);
    font-weight: 600;
    font-size: 15px;
    line-height: 1;
    user-select: none;
}

.portal-flag {
    display: inline-flex;
    width: 20px;
    height: 15px;
    overflow: hidden;
    border-radius: 3px;
    box-shadow: 0 0 0 1px var(--admin-border);
}

.portal-flag svg {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ---------- Sidebar ---------- */

.portal-sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    z-index: 1030;
    display: flex;
    flex-direction: column;
    width: var(--portal-sidebar-w);
    background: var(--admin-surface);
    border-inline-end: 1px solid var(--admin-border);
    transition: width var(--portal-speed) var(--portal-ease), transform var(--portal-speed) var(--portal-ease);
}

.portal-sidebar-head {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 68px;
    padding-inline: 18px 14px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--admin-border);
    overflow: hidden;
}

.portal-brand {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    height: 100%;
    color: inherit;
    text-decoration: none;
}

.portal-brand-wordmark {
    width: 124px;
    flex-shrink: 0;
    transition: opacity calc(var(--portal-speed) * .6) ease;
}

/* The cart emblem sits exactly where the wordmark starts, so the swap reads as one logo shrinking. */
.portal-brand-mark {
    position: absolute;
    inset-inline-start: 0;
    top: 50%;
    width: 36px;
    transform: translateY(-50%);
    opacity: 0;
    pointer-events: none;
    transition: opacity calc(var(--portal-speed) * .6) ease;
}

.portal-close-btn {
    display: none;
}

/* Scrolling menu between the brand and the user. */
.portal-nav {
    flex: 1;
    min-height: 0;
    padding: 12px;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--admin-border) transparent;
    overscroll-behavior: contain;
}

.portal-link,
.portal-group-toggle {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 42px;
    margin: 0 0 2px;
    padding: 0 12px 0 14px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--admin-text-secondary);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.25;
    text-align: start;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}

.portal-link:hover,
.portal-group-toggle:hover {
    background: var(--admin-hover);
    color: var(--admin-text-primary);
}

.portal-nav-icon {
    flex-shrink: 0;
    width: 20px;
    font-size: 20px;
    line-height: 1;
    text-align: center;
}

.portal-nav-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity calc(var(--portal-speed) * .7) ease;
}

.portal-link.is-active {
    background: rgba(var(--admin-accent-rgb), .1);
    color: var(--admin-accent);
    font-weight: 600;
}

.portal-link.is-active::before {
    content: "";
    position: absolute;
    inset-block: 9px;
    inset-inline-start: 0;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--admin-accent);
}

.portal-link-top {
    margin-bottom: 6px;
}

.portal-group-toggle {
    color: var(--admin-text-primary);
}

.portal-group.has-active > .portal-group-toggle {
    font-weight: 600;
}

/* Groups start closed, so a closed group still shows that it holds the page you are on. */
.portal-group.has-active:not(.is-open) > .portal-group-toggle {
    color: var(--admin-accent);
}

.portal-chevron {
    flex-shrink: 0;
    color: var(--admin-text-muted);
    transition: transform var(--portal-speed) var(--portal-ease), opacity .15s ease;
}

.portal-group.is-open > .portal-group-toggle .portal-chevron {
    transform: rotate(180deg);
}

.portal-group-badge,
.portal-menu-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    min-width: 22px;
    height: 20px;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--portal-danger, #B91C1C);
    color: #FFFFFF;
    font-size: 11.5px;
    font-weight: 700;
    line-height: 1;
    transition: opacity .15s ease, transform var(--portal-speed) var(--portal-ease);
}

html[data-bs-theme="dark"] .portal-group-badge,
html[data-bs-theme="dark"] .portal-menu-badge {
    background: #DC2626;
}

/* Groups open with a height animation (grid 0fr → 1fr), no JS measuring. */
.portal-group-panel {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows var(--portal-speed) var(--portal-ease);
}

.portal-group.is-open > .portal-group-panel {
    grid-template-rows: 1fr;
}

.portal-group-inner {
    min-height: 0;
    overflow: hidden;
}

.portal-group-inner > .portal-link {
    min-height: 38px;
    padding-inline-start: 22px;
    font-size: 13.5px;
}

.portal-group-inner > .portal-link .portal-nav-icon {
    font-size: 17px;
}

.portal-group-inner > .portal-link:last-child {
    margin-bottom: 6px;
}

/* ---------- Footer: the signed-in user ---------- */

.portal-sidebar-foot {
    position: relative;
    flex-shrink: 0;
    padding: 10px 12px;
    border-top: 1px solid var(--admin-border);
}

.portal-user {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    transition: opacity calc(var(--portal-speed) * .6) ease;
}

.portal-user-main {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    padding: 4px;
    border-radius: 10px;
    color: inherit;
    text-decoration: none;
}

.portal-user-main:hover {
    background: var(--admin-hover);
    color: inherit;
}

.portal-user-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.2;
}

.portal-user-name {
    overflow: hidden;
    color: var(--admin-text-primary);
    font-size: 13.5px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.portal-user-role {
    overflow: hidden;
    color: var(--admin-text-muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .06em;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

.portal-user-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.portal-user-actions .portal-icon-btn {
    width: 30px;
    height: 30px;
}

.portal-user-main .portal-avatar {
    width: 34px;
    height: 34px;
}

/* The theme button shows the mode in use: system, light or dark. */
.portal-theme-cycle svg {
    display: none;
}

html:not([data-theme-pref]) .portal-theme-cycle .icon-system,
html[data-theme-pref="system"] .portal-theme-cycle .icon-system,
html[data-theme-pref="light"] .portal-theme-cycle .icon-light,
html[data-theme-pref="dark"] .portal-theme-cycle .icon-dark {
    display: block;
}

.portal-user-rail {
    position: absolute;
    inset-block-start: 50%;
    inset-inline-start: 16px;
    display: inline-flex;
    padding: 2px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    transform: translateY(-50%);
    opacity: 0;
    visibility: hidden;
    cursor: pointer;
    transition: opacity calc(var(--portal-speed) * .6) ease, visibility 0s linear var(--portal-speed);
}

.portal-user-rail:hover .portal-avatar,
.portal-user-rail[aria-expanded="true"] .portal-avatar {
    box-shadow: 0 0 0 3px rgba(var(--admin-accent-rgb), .25);
}

/* Round tab on the sidebar edge, just above the footer. */
.portal-edge-toggle {
    position: absolute;
    inset-inline-end: -13px;
    bottom: 72px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--admin-border);
    border-radius: 999px;
    background: var(--admin-surface);
    color: var(--admin-text-secondary);
    box-shadow: 0 1px 3px rgba(15, 23, 42, .12);
    cursor: pointer;
    transition: color .15s ease, background-color .15s ease, transform var(--portal-speed) var(--portal-ease);
}

.portal-edge-toggle:hover {
    background: var(--admin-hover);
    color: var(--admin-text-primary);
}

.portal-edge-toggle svg {
    transition: transform var(--portal-speed) var(--portal-ease);
}

/* ---------- Collapsed rail (desktop) ---------- */

@media (min-width: 992px) {
    html[data-sidebar="collapsed"] .portal-nav-label,
    html[data-sidebar="collapsed"] .portal-chevron,
    html[data-sidebar="collapsed"] .portal-link .portal-menu-badge {
        opacity: 0;
    }

    /* The rail shows top-level icons only; a group's links open in a flyout instead. */
    html[data-sidebar="collapsed"] .portal-group.is-open > .portal-group-panel {
        grid-template-rows: 0fr;
    }

    /* A count on a group stays visible as a small bubble on its icon. */
    html[data-sidebar="collapsed"] .portal-group-badge {
        position: absolute;
        inset-block-start: 4px;
        inset-inline-start: 30px;
        min-width: 18px;
        height: 16px;
        padding: 0 4px;
        font-size: 10px;
        box-shadow: 0 0 0 2px var(--admin-surface);
    }

    /* The open group still shows that it holds the page you are on. */
    html[data-sidebar="collapsed"] .portal-group.has-active > .portal-group-toggle {
        background: rgba(var(--admin-accent-rgb), .1);
        color: var(--admin-accent);
    }

    html[data-sidebar="collapsed"] .portal-group-toggle[aria-expanded="true"] {
        background: var(--admin-hover);
    }

    html[data-sidebar="collapsed"] .portal-brand-wordmark {
        opacity: 0;
    }

    html[data-sidebar="collapsed"] .portal-brand-mark {
        opacity: 1;
    }

    /* Collapsed: the head shows the logo; hovering it swaps the logo for the expand button. */
    html[data-sidebar="collapsed"] .portal-collapse-btn {
        position: absolute;
        inset-inline-start: 18px;
        top: 50%;
        transform: translateY(-50%) rotate(180deg);
        opacity: 0;
    }

    html[data-sidebar="collapsed"] .portal-sidebar-head:hover .portal-collapse-btn,
    html[data-sidebar="collapsed"] .portal-collapse-btn:focus-visible {
        opacity: 1;
        background: var(--admin-hover);
        color: var(--admin-text-primary);
    }

    html[data-sidebar="collapsed"] .portal-sidebar-head:hover .portal-brand-mark,
    html[data-sidebar="collapsed"] .portal-sidebar-head:has(.portal-collapse-btn:focus-visible) .portal-brand-mark {
        opacity: 0;
    }

    html[data-sidebar="collapsed"] .portal-user {
        opacity: 0;
        pointer-events: none;
    }

    html[data-sidebar="collapsed"] .portal-user-rail {
        opacity: 1;
        visibility: visible;
        transition-delay: 0s;
    }

    html[data-sidebar="collapsed"] .portal-edge-toggle svg {
        transform: rotate(180deg);
    }

    .portal-collapse-btn {
        transition: opacity calc(var(--portal-speed) * .6) ease, background-color .15s ease, color .15s ease;
    }

    .portal-sidebar-backdrop {
        display: none;
    }
}

/* ---------- Phones and tablets: the sidebar slides over the page ---------- */

.portal-mobilebar {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: none;
    align-items: center;
    gap: 8px;
    height: 56px;
    padding: 0 12px;
    background: var(--admin-surface);
    border-bottom: 1px solid var(--admin-border);
}

.portal-mobilebar-brand {
    display: flex;
    align-items: center;
}

.portal-mobilebar-brand .portal-brand-wordmark {
    width: 108px;
}

.portal-sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1029;
    background: var(--portal-scrim);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--portal-speed) ease, visibility 0s linear var(--portal-speed);
}

@media (max-width: 991.98px) {
    :root,
    html[data-sidebar="collapsed"] {
        --portal-sidebar-w: min(var(--portal-sidebar-full), 86vw);
    }

    body.portal-shell .wrapper {
        margin-inline-start: 0;
    }

    .portal-sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }

    html[dir="rtl"] .portal-sidebar {
        transform: translateX(100%);
    }

    html.portal-nav-open .portal-sidebar {
        transform: none;
        box-shadow: var(--portal-shadow-pop);
    }

    html.portal-nav-open .portal-sidebar-backdrop {
        opacity: 1;
        visibility: visible;
        transition-delay: 0s;
    }

    html.portal-nav-open body {
        overflow: hidden;
    }

    .portal-collapse-btn,
    .portal-edge-toggle,
    .portal-user-rail {
        display: none;
    }

    .portal-close-btn {
        display: inline-flex;
    }

    .portal-mobilebar {
        display: flex;
    }

    body.portal-shell .portal-mobilebar ~ .wrapper .app-content {
        padding: 16px;
    }
}

/* ---------- Tooltip and flyout menus beside the rail ---------- */

.portal-tip {
    position: fixed;
    z-index: 1090;
    max-width: 260px;
    padding: 6px 10px;
    border-radius: 8px;
    background: #18181B;
    color: #FFFFFF;
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1.3;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity .12s ease, transform .12s ease;
}

html[data-bs-theme="dark"] .portal-tip {
    background: #FAFAFA;
    color: #18181B;
}

.portal-tip.is-visible {
    opacity: 1;
    transform: none;
}

.portal-flyout {
    position: fixed;
    z-index: 1080;
    min-width: 240px;
    max-width: min(320px, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
    padding: 8px;
    overflow-y: auto;
    border: 1px solid var(--admin-border);
    border-radius: 14px;
    background: var(--admin-surface);
    color: var(--admin-text-primary);
    box-shadow: var(--portal-shadow-pop);
    opacity: 0;
    transform: translateX(-6px) scale(.98);
    transform-origin: left center;
    transition: opacity .14s ease, transform .18s var(--portal-ease);
}

.portal-flyout[data-place="top"] {
    transform: translateY(6px) scale(.98);
    transform-origin: bottom center;
}

.portal-flyout.is-open {
    opacity: 1;
    transform: none;
}

.portal-flyout-title {
    margin: 2px 2px 6px;
    padding: 6px 10px 10px;
    border-bottom: 1px solid var(--admin-border);
    font-size: 15px;
    font-weight: 600;
}

.portal-flyout .portal-link {
    min-height: 40px;
    padding-inline: 10px;
    font-size: 14px;
}

.portal-flyout .portal-link .portal-nav-label,
.portal-flyout .portal-link .portal-menu-badge {
    opacity: 1;
}

.portal-menu-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px 12px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--admin-border);
}

.portal-menu-head .portal-avatar {
    width: 40px;
    height: 40px;
}

.portal-menu-label {
    padding: 6px 10px 4px;
    color: var(--admin-text-muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.portal-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 40px;
    padding: 0 10px;
    border-radius: 9px;
    color: var(--admin-text-primary);
    font-size: 14px;
    text-decoration: none;
}

.portal-menu-item:hover {
    background: var(--admin-hover);
    color: var(--admin-text-primary);
}

.portal-menu-item > svg {
    flex-shrink: 0;
    color: var(--admin-text-secondary);
}

.portal-menu-item.is-current {
    font-weight: 600;
}

.portal-menu-item.is-current::after {
    content: "";
    width: 7px;
    height: 7px;
    margin-inline-start: auto;
    border-radius: 999px;
    background: var(--admin-accent);
}

.portal-menu-item.is-danger,
.portal-menu-item.is-danger > svg {
    color: var(--portal-danger, #B91C1C);
}

.portal-menu-sep {
    height: 1px;
    margin: 6px 4px;
    background: var(--admin-border);
}

.portal-menu-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 44px;
    padding: 0 6px 0 10px;
    font-size: 14px;
}

.portal-segmented {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    border-radius: 10px;
    background: var(--admin-hover);
}

.portal-segmented button[data-admin-theme] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--admin-text-secondary);
    cursor: pointer;
}

.portal-segmented button[data-admin-theme]:hover {
    color: var(--admin-text-primary);
}

.portal-segmented button[data-admin-theme][aria-pressed="true"] {
    background: var(--admin-surface);
    color: var(--admin-text-primary);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .12), 0 0 0 1px var(--admin-border);
}

/* ---------- Record drawer ---------- */

.portal-drawer-overlay {
    position: fixed;
    inset: 0;
    z-index: 1040;
    background: var(--portal-scrim);
    opacity: 0;
    transition: opacity 280ms ease;
}

.portal-drawer {
    position: fixed;
    inset-block: 0;
    inset-inline-end: 0;
    z-index: 1045;
    display: flex;
    flex-direction: column;
    width: var(--portal-drawer-w);
    background: var(--admin-surface);
    border-inline-start: 1px solid var(--admin-border);
    box-shadow: -24px 0 48px -24px rgba(15, 23, 42, .35);
    transform: translateX(100%);
    transition: transform 320ms var(--portal-ease), width 240ms var(--portal-ease);
    will-change: transform;
}

/* Full width: the drawer covers the whole window (header button or a request from the screen inside). */
html.portal-drawer-wide {
    --portal-drawer-w: 100vw;
}

.portal-drawer-collapse-icon,
html.portal-drawer-wide .portal-drawer-expand-icon {
    display: none;
}

html.portal-drawer-wide .portal-drawer-collapse-icon {
    display: block;
}

.portal-drawer-expand[aria-pressed="true"] {
    color: var(--admin-accent);
}

html[dir="rtl"] .portal-drawer {
    transform: translateX(-100%);
}

.portal-drawer-overlay[hidden],
.portal-drawer[hidden] {
    display: none;
}

html.portal-drawer-open .portal-drawer-overlay {
    opacity: 1;
}

html.portal-drawer-open .portal-drawer {
    transform: none;
}

html.portal-drawer-open body {
    overflow: hidden;
}

.portal-drawer-head {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 68px;
    padding: 12px 20px 12px 16px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--admin-border);
}

.portal-drawer-crumb {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex: 1;
    min-width: 0;
    font-size: 15px;
    white-space: nowrap;
}

.portal-drawer-entity {
    flex-shrink: 0;
    color: var(--admin-text-secondary);
}

.portal-drawer-sep {
    color: var(--admin-text-muted);
}

.portal-drawer-record {
    overflow: hidden;
    color: var(--admin-text-primary);
    font-weight: 600;
    text-overflow: ellipsis;
}

.portal-drawer-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.portal-drawer-actions .btn {
    min-width: 76px;
    border-radius: 9px;
    font-weight: 600;
}

.portal-drawer-actions [hidden] {
    display: none !important;
}

.portal-drawer-body {
    position: relative;
    flex: 1;
    min-height: 0;
    background: var(--admin-bg);
}

.portal-drawer-frame {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: var(--admin-bg);
    opacity: 0;
    transition: opacity .2s ease;
}

.portal-drawer.is-ready .portal-drawer-frame {
    opacity: 1;
}

.portal-drawer-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--admin-text-secondary);
    font-size: 14px;
    pointer-events: none;
}

.portal-drawer-loading::before {
    content: "";
    width: 18px;
    height: 18px;
    border: 2px solid var(--admin-border);
    border-top-color: var(--admin-accent);
    border-radius: 999px;
    animation: portal-spin .7s linear infinite;
}

.portal-drawer.is-ready .portal-drawer-loading {
    display: none;
}

@keyframes portal-spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 575.98px) {
    :root {
        --portal-drawer-w: 100vw;
    }

    .portal-drawer-head {
        flex-wrap: wrap;
        padding: 10px 12px;
    }

    .portal-drawer-crumb {
        order: 2;
        flex-basis: 100%;
        padding-inline-start: 4px;
    }

    .portal-drawer-actions {
        margin-inline-start: auto;
    }

    /* The drawer already fills a phone screen. */
    .portal-drawer-expand {
        display: none;
    }
}

/* Full width on a page outside the drawer: hide the sidebar so the screen gets the whole window. */
@media (min-width: 992px) {
    html.portal-wide:not(.portal-embedded) .portal-sidebar {
        display: none;
    }

    html.portal-wide:not(.portal-embedded) body.portal-shell .wrapper {
        margin-inline-start: 0;
    }
}

/* List rows open their record in the drawer. */
html.portal-has-drawer #crudTable tbody tr[data-portal-open] {
    cursor: pointer;
}

html.portal-has-drawer #crudTable tbody tr.is-drawer-current > td {
    background: rgba(var(--admin-accent-rgb), .08) !important;
    box-shadow: none;
}

/* ---------- A screen shown inside the drawer has no chrome of its own ---------- */

html.portal-embedded body.portal-shell .wrapper {
    margin-inline-start: 0;
}

html.portal-embedded .app-loader,
html.portal-embedded .pace {
    display: none;
}

html.portal-embedded .app-content {
    padding: 20px 24px 32px;
}

/* The drawer header already has Close, Save and Edit. */
html.portal-embedded .portal-back-link,
html.portal-embedded #saveActions,
html.portal-embedded .portal-page-actions a[href$="/edit"] {
    display: none !important;
}

html.portal-embedded .portal-page-header {
    padding-top: 0;
}

@media (max-width: 575.98px) {
    html.portal-embedded .app-content {
        padding: 14px 12px 24px;
    }
}

/* ---------- Motion preferences and print ---------- */

@media (prefers-reduced-motion: reduce) {
    :root {
        --portal-speed: 1ms;
    }

    .portal-drawer,
    .portal-drawer-overlay,
    .portal-flyout,
    .portal-tip {
        transition-duration: 1ms;
    }
}

@media print {
    body.portal-shell .wrapper {
        margin-inline-start: 0;
    }

    .portal-sidebar,
    .portal-mobilebar,
    .portal-drawer,
    .portal-drawer-overlay {
        display: none !important;
    }
}
