/* ============================================
   PHOENIX - SHARED LIST PAGE RULES (T-20261027-03, U3)
   The wrapper, the phone cards and the phone/desktop switch of the list pages.
   Linked by its own @Assets link in App.razor, like every framework file since
   T-20261030-03 (A1): the service worker serves a plain URL cache first, so an
   @import file loaded old on the first load after a deploy (T-20261027-02 F4).
   Every framework file has a new URL after each change; a new framework file
   gets its own @Assets link. It also holds the phone padding of .main-content for
   every page (Q9) and the page height rule of every page (T-20261028-03).
   ============================================ */

/* The page height of every page (the owner, 2026-10-29: an empty scroll at the bottom of every page).
   .main-content has margin-top: 56px for the fixed header (mobile.css); without a block formatting context on
   body that margin falls through body, so body started 56 px down and was still 100vh high: 56 px of empty scroll.
   flow-root keeps the margin inside body. Below 1024 px .main-content's min-height (the screen - 120 px:
   the header 56 + the bottom bar 64) fills the screen exactly; from 1024 px (no bottom bar) it ends 64 px
   higher and body's min-height fills the rest. The page wrappers carry no min-height of their own.
   dvh (the visible height): on a phone browser 100vh counts the hidden address bar, so a short page would
   still scroll by the bar's height. The vh line is the fallback of an old browser.
   These override base.css and mobile.css (loaded earlier, same specificity). */
body {
    display: flow-root;
    min-height: 100vh;
    min-height: 100dvh;
}

/* No browser tap rectangle on the phone (T-20261029-01 Part C, the owner's point): the phone browser drew its own
   blue box over every tapped control, square also on a round button or a pill. Inherited by every element.
   The keyboard focus keeps its ring (*:focus-visible in phoenix.css).
   scrollbar-gutter (T-20261103-05, the owner's Q5): the page keeps the scrollbar's space always, so the page does not
   jump sideways when a page lock hides the scrollbar. Never an overflow value on html: it would stop the overflow of
   body going to the viewport and would break every body lock of this file and mobile.css. */
html {
    -webkit-tap-highlight-color: transparent;
    scrollbar-gutter: stable;
}

/* The sign-in pages paint their gradient over the full width and hold no window and no lock: the space would only show a
   light strip beside the gradient (the owner, 2026-11-03, T-20261103-05 E1). */
html:has(.auth-layout) {
    scrollbar-gutter: auto;
}

.main-content {
    min-height: calc(100vh - 120px);
    min-height: calc(100dvh - 120px);
}

/* Page wrapper (no min-height: .main-content and body fill the screen, see above) */
.list-page {
    padding: 24px 16px;
    background: var(--bg-secondary);
}

/* Mobile/Desktop toggle */
.mobile-only {
    display: none;
}

/* Mobile Card Styles */
.mobile-cards {
    flex-direction: column;
    gap: 8px;
}

/* The phone card (T-20261029-01, U6, the owner's "Accent + soft panel" look): a white surface with a soft
   two-layer shadow and a 4 px strip on the left in the accent colour of the row (ExpandableCard, card-accent-*).
   The left padding holds the strip. */
.mobile-card {
    position: relative;
    overflow: hidden;
    background: var(--bg-primary);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    padding: 14px 16px 14px 20px;
    box-shadow: var(--shadow-card);
    transition: box-shadow var(--transition-fast);
}

.mobile-card:active {
    box-shadow: var(--shadow-raised);
}

.mobile-card::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 4px;
}

.card-accent-neutral::before { background: var(--color-primary); }
.card-accent-success::before { background: var(--status-active); }
.card-accent-warning::before { background: var(--color-warning); }
.card-accent-danger::before { background: var(--color-danger); }
.card-accent-muted::before { background: var(--status-suspended); }

.mobile-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

/* A card with only its head (no meta row, no bottom row, closed) */
.mobile-card-top:last-child {
    margin-bottom: 0;
}

