/* Shared by the signed-in pages (dashboard/) and their components. Page layouts go in each page's .razor.css.
   Colours come from the MudBlazor theme (RoundelTheme), via its --mud-palette-* variables. */

/* Page to page: the browser cross-fades the content while the frame (top bar, side menu, tab bar) stays still,
   because each has its own view-transition-name (DashboardLayout.razor.css). Works for whole-page loads, which is
   why the dashboard turns Blazor's enhanced navigation off. Browsers without View Transitions just change page. */
@view-transition {
    navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: .2s;
}

/* Each page's content rises in gently as it loads */
.dash-main > * {
    animation: dash-fade-up .3s ease both;
}

@keyframes dash-fade-up {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

/* People who've asked their device for less motion get none of it */
@media (prefers-reduced-motion: reduce) {
    @view-transition {
        navigation: none;
    }

    .dash-main > * {
        animation: none;
    }
}

/* The hidden attribute must win over the display set on these elements (e.g. filtered-out list rows) */
[hidden] {
    display: none !important;
}

/* The white card every section sits in */
.dash-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 16px;
    border-radius: 18px;
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-default);
}

    .dash-card h2 {
        margin: 0;
        font-size: 1rem;
        font-weight: 800;
    }

    .dash-card p {
        margin: 0;
    }

/* A card's title row: heading on the left, a note on the right */
.card-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}

.muted {
    color: var(--mud-palette-text-secondary);
}

/* A labelled form field on dashboard pages: <label class="dash-field"><span>Label</span><input …></label> */
.dash-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

    .dash-field > span:first-child {
        font-size: .875rem;
        font-weight: 700;
    }

    .dash-field input:not([type="checkbox"]),
    .dash-field select {
        height: 48px;
        min-width: 0;
        padding: 0 14px;
        font: inherit;
        font-size: 1rem;           /* 16px+ stops iPhones zooming in on focus */
        color: var(--mud-palette-text-primary);
        border-radius: 12px;
        border: 1px solid var(--mud-palette-lines-inputs);
        background: var(--mud-palette-surface);
    }

        .dash-field input:focus-visible,
        .dash-field select:focus-visible {
            outline: 2px solid var(--mud-palette-primary);
            outline-offset: -1px;
        }

    .dash-field .validation-message {
        font-size: .8125rem;
        color: var(--mud-palette-error);
    }

/* Site picker (Components/SitePicker.razor). Global rather than scoped: dashboard.js adds chips, and elements made by
   script don't carry Blazor's scoped-CSS attribute. */
