/*
    Flex Hub profile screen.

    Mobile first, one structural breakpoint at 900px, same as the shell. Below it the screen is the
    full-height form with its own phone header. Above it the same form sits on a 440px panel
    shown in the shell's profile dialog.

    Token-table values come through custom properties. Remaining literals are copied from the design
    screens. The full sourcing rule is stated once, in tokens.css.
*/

.pf-page {
    height: 100%;
}

.pf-panel {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Carries the panel's column layout, so the body still scrolls under the pinned actions. */
.pf-form {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/*
    The dialog only opens on wide screens. It is a bare frame, and the panel inside it carries the
    look of the surface.
*/
.pf-dialog {
    padding: 0;
    border: none;
    background: transparent;
    max-width: none;
    max-height: none;
    overflow: visible;
    color: inherit;
}

.pf-dialog::backdrop {
    background: var(--scrim);
}

/* ---- Header ---- */

.pf-header--wide {
    display: none;
}

/* The phone header sits on the navigation surface and its text uses the rail item colours. */
.pf-header--phone {
    flex: none;
    background: var(--surface-nav);
    padding: 14px 16px 18px;
    display: flex;
    align-items: center;
    gap: 13px;
}

.pf-back {
    width: var(--size-hit-target-min);
    height: var(--size-hit-target-min);
    margin-left: -10px;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font: 500 22px var(--font-mono);
    color: var(--nav-item);
}

.pf-back:hover {
    color: var(--nav-item-hover);
}

.pf-header--phone .pf-header__avatar {
    width: 52px;
    height: 52px;
    flex: none;
    border-radius: 50%;
    background: var(--avatar);
    display: flex;
    align-items: center;
    justify-content: center;
    font: 600 15px var(--font-mono);
    color: var(--avatar-text);
}

.pf-header__text {
    min-width: 0;
}

.pf-header--phone .pf-header__title {
    font: 600 17px var(--font-display);
    color: var(--text-primary);
    letter-spacing: var(--tracking-wordmark);
    margin-bottom: 3px;
}

.pf-header--phone .pf-header__sub {
    font: 400 11px var(--font-mono);
    color: var(--text-muted);
}

/* ---- Form body ---- */

.pf-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 16px 0;
}

.pf-name-row {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
}

.pf-name-field {
    flex: 1;
    min-width: 0;
}

.pf-label {
    display: block;
    font: var(--font-field-label);
    text-transform: uppercase;
    letter-spacing: var(--tracking-field-label-wide);
    color: var(--text-muted);
    margin-bottom: 7px;
}

.pf-label--section {
    margin-bottom: 8px;
}

.pf-input {
    width: 100%;
    height: var(--size-field-mobile);
    box-sizing: border-box;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-field-mobile);
    background: var(--surface-card);
    padding: 0 14px;
    font: 400 15px var(--font-ui);
    color: var(--text-primary);
}

.pf-input::placeholder {
    color: var(--text-disabled);
}

.pf-input--email {
    margin-bottom: 7px;
}

.pf-note {
    font: 400 11.5px/1.5 var(--font-ui);
    color: var(--text-muted);
    margin: 0 0 15px;
}

.pf-note--wide {
    display: none;
}

/* ---- Sign-in tiles ---- */

.pf-tile {
    width: 100%;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 11px;
    text-align: left;
    border: 1px solid var(--border-card);
    border-radius: var(--radius-card-large);
    background: var(--surface-card);
    padding: 13px 14px;
    margin-bottom: 9px;
}

.pf-tile--button {
    margin-bottom: 15px;
}

.pf-tile__text {
    line-height: 1.3;
    min-width: 0;
}

.pf-tile__username {
    font: 600 13.5px var(--font-mono);
    color: var(--text-body);
}

.pf-tile__title {
    font: 600 14px var(--font-ui);
    color: var(--text-primary);
}

.pf-tile__sub {
    font: 400 11.5px var(--font-ui);
    color: var(--text-muted);
}

.pf-locked {
    margin-left: auto;
    flex: none;
    font: 600 9px var(--font-mono);
    letter-spacing: var(--tracking-field-label);
    color: var(--text-muted);
    border: 1px solid var(--nav-divider);
    border-radius: var(--radius-chip);
    padding: 3px 6px;
}

.pf-tile__chevron {
    margin-left: auto;
    width: 24px;
    flex: none;
    text-align: right;
    font: 500 17px var(--font-mono);
    color: var(--text-secondary);
}

/* ---- Role and assigned area chips ---- */

.pf-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}

.pf-chips--areas {
    margin-bottom: 8px;
}

.pf-chip {
    border: 1px solid var(--border-card);
    background: var(--surface-card);
    padding: 6px 11px;
    border-radius: 7px;
}

.pf-chip--role {
    font: 600 10.5px var(--font-mono);
    color: var(--text-secondary);
}

.pf-chip--area {
    font: 500 13px var(--font-ui);
    color: var(--text-body);
}

.pf-chip--empty {
    color: var(--text-disabled);
}

/* ---- Actions ---- */

.pf-actions {
    flex: none;
    border-top: 1px solid var(--border-structural);
    background: var(--surface-dock);
    padding: 12px 16px 16px;
}

.pf-actions__note {
    font: 400 11.5px/1.5 var(--font-ui);
    color: var(--text-muted);
    margin: 0 0 8px;
}

/* Validation messages use the stop-state chip colour. */
.pf-actions__note--error {
    color: var(--state-d1-pill-text);
}

