/*
 * Flux · the account menu and the language switch, the same in the office header and on every factory screen.
 * Markup: resources/views/partials/fx-account.blade.php (linked once from there, so it also works on the factory
 * screens, which load neither fx-nav.css nor fx-nav.js), partials/fx-language.blade.php (also under the login card)
 * and filament/auth/profile-back.blade.php (the way back on Contul meu). Tokens only (fx-tokens.css).
 *
 *   the button      on the graphite header: the avatar, the name (office from 1280, factory from 640), a chevron
 *   the panel       light, from the button: Contul meu (the first row), Toate ecranele mele, Limbă / Language, Ieșire
 */

.fx-account {
    position: relative;
    flex: none;
    --fx-account-gap: 10px;
    --fx-account-row: var(--fx-tap);
}
.fx-account-ico { width: 1.25rem; height: 1.25rem; flex: none; }

/* ---------- The button on the dark header ---------- */
.fx-account-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--fx-s-2);
    height: var(--fx-tap);
    margin: 0;
    padding: 0 var(--fx-s-3) 0 var(--fx-s-1);
    border: 0;
    border-radius: var(--fx-r-pill);
    background: transparent;
    color: var(--fx-on-dark);
    font: inherit;
    font-size: var(--fx-fs-14);
    font-weight: var(--fx-fw-medium);
    cursor: pointer;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
    transition: background-color var(--fx-dur-2) var(--fx-ease-out), transform var(--fx-dur-1) var(--fx-ease-out);
}
.fx-account-btn:active { transform: scale(0.97); }
.fx-account-btn[aria-expanded="true"] { background-color: var(--fx-on-dark-hover); }
@media (hover: hover) and (pointer: fine) { .fx-account-btn:hover { background-color: var(--fx-on-dark-hover); } }
.fx-account-btn:focus-visible { outline: var(--fx-focus-width) solid var(--fx-focus-color-dark); outline-offset: var(--fx-focus-offset); }
.fx-account-name { max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-account-chev { width: 1rem; height: 1rem; opacity: 0.8; transition: transform var(--fx-dur-3) var(--fx-ease-move); }
.fx-account-btn[aria-expanded="true"] > .fx-account-chev { transform: rotate(180deg); }

.fx-account-avatar {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--fx-on-dark-active);
    color: var(--fx-on-dark);
    font-size: var(--fx-fs-13);
    font-weight: var(--fx-fw-bold);
    letter-spacing: 0.02em;
    line-height: 1;
    box-shadow: inset 0 0 0 1px var(--fx-on-dark-line);
}
/* On your own account page the avatar is the current place: a light ring (never the factory's colour on graphite). */
.fx-account-btn.is-on .fx-account-avatar { box-shadow: 0 0 0 2px var(--fx-on-dark-2); }

/* ---------- The panel ---------- */
.fx-account-panel {
    position: absolute;
    z-index: var(--fx-z-raised);
    top: calc(100% + var(--fx-account-gap));
    right: 0;
    width: min(19rem, calc(100vw - 2 * var(--fx-gutter)));
    padding: var(--fx-s-2);
    border-radius: var(--fx-r-float);
    color: var(--fx-ink);
    text-align: left;
    background: var(--fx-glass-strong);
    -webkit-backdrop-filter: var(--fx-glass-filter);
    backdrop-filter: var(--fx-glass-filter);
    box-shadow: var(--fx-glass-edge), var(--fx-shadow-3);
    transform-origin: calc(100% - 28px) 0;
}
/* In the office header the button sits in the middle of a taller bar: the panel opens under the bar. */
.fx-account-office .fx-account-panel { top: calc(100% + (var(--fx-hdr-h) - var(--fx-tap)) / 2 + var(--fx-account-gap)); right: calc(-1 * var(--fx-s-2)); }