.site-picker {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

    .site-picker .count {
        font-size: .875rem;
        font-weight: 700;
    }

    .site-picker .chips {
        list-style: none;
        margin: 0;
        padding: 0;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

        .site-picker .chips:not(:has(li)) {
            display: none;
        }

        .site-picker .chips li {
            display: inline-flex;
            align-items: center;
            gap: 2px;
            max-width: 100%;
            padding-left: 12px;
            font-size: .875rem;
            font-weight: 600;
            color: var(--mud-palette-primary);
            border-radius: 999px;
            background: color-mix(in srgb, var(--mud-palette-primary) 8%, var(--mud-palette-surface));
        }

            .site-picker .chips li span {
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;
            }

        .site-picker .chips button {
            width: 32px;
            height: 32px;
            flex: none;
            font: inherit;
            font-size: 1.125rem;
            line-height: 1;
            color: inherit;
            cursor: pointer;
            border: 0;
            border-radius: 16px;
            background: none;
        }

            .site-picker .chips button:hover {
                background: color-mix(in srgb, var(--mud-palette-primary) 14%, transparent);
            }

            .site-picker .chips button:focus-visible {
                outline: 2px solid var(--mud-palette-primary);
            }

    /* The list scrolls on its own, so the page (and its buttons) stay short */
    .site-picker .choices {
        list-style: none;
        margin: 0;
        padding: 0;
        max-height: min(40dvh, 380px);
        overflow-y: auto;
        overscroll-behavior: contain;
        border-radius: 12px;
        border: 1px solid var(--mud-palette-lines-default);
    }

        .site-picker .choices li + li {
            border-top: 1px solid var(--mud-palette-lines-default);
        }

        .site-picker .choices label {
            display: flex;
            align-items: center;
            gap: 12px;
            min-height: 56px;
            padding: 8px 14px;
            cursor: pointer;
        }

            .site-picker .choices label:hover {
                background: var(--mud-palette-action-default-hover);
            }

        .site-picker .choices input {
            width: 20px;
            height: 20px;
            flex: none;
            accent-color: var(--mud-palette-primary);
        }

    .site-picker .choice-text {
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

        .site-picker .choice-text .muted {
            font-size: .8125rem;
        }

/* "← Back to …" link at the top of a card */
.back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    align-self: flex-start;
    min-height: 32px;
    font-size: .875rem;
    font-weight: 700;
    color: var(--mud-palette-primary);
    text-decoration: none;
}

/* Form buttons on dashboard pages (Register user, Manage sites) */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 48px;
    padding: 0 18px;
    font: inherit;
    font-size: .9375rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    border-radius: 12px;
}

.btn-primary {
    color: var(--mud-palette-primary-text);
    border: 0;
    background: var(--mud-palette-primary);
}

    .btn-primary:hover {
        background: var(--mud-palette-primary-darken);
    }

.btn-secondary {
    color: inherit;
    border: 1px solid var(--mud-palette-lines-inputs);
    background: var(--mud-palette-surface);
}

/* A text-only button, e.g. "Edit details", "Remove" */
.edit-link {
    min-height: 40px;
    padding: 0 12px;
    font: inherit;
    font-size: .875rem;
    font-weight: 700;
    color: var(--mud-palette-primary);
    cursor: pointer;
    border: 0;
    border-radius: 10px;
    background: none;
}

    .edit-link:hover {
        background: var(--mud-palette-action-default-hover);
    }

/* For things that can't be undone, e.g. "Delete call off" */
.btn-danger {
    color: var(--mud-palette-error-text);
    border: 0;
    background: var(--mud-palette-error);
}

    .btn-danger:hover {
        background: var(--mud-palette-error-darken);
    }

/* The "are you sure?" dialog for forms with data-confirm (built by wwwroot/js/dashboard.js) */
.confirm-dialog {
    /* Centred on screen: set explicitly, because MudBlazor's reset takes away the browser's margin: auto */
    position: fixed;
    inset: 0;
    margin: auto;
    height: fit-content;
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    box-sizing: border-box;
    width: min(420px, calc(100vw - 32px));
    padding: 24px;
    color: var(--mud-palette-text-primary);
    border: 0;
    border-radius: 16px;
    background: var(--mud-palette-surface);
    box-shadow: var(--mud-elevation-24);
}

    .confirm-dialog[open] {
        animation: dash-fade-up .2s ease both;
    }

    .confirm-dialog::backdrop {
        background: var(--mud-palette-overlay-dark);
    }

    .confirm-dialog h2 {
        margin: 14px 0 4px;
        font-size: 1.25rem;
        font-weight: 700;
    }

.confirm-icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    color: var(--mud-palette-error);
    border-radius: 50%;
    background: color-mix(in srgb, var(--mud-palette-error) 12%, transparent);
}

.confirm-detail {
    margin: 0;
    font-size: .875rem;
    color: var(--mud-palette-text-secondary);
}

.confirm-warning {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 16px 0 0;
    padding: 12px 14px;
    font-size: .875rem;
    color: var(--mud-palette-warning-darken);
    border-radius: 10px;
    background: color-mix(in srgb, var(--mud-palette-warning) 12%, transparent);
}

    .confirm-warning svg {
        flex-shrink: 0;
    }