.mobile-card-identity {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.mobile-card-info {
    min-width: 0;
    flex: 1;
}

/* The full name wraps (T-20261029-01: every desktop field is on the card; the name was cut with "...") */
.mobile-card-name {
    font-weight: 600;
    font-size: var(--font-size-base);
    color: var(--text-primary);
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.mobile-card-sub {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mobile-card-sub i {
    font-size: 10px;
    color: var(--color-primary);
    flex-shrink: 0;
}

.mobile-card-bottom {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    padding-top: 10px;
    border-top: 1px solid var(--color-border);
}

/* The buttons wrap to a second line at the right when they do not fit (Boss Users: Approve, Deactivate, Roles, the arrow) */
.mobile-card-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

/* 44 px tap targets on the phone cards: a text button is a 44 px high pill (Approve, Revoke, Block),
   an icon-only button (card-btn-icon) is a round 44 px button */
.mobile-card-actions .btn {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 16px;
    border-radius: 22px;
}

.mobile-card-actions .btn.card-btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
}

/* A ghost button gets a soft fill and a border (on the white card --bg-secondary is almost white) */
.mobile-card-actions .btn-ghost {
    background: var(--bg-tertiary);
    border: 1px solid var(--color-border);
}

.mobile-card-actions .btn-ghost.text-danger {
    background: rgba(var(--color-danger-rgb), 0.08);
    border-color: rgba(var(--color-danger-rgb), 0.25);
}

/* The pressed look (T-20261030-03 D6): the card's ghost buttons already rest on a soft fill, so the press
   shows a darker one; the button also shrinks a little (.btn:active in buttons.css). */
.card-btn-icon:active:not(:disabled) {
    transform: scale(0.97);
}

.mobile-card-actions .btn-ghost:active:not(:disabled) {
    background: var(--color-border);
}

.mobile-card-actions .btn-ghost.text-danger:active:not(:disabled) {
    background: rgba(var(--color-danger-rgb), 0.16);
}

/* The meta row (the Machines version, connection, last seen): a line above and under it */
.card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    padding: 8px 0;
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 8px;
}

.card-meta + .mobile-card-bottom {
    padding-top: 0;
    border-top: 0;
}

/* The flags as 24 px pills with a 10 % tint of their colour; the text in the -dark tone of the colour
   (as the .badge-* rules: the base colour on its tint is about 2:1) */
.card-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.card-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 24px;
    padding: 0 10px;
    border-radius: 12px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    white-space: nowrap;
}

.card-chip i {
    font-size: 11px;
}

.card-chip-info {
    background: rgba(var(--color-info-rgb), 0.1);
    color: var(--color-info-dark);
}

.card-chip-success {
    background: rgba(var(--color-success-rgb), 0.1);
    color: var(--color-success-dark);
}

.card-chip-warning {
    background: rgba(var(--color-warning-rgb), 0.1);
    color: var(--color-warning-dark);
}

.card-chip-danger {
    background: rgba(var(--color-danger-rgb), 0.1);
    color: var(--color-danger-dark);
}

/* No -rgb token exists for grey */
.card-chip-muted {
    background: var(--bg-tertiary);
    color: var(--status-suspended);
}

/* The arrow: the last button of the bottom row; open, it turns and gets the primary tint */
.card-toggle i {
    transition: transform var(--transition-base);
}

.mobile-card-actions .card-toggle-open {
    background: rgba(var(--color-primary-rgb), 0.1);
    border-color: rgba(var(--color-primary-rgb), 0.3);
    color: var(--color-primary);
}

.card-toggle-open i {
    transform: rotate(180deg);
}

/* The open part: a soft panel with a two-column grid of label and value. min-width: 0 keeps a long
   identifier or a JSON block inside the grid. */
.card-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
    margin: 12px 0 0;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 10px;
    animation: card-details-in var(--transition-base);
}

.card-field {
    min-width: 0;
}

.card-field-wide {
    grid-column: 1 / -1;
}