.pf-actions__note--saved {
    color: var(--state-run-pill-text);
}

.pf-actions__row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pf-cancel {
    height: var(--size-button-mobile);
    flex: none;
    display: inline-flex;
    align-items: center;
    padding: 0 16px;
    font: 500 14px var(--font-ui);
    color: var(--text-secondary);
}

.pf-save {
    height: var(--size-button-mobile);
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    font: var(--font-button-mobile-large);
    color: var(--accent-on-fill);
    background: var(--accent);
    border-radius: var(--radius-card-large);
}

/* Save and Change password do nothing yet. The design has no disabled treatment, so this is one. */
.pf-save[disabled],
.pf-tile--button[disabled] {
    opacity: .55;
    cursor: not-allowed;
}

/* ---- Desktop ---- */

@media (min-width: 900px) {

    .pf-page {
        height: auto;
        padding: 20px 26px 23px;
    }

    /* The page keeps no padding while the dialog holds its panel. */
    .pf-page--hosted {
        padding: 0;
    }

    /*
        A framed section 440px wide. On wide screens it sits in the shell's profile
        dialog, where it takes the shell dialog's corners and shadow. A window too short for the
        whole form scrolls the panel, so the actions stay reachable.
    */
    .pf-panel {
        height: auto;
        width: 440px;
        max-width: 100%;
        background: var(--surface-body);
        border: 1px solid var(--border-structural);
        border-radius: var(--radius-panel);
        overflow: hidden;
    }

    .pf-dialog .pf-panel {
        border-radius: var(--radius-dialog);
        box-shadow: var(--shadow-dialog);
        max-height: calc(100vh - 48px);
        overflow-y: auto;
    }

    .pf-header--phone {
        display: none;
    }

    /* Desktop page headers align with the navigation rail header. */
    .pf-header--wide {
        flex: none;
        display: flex;
        align-items: center;
        gap: 16px;
        min-height: var(--nav-head);
        box-sizing: border-box;
        padding: 0 26px;
        border-bottom: 1px solid var(--nav-divider);
    }

    .pf-header--wide .pf-header__avatar {
        width: 38px;
        height: 38px;
        flex: none;
        border-radius: 50%;
        background: var(--avatar);
        color: var(--avatar-text);
        display: flex;
        align-items: center;
        justify-content: center;
        font: 600 13px var(--font-mono);
    }

    .pf-header--wide .pf-header__text {
        line-height: 1.25;
    }

    .pf-header--wide .pf-header__title {
        font: var(--font-page-title);
        letter-spacing: var(--tracking-title);
        color: var(--text-primary);
    }

    .pf-header--wide .pf-header__sub {
        font: 400 11px var(--font-mono);
        color: #7f858d;
    }

    .pf-close {
        margin-left: auto;
        flex: none;
        font: 400 15px var(--font-ui);
        color: var(--text-muted);
        cursor: pointer;
    }

    .pf-body {
        flex: none;
        overflow: visible;
        padding: 18px 20px 0;
    }

    .pf-name-row {
        margin-bottom: 15px;
    }

    .pf-label {
        margin-bottom: 6px;
    }

    .pf-label--section {
        margin-bottom: 7px;
    }

    .pf-input {
        height: auto;
        border-radius: var(--radius-field);
        padding: 11px 13px;
        font: 400 13.5px var(--font-ui);
    }

    .pf-input--email {
        margin-bottom: 6px;
    }

    .pf-note {
        font: 400 11px/1.5 var(--font-ui);
        margin-bottom: 16px;
    }

    .pf-note--phone {
        display: none;
    }

    .pf-note--wide {
        display: block;
    }

    .pf-tile {
        border-radius: var(--radius-card);
        padding: 12px 14px;
    }

    .pf-tile--button {
        margin-bottom: 16px;
    }

    .pf-tile__username {
        font: var(--font-data-large);
    }

    .pf-tile__title {
        font: var(--font-card-title);
    }

    .pf-tile__sub {
        font: 400 11px var(--font-ui);
    }

    .pf-tile__chevron {
        width: auto;
        font: 500 15px var(--font-mono);
    }

    .pf-chip {
        padding: 5px 10px;
        border-radius: var(--radius-control);
    }

    .pf-chip--role {
        font: var(--font-data-strong);
        letter-spacing: .03em;
    }

    .pf-chip--area {
        font: 500 12px var(--font-ui);
    }

    .pf-chips--areas {
        margin-bottom: 9px;
    }

    /* The actions belong to the panel body on wide screens, so they lose the phone's footer bar. */
    .pf-actions {
        border-top: 0;
        background: none;
        padding: 0 20px 18px;
    }

    .pf-actions__note {
        font: 400 11px/1.5 var(--font-ui);
        text-align: right;
    }

    /* The bordered secondary button of the shell dialogs. */
    .pf-cancel {
        height: auto;
        margin-left: auto;
        padding: 9px 15px;
        font: 500 12.5px var(--font-ui);
        background: var(--surface-card);
        border: 1px solid var(--border-card);
        border-radius: var(--radius-button-desktop);
        cursor: pointer;
    }

    @media (hover: hover) {
        .pf-cancel:hover {
            border-color: var(--accent-keyline-soft);
        }
    }

    .pf-save {
        height: auto;
        flex: none;
        padding: 11px 18px;
        font: var(--font-button);
        border-radius: var(--radius-button-desktop);
    }
}