/* The first row: who you are, and the way to Contul meu. */
.fx-account-head {
    display: flex;
    align-items: center;
    gap: var(--fx-s-3);
    min-height: 60px;
    padding: var(--fx-s-2);
    border-radius: calc(var(--fx-r-float) - var(--fx-s-2));
    color: var(--fx-ink);
    text-decoration: none;
    transition: background-color var(--fx-dur-2) var(--fx-ease-out);
}
.fx-account-head .fx-account-avatar { width: 44px; height: 44px; font-size: var(--fx-fs-14); background: var(--fx-graphite); box-shadow: none; }
.fx-account-who { display: grid; gap: 2px; min-width: 0; }
.fx-account-who strong { font-size: var(--fx-fs-16); font-weight: var(--fx-fw-semibold); line-height: var(--fx-lh-snug); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-account-who small { color: var(--fx-ink-2); font-size: var(--fx-fs-13); font-weight: var(--fx-fw-medium); }
.fx-account-head.is-on { background-color: var(--fx-brand-tint); }
.fx-account-head.is-on .fx-account-avatar { box-shadow: 0 0 0 2px var(--fx-surface), 0 0 0 3px var(--fx-brand-line); }

.fx-account-link {
    display: flex;
    align-items: center;
    gap: var(--fx-s-3);
    width: 100%;
    min-height: var(--fx-account-row);
    margin: 0;
    padding: 0 var(--fx-s-3);
    border: 0;
    border-radius: calc(var(--fx-r-float) - var(--fx-s-2));
    background: transparent;
    color: var(--fx-ink);
    font: inherit;
    font-size: var(--fx-fs-14);
    font-weight: var(--fx-fw-medium);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background-color var(--fx-dur-2) var(--fx-ease-out);
}
.fx-account-link .fx-account-ico { color: var(--fx-ink-2); }
.fx-account-link[aria-current="page"] { font-weight: var(--fx-fw-semibold); }
.fx-account-head:active, .fx-account-link:active { background-color: var(--fx-line-soft); }
@media (hover: hover) and (pointer: fine) {
    .fx-account-head:hover, .fx-account-link:hover { background-color: var(--fx-line-soft); }
    .fx-account-head.is-on:hover { background-color: var(--fx-brand-tint); }
}
.fx-account-head:focus-visible,
.fx-account-link:focus-visible { outline: var(--fx-focus-width) solid var(--fx-focus-color); outline-offset: calc(-1 * var(--fx-focus-width)); }

/* A hairline under the first row (drawn inside the panel's padding, so the row's tint keeps its round corners). */
.fx-account-head { position: relative; margin-bottom: var(--fx-s-2); }
.fx-account-head::after {
    content: '';
    position: absolute;
    left: var(--fx-s-2);
    right: var(--fx-s-2);
    bottom: calc(-1 * var(--fx-s-1) - 1px);
    height: 1px;
    background: var(--fx-line);
    pointer-events: none;
}

/* Limbă / Language: a two-part switch, the current language pressed. */
.fx-account-lang { display: grid; gap: var(--fx-s-2); padding: var(--fx-s-2) var(--fx-s-3) var(--fx-s-3); }
.fx-account-lang-title { display: flex; align-items: center; gap: var(--fx-s-3); color: var(--fx-ink-2); font-size: var(--fx-fs-13); font-weight: var(--fx-fw-medium); }
.fx-account-lang-title .fx-account-ico { color: var(--fx-ink-2); }

.fx-account-out { margin: 0; padding-top: var(--fx-s-1); border-top: 1px solid var(--fx-line); }

/* ---------- The language switch ---------- */
.fx-lang { margin: 0; }
.fx-lang-btn {
    margin: 0;
    border: 0;
    font: inherit;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}
.fx-lang-btn:focus-visible { outline: var(--fx-focus-width) solid var(--fx-focus-color); outline-offset: var(--fx-focus-offset); }

/* In the menu: a segmented pair. */
.fx-lang-menu,
.fx-lang-floor {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3px;
    padding: 3px;
    border-radius: var(--fx-r-pill);
    background: var(--fx-sunk);
    box-shadow: inset 0 0 0 1px var(--fx-line);
}
.fx-lang-menu .fx-lang-btn,
.fx-lang-floor .fx-lang-btn {
    min-height: 38px;
    padding: 0 var(--fx-s-3);
    border-radius: var(--fx-r-pill);
    background: transparent;
    color: var(--fx-ink-2);
    font-size: var(--fx-fs-14);
    font-weight: var(--fx-fw-medium);
    transition: background-color var(--fx-dur-2) var(--fx-ease-out), color var(--fx-dur-2) var(--fx-ease-out);
}
.fx-lang-menu .fx-lang-btn[aria-pressed="true"],
.fx-lang-floor .fx-lang-btn[aria-pressed="true"] {
    background: var(--fx-surface);
    color: var(--fx-ink);
    font-weight: var(--fx-fw-strong);
    box-shadow: var(--fx-shadow-1);
}
@media (hover: hover) and (pointer: fine) {
    .fx-lang-menu .fx-lang-btn[aria-pressed="false"]:hover { color: var(--fx-ink); }
}
@media (pointer: coarse) {
    .fx-lang-menu .fx-lang-btn { min-height: 40px; }
}

/* Under the login card: two quiet words, the current one in ink. */
.fx-lang-login {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--fx-s-1);
}
.fx-lang-login .fx-lang-btn {
    position: relative;
    min-height: var(--fx-tap);
    padding: 0 var(--fx-s-3);
    border-radius: var(--fx-r-pill);
    background: transparent;
    color: var(--fx-ink-2);
    font-size: var(--fx-fs-14);
    font-weight: var(--fx-fw-medium);
}
.fx-lang-login .fx-lang-btn[aria-pressed="true"] { color: var(--fx-ink); font-weight: var(--fx-fw-strong); }
.fx-lang-login .fx-lang-btn[aria-pressed="true"]::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 8px;
    width: 16px;
    height: 2px;
    margin-left: -8px;
    border-radius: 2px;
    background: var(--fx-ink);
}
.fx-lang-login .fx-lang-btn + .fx-lang-btn::before {
    content: '';
    position: absolute;
    left: calc(-1 * var(--fx-s-1) / 2 - 2px);
    top: 50%;
    width: 4px;
    height: 4px;
    margin-top: -2px;
    border-radius: 50%;
    background: var(--fx-line-2);
}
@media (hover: hover) and (pointer: fine) {
    .fx-lang-login .fx-lang-btn[aria-pressed="false"]:hover { color: var(--fx-ink); background: var(--fx-line-soft); }
}
/* Placed under the card (it is rendered inside it, after the login form): the card keeps room for it below. */
.fi-simple-main:has(.fx-lang-login) { position: relative; margin-bottom: calc(var(--fx-tap) + var(--fx-s-4)); }
.fi-simple-main .fx-lang-login { position: absolute; left: 0; right: 0; top: calc(100% + var(--fx-s-2)); }