.card-field dt {
    margin: 0 0 2px;
    font-size: var(--font-size-2xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.card-field dd {
    margin: 0;
    min-width: 0;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

/* A link in the open part (the manager phone) is a 44 px tap target */
.card-field dd a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
}

/* An identifier */
.card-mono {
    font-family: var(--font-mono);
    letter-spacing: 0.5px;
}

/* 44 px controls inside the open part (the Packages ring select, a JSON toggle) */
.card-details .form-select,
.card-details .btn {
    min-height: 44px;
}

/* A choice card (MachinePicker on the phone): a label with its radio first; a tap anywhere picks it */
.card-pick {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    cursor: pointer;
}

/* The picked choice card: a primary border and tint, not only the radio dot */
.card-pick:has(input:checked) {
    border-color: var(--color-primary);
    background: rgba(var(--color-primary-rgb), 0.06);
}

@keyframes card-details-in {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .card-toggle i {
        transition: none;
    }

    .card-details {
        animation: none;
    }
}

@media (max-width: 768px) {
    /* The phone space of every page (Q9). Overrides mobile.css .main-content
       (1rem), which loads earlier with the same specificity. */
    .main-content {
        padding: 8px;
    }

    /* With the 8 px of .main-content: 12 px from the screen edge (Q9) */
    .list-page {
        padding: 8px 4px;
    }

    .desktop-only {
        display: none;
    }

    /* 44 px Previous / Next of the Boss pages (BossUsers, BossAudit); a global rule here, not in the five
       identical Boss files (C1) */
    .boss-paging .btn {
        min-height: 44px;
    }

    .mobile-only {
        display: flex;
    }
}

/* The sticky phone toolbar (T-20261029-01, D7): under the fixed header (56 px, z-index 1000) and the bottom bar,
   over the cards. The background and the bottom padding (not a margin) leave no gap that shows the cards.
   Both rules are here, the raise after the sticky rule: a scoped rule would win over a global raise.
   Not on a phone turned to landscape (less than 500 px high): the toolbar would leave little room for the cards. */
@media (max-width: 768px) and (min-height: 500px) {
    .list-toolbar {
        position: sticky;
        top: 56px;
        z-index: 990;
        background: var(--bg-secondary);
    }

    /* The open filter sheet: sticky makes the toolbar its own layer, so the sheet (2100 / 2101) stays inside it;
       the raise lifts the layer over the header, the bottom bar and the list modals (1050); it stops with the close at
       once (filter-dd-closing, T-20261030-03 C2) */
    .list-toolbar:has(.filter-dd-sheet-open:not(.filter-dd-closing)) {
        z-index: 2050;
    }
}

/* The open bottom sheet of FilterDropdown (T-20261028-01): the page behind does not scroll.
   Not scoped: a rule on body. The marker class leaves the DOM with the sheet, also at a page change; the lock stops
   with the close at once (filter-dd-closing, T-20261030-03 C2). */
@media (max-width: 768px) {
    body:has(.filter-dd-sheet-open:not(.filter-dd-closing)) {
        overflow: hidden;
    }
}

/* The open bell panel (T-20261030-02, U9, D3): it lives inside the header (1000, painted under the bottom bar), so the
   raise lifts the header over the bottom bar, the sticky toolbar and the "More" menu (2000), under the filter sheet
   (2100), the PWA layers and the toasts (100100). The marker class leaves the DOM with the panel.
   :not(.notif-panel-closing) (E2): both rules stop at the moment the script hides the panel, not after the server's
   round trip. */
.app-header:has(.notif-panel-open:not(.notif-panel-closing)) {
    z-index: 2050;
}

/* The bell's bottom sheet: the page behind does not scroll (the copy of the filter sheet's lock) */
@media (max-width: 768px) {
    body:has(.notif-panel-open:not(.notif-panel-closing)) {
        overflow: hidden;
    }
}

/* Every form window (form-modal-backdrop), the Pending client picker and the reconnect dialog: the page behind does not
   scroll, at every width (the owner, 2026-11-03, T-20261103-05). :not(...-closing): the lock ends at the moment the script
   hides the window (the drawer's and the bell's pattern); the window's own body keeps scrolling (components.css
   .form-modal-body). The picker's two overlay classes are named, so no other "picker-open" locks the page.
   The install guide dialog joins it (T-20261121-01, P5). The five body locks: the filter sheet, the bell sheet, the
   drawer sheet, the "More" sheet (the script's modal-open, mobile.css) and this one. Not scoped: a .razor.css file
   cannot hold a rule on body. */
body:has(.form-modal-backdrop:not(.form-modal-closing)),
body:has(:is(.picker-overlay, .add-client-overlay).picker-open:not(.picker-closing)),
body:has(#components-reconnect-modal[open]),
body:has(#install-guide[open]) {
    overflow: hidden;
}

@media (max-width: 480px) {
    /* The left padding keeps the 4 px strip clear */
    .mobile-card {
        padding: 12px 14px 12px 18px;
    }
}

/* ============================================
   THE LIST STATES AND THE DETAIL DRAWER (T-20261029-02, U7; the owner's Q10 and Q11)
   ============================================ */

/* The width of the detail drawer (DetailDrawer.razor.css) from 1024 px; the list's right margin reads it too */
:root {
    --detail-drawer-width: clamp(360px, 35vw, 480px);
}

/* A text for a screen reader only (the status text of ListSkeleton) */
.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* The empty and the error state of a list (EmptyState, ErrorState): a card with the icon, the title, the text and
   an optional button. The error block has the danger strip on the left, as a phone card. */
.list-state {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 48px 24px;
    background: var(--bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}

.list-state-icon {
    margin-bottom: 16px;
    font-size: 56px;
    line-height: 1;
    color: var(--text-secondary);
}

.list-state-title {
    margin: 0 0 8px;
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
}

.list-state-text {
    max-width: 480px;
    margin: 0;
    color: var(--text-secondary);
    overflow-wrap: anywhere;
}

.list-state-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.list-state-error::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 4px;
    background: var(--color-danger);
}

.list-state-error .list-state-icon {
    color: var(--color-danger);
}

/* A failed later load: the rows of before stay under this bar (ErrorState Stale) */
.list-stale {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin-bottom: 12px;
    padding: 10px 14px;
    background: rgba(var(--color-warning-rgb), 0.1);
    border: 1px solid rgba(var(--color-warning-rgb), 0.35);
    border-radius: var(--radius-md);
    color: var(--color-warning-dark);
    font-size: var(--font-size-sm);
}

.list-stale-icon {
    flex-shrink: 0;
}

.list-stale-text {
    flex: 1 1 200px;
    min-width: 0;
}

/* The name of a row opens the detail drawer: a button that looks like the text around it (it inherits the weight
   of its line). A button centres its text; base.css resets only the font, the border and the background.
   No overflow-wrap here: "anywhere" let a table cell shrink to one letter per line (measured at 1025 px); the card name
   inherits it from .mobile-card-name. */
.row-name-btn {
    padding: 0;
    margin: 0;
    border: 0;
    background: none;
    color: inherit;
    font-weight: inherit;
    text-align: start;
    cursor: pointer;
}

@media (hover: hover) {
    .row-name-btn:hover {
        text-decoration: underline;
    }
}

.row-name-btn:focus-visible {
    text-decoration: underline;
}

/* 44 px touch targets below 1024 px: the name button, the Retry and clear buttons of the states */
@media not all and (min-width: 1024px) {
    .row-name-btn {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
    }

    .list-state-actions .btn,
    .list-stale .btn {
        min-height: 44px;
    }
}

/* The fields of a drawer section (DrawerSection): the soft panel of the card fields without the open animation */
.drawer-fields {
    margin: 0;
    animation: none;
}

@media (max-width: 399.98px) {
    .drawer-fields {
        grid-template-columns: 1fr;
    }
}

/* The open detail drawer from 1024 px (a panel at the right side, DetailDrawer.razor.css): the list gets narrower, so
   the search, the filter and the Pager stay visible (the owner's Q8). The search box shrinks with it (the fixed 360 px
   box went under the drawer at 1024 px); these selectors win over the scoped ListToolbar rules: (0,3,1) against (0,2,0).
   :not(.detail-drawer-closing): the rules stop at the moment the script hides the drawer, not after the server's round
   trip (T-20261029-02 B0b). */
@media (min-width: 1024px) {
    body:has(.detail-drawer-open:not(.detail-drawer-closing)) .main-content {
        margin-right: var(--detail-drawer-width);
    }

    body:has(.detail-drawer-open:not(.detail-drawer-closing)) .list-toolbar-search {
        width: 100%;
        max-width: 360px;
        flex-shrink: 1;
        min-width: 0;
    }

    body:has(.detail-drawer-open:not(.detail-drawer-closing)) .list-toolbar-controls {
        flex: 1 1 auto;
        min-width: 0;
    }

    /* The page header wraps (measured at 1025 px with the sidebar open: the Add button covered the title): the text keeps
       140 px beside the icon, the button goes to its own line at the right when it does not fit */
    body:has(.detail-drawer-open:not(.detail-drawer-closing)) .page-head {
        flex-wrap: wrap;
    }

    body:has(.detail-drawer-open:not(.detail-drawer-closing)) .page-head-text {
        flex: 1 1 140px;
    }

    body:has(.detail-drawer-open:not(.detail-drawer-closing)) .page-head-title {
        font-size: var(--font-size-xl);
        overflow-wrap: anywhere;
    }

    body:has(.detail-drawer-open:not(.detail-drawer-closing)) .page-head-actions {
        margin-left: auto;
    }
}

/* The open drawer below 1024 px is a sheet over the page (the owner's Q9): the page behind does not scroll. Its own
   block, not the 768 px block of the filter sheet; the exact opposite of "min-width: 1024px" (a zoom level). */
@media not all and (min-width: 1024px) {
    body:has(.detail-drawer-open:not(.detail-drawer-closing)) {
        overflow: hidden;
    }
}