/* Phone: buttons full width, the red one on top (nearest the thumb) */
.confirm-buttons {
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    margin-top: 20px;
}

@media (min-width: 480px) {
    .confirm-buttons {
        flex-direction: row;
        justify-content: flex-end;
    }
}

@media (prefers-reduced-motion: reduce) {
    .confirm-dialog[open] {
        animation: none;
    }
}

.btn:focus-visible,
.edit-link:focus-visible {
    outline: 2px solid var(--mud-palette-primary);
    outline-offset: 2px;
}

/* A list of sites (Site | Customer | Account [| action]): a table on desktop; on phones each site is a small block
   with the headings hidden and the labels inline */
.site-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

    .site-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
    }

    .site-table tr {
        display: flex;
        flex-direction: column;
        gap: 2px;
        padding: 10px 0;
        border-top: 1px solid var(--mud-palette-lines-default);
    }

    .site-table td {
        display: block;
        overflow-wrap: anywhere;
    }

        .site-table td[data-label]:not(:first-child) {
            color: var(--mud-palette-text-secondary);
        }

        .site-table td[data-label]:not(:first-child)::before {
            content: attr(data-label) ": ";
            font-weight: 700;
        }

        .site-table td.action {
            align-self: flex-start;
            margin-left: -12px;     /* line the text button up with the text above */
        }

@media (min-width: 960px) {
    .site-table thead {
        position: static;
        display: table-header-group;
        width: auto;
        height: auto;
        overflow: visible;
        clip-path: none;
    }

    .site-table tr {
        display: table-row;
    }

    .site-table {
        font-size: .8125rem;
    }

    .site-table th,
    .site-table td {
        display: table-cell;
        padding: 7px 16px 7px 0;
        text-align: left;
        vertical-align: middle;
        border-top: 1px solid var(--mud-palette-lines-default);
    }

    .site-table th {
        font-size: .6875rem;
        font-weight: 700;
        letter-spacing: .04em;
        text-transform: uppercase;
        color: var(--mud-palette-text-secondary);
        border-top: 0;
    }

        .site-table td[data-label]:not(:first-child)::before {
            content: none;
        }

        .site-table td.action {
            margin: 0;
            padding-right: 0;
            text-align: right;
        }
}

/* Pages in steps (Register user, Kitchen call off): the progress line and the Back / Continue bar ---------------- */

/* Progress: numbered steps under a coloured line. <ol class="steps"><li class="done|current">… */
.steps {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    display: flex;
    gap: 6px;
}

    .steps li {
        flex: 1;
        min-width: 0;
        display: flex;
        align-items: center;
        gap: 8px;
        padding-top: 10px;
        font-size: .8125rem;
        font-weight: 600;
        color: var(--mud-palette-text-secondary);
        border-top: 4px solid var(--mud-palette-lines-default);
    }

        .steps li.done,
        .steps li.current {
            border-top-color: var(--mud-palette-primary);
        }

        .steps li.current {
            font-weight: 800;
            color: var(--mud-palette-text-primary);
        }

    /* A step that can be gone back to is a button that looks like the rest of the step */
    .steps .step-go {
        display: flex;
        align-items: center;
        gap: 8px;
        min-width: 0;
        min-height: 32px;
        padding: 0;
        font: inherit;
        color: inherit;
        text-align: left;
        cursor: pointer;
        border: 0;
        background: none;
    }

        .steps .step-go:focus-visible {
            outline: 2px solid var(--mud-palette-primary);
            outline-offset: 2px;
            border-radius: 6px;
        }

.step-num {
    width: 24px;
    height: 24px;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    font-weight: 800;
    border-radius: 12px;
    background: var(--mud-palette-background-gray);
}

.steps li.done .step-num,
.steps li.current .step-num {
    color: var(--mud-palette-primary-text);
    background: var(--mud-palette-primary);
}

/* Phones: only the current step's label, to fit. Its step takes the room the label needs and the others share
   what's left, so a long label ("Appliances") never runs into the next step's number. */
