/*
 * Prime RoadRunners — the frame of the two desk portals (store, admin).
 * Builds on rr.css (colours, buttons, fields, dialogs, toasts).
 *
 *   wide screen    menu on the left, with names
 *   tablet         menu on the left, icons only
 *   phone          menu at the bottom
 *
 * What is particular to a portal lives in its own app.css.
 */

body {
    min-height: 100dvh;
}

.shell {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    min-height: 100dvh;
}

/* ---------------------------------------------------------------------- menu */

.side {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 100dvh;
    padding: calc(24px + var(--safe-top)) 16px calc(24px + var(--safe-bottom)) calc(16px + var(--safe-left));
    border-right: 1px solid var(--border);
    background: var(--surface);
    overflow-y: auto;
}
.side__brand {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 8px;
    color: var(--text-3);
    font-size: 12px;
    line-height: 16px;
}
.side__brand img {
    width: 136px;
    height: auto;
}
.side__who {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    border-radius: var(--r-md);
    background: var(--canvas);
}
.side__name {
    font-size: 15px;
    font-weight: 600;
    line-height: 20px;
    overflow-wrap: anywhere;
}
.side__state {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--success);
    font-size: 13px;
    font-weight: 600;
    line-height: 18px;
}
.side__dot {
    width: 8px;
    height: 8px;
    flex-shrink: 0;
    border-radius: 50%;
    background: currentColor;
}
.side__state.is-off {
    color: var(--danger-soft-text);
}
.side__nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-grow: 1;
}
.side__item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: var(--tap);
    padding: 0 12px;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--text-2);
    font-size: 15px;
    font-weight: 600;
    text-align: left;
}
.side__item:hover {
    background: var(--surface-2);
    color: var(--ink);
}
.side__item[aria-current='page'] {
    background: var(--brand-soft);
    color: var(--brand-soft-text);
    font-weight: 700;
}
.side__item[aria-current='page']::before {
    content: '';
    position: absolute;
    top: 10px;
    bottom: 10px;
    left: 0;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--accent);
}
.side__label {
    flex-grow: 1;
}
.side__badge {
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: var(--r-pill);
    background: var(--accent-strong);
    color: var(--surface);
    font-size: 12px;
    font-weight: 700;
    line-height: 22px;
    text-align: center;
}

/* ---------------------------------------------------------------------- main */

.main {
    min-width: 0;
}
.view {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: calc(24px + var(--safe-top)) calc(32px + var(--safe-right)) 48px 32px;
}
.view__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 16px;
}
.view__title {
    font-size: 26px;
    font-weight: 700;
    line-height: 32px;
}
.view__spacer {
    flex-grow: 1;
}

.counts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex-grow: 1;
}
.count {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 32px;
    padding: 0 12px;
    border-radius: var(--r-pill);
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}
.count b {
    font-size: 18px;
}
.count--pending { background: var(--st-pending-bg); color: var(--st-pending); }
.count--active { background: var(--st-accepted-bg); color: var(--st-accepted); }

/* ------------------------------------------------- filters, totals, tables */

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    align-items: end;
    padding: 16px;
    box-shadow: none;
}
.filters__search {
    grid-column: span 2;
}
.totals {
    padding: 16px 8px;
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--surface);
}
.totals__value {
    font-size: 28px;
    line-height: 32px;
}
.totals__value--money {
    font-size: 24px;
}

.table-card {
    overflow: hidden;
    box-shadow: none;
}
.table-wrap {
    /* positioned: whatever it holds stays inside the frame that scrolls */
    position: relative;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    line-height: 20px;
}
.table th {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-3);
    font-size: 13px;
    font-weight: 700;
    text-align: left;
    white-space: nowrap;
}
.table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.table tr:last-child td {
    border-bottom: 0;
}
.table tbody tr:hover {
    background: var(--canvas);
}
.table .is-empty {
    color: var(--text-3);
}
.table__number {
    font-weight: 600;
    white-space: nowrap;
}
.table__when {
    white-space: nowrap;
}
.table__sub {
    display: block;
    color: var(--text-3);
    font-size: 13px;
}
.table__address {
    min-width: 200px;
    max-width: 340px;
    overflow-wrap: anywhere;
}
.table__money {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.table th.table__money {
    text-align: right;
}

/* -------------------------------------------------------------------- panels */

.panels {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
    align-items: start;
    max-width: 1100px;
}
.side__out {
    display: flex;
}
/* Shown on the page when the menu has no room for it */
.when-menu-narrow {
    display: none;
}

/* -------------------------------------------------------------------- tablet */

@media (max-width: 960px) {
    .shell {
        grid-template-columns: 72px minmax(0, 1fr);
    }
    .side {
        align-items: center;
        gap: 16px;
        padding-right: 8px;
        padding-left: calc(8px + var(--safe-left));
    }
    .side__brand,
    .side__who,
    .side__label,
    .side__out {
        display: none;
    }
    .side__nav {
        width: 100%;
    }
    .side__item {
        justify-content: center;
        min-height: 52px;
        padding: 0;
    }
    .side__item .icon {
        width: 24px;
        height: 24px;
    }
    .side__badge {
        position: absolute;
        top: 4px;
        right: 4px;
    }
    .when-menu-narrow {
        display: flex;
    }
    .view {
        padding-right: calc(20px + var(--safe-right));
        padding-left: 20px;
    }
}

/* --------------------------------------------------------------------- phone */

@media (max-width: 640px) {
    :root {
        --toasts-lift: 72px;
    }
    .shell {
        display: block;
        padding-bottom: calc(64px + var(--safe-bottom));
    }
    .side {
        position: fixed;
        top: auto;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 100;
        flex-direction: row;
        height: calc(64px + var(--safe-bottom));
        padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
        border-top: 1px solid var(--border);
        border-right: 0;
        overflow: visible;
    }
    .side__nav {
        flex-direction: row;
        gap: 0;
        height: 100%;
    }
    .side__item {
        flex: 1 1 0;
        flex-direction: column;
        gap: 3px;
        min-height: 0;
        border-radius: 0;
        font-size: 12px;
    }
    .side__label {
        display: block;
        flex-grow: 0;
    }
    .side__item[aria-current='page'] {
        background: transparent;
        color: var(--brand);
    }
    .side__item[aria-current='page']::before {
        top: 0;
        right: 24px;
        bottom: auto;
        left: 24px;
        width: auto;
        height: 3px;
        border-radius: 0 0 3px 3px;
    }
    .side__badge {
        top: 6px;
        right: auto;
        left: calc(50% + 8px);
        min-width: 20px;
        height: 20px;
        line-height: 20px;
    }

    .view {
        gap: 16px;
        padding: calc(16px + var(--safe-top)) calc(16px + var(--safe-right)) 24px calc(16px + var(--safe-left));
    }
    .view__head {
        gap: 10px 12px;
    }
    .view__title {
        flex-grow: 1;
        font-size: 22px;
        line-height: 28px;
    }
    .counts {
        order: 3;
        flex-basis: 100%;
    }

    .filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .filters__search,
    .filters__wide {
        grid-column: 1 / -1;
    }
    .panels {
        grid-template-columns: minmax(0, 1fr);
    }
}