/* ---------- Contul meu: a comfortable column, and the way back to a factory screen ---------- */
.fx-profile-form { max-width: 46rem; }

.fx-profile-back {
    display: inline-flex;
    align-items: center;
    gap: var(--fx-s-1);
    min-height: var(--fx-tap);
    padding: 0 var(--fx-s-4) 0 var(--fx-s-2);
    border-radius: var(--fx-r-pill);
    background: var(--fx-surface);
    color: var(--fx-ink);
    font-size: var(--fx-fs-14);
    font-weight: var(--fx-fw-semibold);
    text-decoration: none;
    box-shadow: var(--fx-shadow-1);
    touch-action: manipulation;
    transition: transform var(--fx-dur-1) var(--fx-ease-out);
}
.fx-profile-back:active { transform: scale(0.97); }
.fx-profile-back-ico { width: 1.25rem; height: 1.25rem; color: var(--fx-ink-2); }
.fx-profile-back:focus-visible { outline: var(--fx-focus-width) solid var(--fx-focus-color); outline-offset: var(--fx-focus-offset); }

/* ---------- Bands ---------- */
/* Office: the name shows on a computer; on a sideways tablet and below, the initials alone. */
@media (max-width: 1279.98px) {
    .fx-account-office .fx-account-name { display: none; }
    .fx-account-office .fx-account-btn { padding-left: var(--fx-s-1); }
}
@media (max-width: 1023.98px) {
    .fx-account-office .fx-account-btn { padding: 0 var(--fx-s-1); }
    .fx-account-office .fx-account-chev { display: none; }
    .fx-account-office .fx-account-panel { right: calc(-1 * var(--fx-s-1)); }
}