.steps li.current {
    flex: 0 0 auto;
    white-space: nowrap;
}

.steps li:not(.current) .step-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
}

/* The Back / Continue bar of a wizard (the call off, Register user). Phones: a slim strip fixed to the bottom edge, in
   place of the tab bar (hidden below while the page has a wizard: one task at a time, and the page's back link still
   leads out). Continue fills the width for an easy tap; the progress line at the top already says which step. */
.wizard-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 11;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--mud-palette-lines-default);
    background: var(--mud-palette-surface);
}

    .wizard-bar .btn {
        min-height: 44px;
    }

    .wizard-bar .btn-primary {
        flex: 1;
    }

.bar-note {
    display: none;
    font-size: .8125rem;
}

@media (max-width: 959.98px) {
    /* The bar takes the tab bar's place, so the page only needs room for the bar */
    .dash:has(.wizard-bar) .dash-tabs {
        display: none;
    }

    .dash:has(.wizard-bar) .dash-main {
        padding-bottom: calc(76px + env(safe-area-inset-bottom));
    }
}

@media (min-width: 960px) {
    /* Same selector as the phone rule that hides them, so this later one wins */
    .steps li:not(.current) .step-label {
        position: static;
        width: auto;
        height: auto;
        overflow: visible;
        clip-path: none;
    }

    /* Every label shows, so every step gets an equal share again */
    .steps li.current {
        flex: 1;
        white-space: normal;
    }

    /* Wide screens: no floating, just the buttons in line under the step, where the step ends */
    .wizard-bar {
        position: static;
        padding: 0;
        border: 0;
        background: none;
    }

        .wizard-bar .btn {
            min-height: 38px;
        }

        .wizard-bar .btn-primary {
            flex: none;
        }

    .bar-note {
        display: block;
        flex: 1;
        text-align: right;
    }
}

/* For screen readers only */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* Grey placeholder shown while a page's data loads (stream rendering) */
.skeleton {
    border-radius: 18px;
    background: linear-gradient(90deg, var(--mud-palette-background-gray) 25%, var(--mud-palette-lines-default) 50%, var(--mud-palette-background-gray) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.3s linear infinite;
}

@keyframes skeleton-shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
    .skeleton {
        animation: none;
    }
}

/* Desktop is compact, so a lot fits on screen at 100% zoom. These are the standard sizes for every dashboard page
   (set by Site details, 2026-11-05): pages size their own content to match, not bigger. Phones keep the roomier
   sizes above, for thumbs. */
@media (min-width: 960px) {
    .dash-card {
        gap: 10px;
        padding: 14px 16px;
        border-radius: 14px;
    }

        .dash-card h2 {
            font-size: .9375rem;
        }

    .card-head .muted {
        font-size: .8125rem;
    }

    .back {
        min-height: 28px;
        font-size: .8125rem;
    }

    .btn {
        min-height: 36px;
        padding: 0 14px;
        font-size: .875rem;
        border-radius: 10px;
    }

    .edit-link {
        min-height: 32px;
        padding: 0 10px;
        font-size: .8125rem;
        border-radius: 8px;
    }

    .dash-field {
        gap: 4px;
    }

        .dash-field > span:first-child {
            font-size: .8125rem;
        }

        /* No iPhone zoom to worry about on desktop, so the text can be smaller than 16px */
        .dash-field input:not([type="checkbox"]),
        .dash-field select {
            height: 38px;
            padding: 0 12px;
            font-size: .875rem;
            border-radius: 10px;
        }

    .site-picker {
        gap: 10px;
    }

        .site-picker .count,
        .site-picker .chips li {
            font-size: .8125rem;
        }

        .site-picker .chips button {
            width: 28px;
            height: 28px;
        }

        .site-picker .choices label {
            min-height: 44px;
            padding: 6px 12px;
        }

    .skeleton {
        border-radius: 14px;
    }
}