/* Factory screens: bigger targets for gloves; the name shows from 640, so a shared tablet says who is logged in. */
.fx-account-floor { --fx-account-row: var(--fx-tap); --fx-account-gap: var(--fx-s-3); }
.fx-account-floor .fx-account-btn { height: var(--fx-tap); padding: 0 var(--fx-s-4) 0 var(--fx-s-2); font-size: var(--fx-fs-16); font-weight: var(--fx-fw-semibold); }
.fx-account-floor .fx-account-avatar { width: 40px; height: 40px; font-size: var(--fx-fs-14); }
.fx-account-floor .fx-account-head .fx-account-avatar { width: 48px; height: 48px; }
.fx-account-floor .fx-account-panel { width: min(22rem, calc(100vw - 2 * var(--fx-s-4))); background: var(--fx-surface); box-shadow: var(--fx-shadow-4); }
.fx-account-floor .fx-account-head { min-height: 68px; }
.fx-account-floor .fx-account-link { font-size: var(--fx-fs-16); }
.fx-account-floor .fx-lang-btn { min-height: max(48px, var(--fx-tap)); font-size: var(--fx-fs-16); }
@media (max-width: 639.98px) {
    .fx-account-floor .fx-account-name, .fx-account-floor .fx-account-chev { display: none; }
    .fx-account-floor .fx-account-btn { padding: 0 var(--fx-s-1); }
}

/* ---------- Phones: the panel is a bottom sheet, in reach of the thumb, over a dimmed page ---------- */
.fx-account-scrim { display: none; }
@media (max-width: 639.98px) {
    /* While it is open, the header's layer rises above the dock, so the sheet covers it as "Mai mult" does. */
    .fx-shell:has(.fx-account-btn[aria-expanded="true"]),
    .fx-app-shell:has(.fx-account-btn[aria-expanded="true"]) { z-index: var(--fx-z-sheet); }

    .fx-account-scrim {
        display: block;
        position: fixed;
        inset: 0;
        background: var(--fx-scrim);
        touch-action: none;
        pointer-events: auto;
    }
    .fx-account .fx-account-panel,
    .fx-account-office .fx-account-panel {
        position: fixed;
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-height: 85dvh;
        overflow-y: auto;
        overscroll-behavior: contain;
        padding: var(--fx-s-5) calc(var(--fx-s-3) + var(--fx-safe-r)) calc(var(--fx-s-3) + var(--fx-safe-b)) calc(var(--fx-s-3) + var(--fx-safe-l));
        border-radius: var(--fx-r-sheet) var(--fx-r-sheet) 0 0;
        background: var(--fx-surface);
        box-shadow: var(--fx-shadow-4);
        pointer-events: auto;
    }
    /* The grab handle, as on the "Mai mult" sheet. */
    .fx-account-panel::before {
        content: '';
        position: absolute;
        top: var(--fx-s-2);
        left: 50%;
        width: 36px;
        height: 5px;
        margin-left: -18px;
        border-radius: var(--fx-r-pill);
        background: var(--fx-line-2);
    }
    /* Slides up from the bottom instead of dropping from the avatar. */
    .fx-account-panel.fx-t-pop-0 { opacity: 1; transform: translateY(100%); }
    .fx-account { --fx-account-row: max(52px, var(--fx-tap)); }
    .fx-account-link { font-size: var(--fx-fs-16); }
    .fx-lang-menu .fx-lang-btn { min-height: 48px; font-size: var(--fx-fs-16); }
}

/* ---------- Windows high contrast ---------- */
@media (forced-colors: active) {
    .fx-account-panel { border: 1px solid CanvasText; }
    .fx-account-head.is-on, .fx-lang-btn[aria-pressed="true"] { outline: 2px solid CanvasText; outline-offset: -2px; }
}
