/*
 * Components of the portal's pages (sign-in, recovery, "Mi cuenta", administration). Colours come from the tokens
 * in theme.css, which also adapts Bootstrap to both themes; nothing here has its own colour values.
 */

.visually-hidden-focusable:not(:focus):not(:focus-within) {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
}

.skip-link {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 1000;
    padding: 8px 12px;
    background: var(--acc-surface);
    border: 1px solid var(--acc-border);
    border-radius: var(--acc-radius);
}

/* ---- Shell of the pages without a portal session ------------------------------------------------------ */

.account-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
}

.account-shell__column {
    width: 100%;
    max-width: 420px;
}

/* As wide as the card below it, never wider: it grows with the card and shrinks with it on phones. */
.account-logo {
    display: block;
    width: 100%;
    height: auto;
    margin: 0 auto 12px;
}

.account-footer {
    margin-top: 24px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--acc-text-muted);
}

.account-footer a {
    color: var(--acc-text-muted);
}

/* ---- Card ----------------------------------------------------------------------------------------------- */

.account-card {
    background: var(--acc-surface);
    border: 1px solid var(--acc-border);
    border-radius: var(--acc-radius-lg);
    padding: 28px 28px 24px;
}

@media (max-width: 480px) {
    .account-shell {
        justify-content: flex-start;
        padding-top: 24px;
    }

    .account-card {
        padding: 22px 18px 20px;
    }
}

.account-card__title {
    font-size: 1.35rem;
    font-weight: 600;
    line-height: 1.3;
    margin: 0 0 6px;
}

.account-card__subtitle {
    color: var(--acc-text-muted);
    font-size: 0.95rem;
    margin: 0 0 20px;
}

.account-card__section + .account-card__section {
    border-top: 1px solid var(--acc-border);
    margin-top: 20px;
    padding-top: 20px;
}

.account-links {
    margin-top: 16px;
    text-align: center;
    font-size: 0.9rem;
}

.account-links a + a {
    margin-left: 16px;
}

/* Status mark on pages that only report an outcome (link sent, password saved, link not valid...). */
.account-status {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 0 16px;
    font-size: 1.3rem;
    font-weight: 700;
}

.account-status--success {
    background: var(--acc-success-bg);
    color: var(--acc-success);
}

.account-status--warning {
    background: var(--acc-warning-bg);
    color: var(--acc-warning);
}

.account-status--info {
    background: var(--acc-info-bg);
    color: var(--acc-info);
}

/* ---- Forms --------------------------------------------------------------------------------------------- */

.form-floating > .form-control {
    height: 3.4rem;
}

.field-validation-error,
.text-danger.field-validation-error {
    display: block;
    font-size: 0.85rem;
    margin-top: 4px;
}

.form-hint {
    display: block;
    font-size: 0.85rem;
    color: var(--acc-text-muted);
    margin-top: 4px;
}

/* Password field with its show/hide button. */
.password-field {
    position: relative;
}

.password-field > .form-control {
    padding-right: 3.25rem;
}

.password-toggle {
    position: absolute;
    top: 0;
    right: 0;
    height: 3.4rem;
    width: 3rem;
    border: 0;
    background: transparent;
    color: var(--acc-text-muted);
    border-radius: 0 var(--acc-radius) var(--acc-radius) 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

.password-toggle:hover {
    color: var(--acc-text);
}

.password-toggle svg {
    width: 20px;
    height: 20px;
}

.caps-lock-hint {
    display: none;
    font-size: 0.85rem;
    color: var(--acc-warning);
    margin-top: 4px;
}

.caps-lock-hint.is-visible {
    display: block;
}

/* Live checklist of the password policy (see _PasswordRequirements). */
.password-requirements {
    margin: 0 0 16px;
    font-size: 0.875rem;
}

.password-requirements ul {
    list-style: none;
    padding: 0;
    margin: 4px 0 0;
}

.password-requirements li {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--acc-text-muted);
    line-height: 1.7;
}

.password-requirements li::before {
    content: "○";
    width: 1rem;
    text-align: center;
    font-weight: 700;
}

.password-requirements li.met {
    color: var(--acc-success);
}

.password-requirements li.met::before {
    content: "✓";
}

/* ---- Buttons ------------------------------------------------------------------------------------------- */

/* A submitted form shows its button as busy (see account.js). */
.btn[aria-busy="true"] {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn[aria-busy="true"]::after {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: 1.1rem;
    height: 1.1rem;
    border: 2px solid var(--acc-on-primary);
    border-right-color: transparent;
    border-radius: 50%;
    animation: acc-spin 0.7s linear infinite;
}

.btn-outline-secondary[aria-busy="true"]::after,
.btn-outline-danger[aria-busy="true"]::after {
    border-color: var(--acc-text);
    border-right-color: transparent;
}

@keyframes acc-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .btn[aria-busy="true"]::after {
        animation-duration: 2s;
    }
}

/* ---- Messages ------------------------------------------------------------------------------------------ */

.account-alert {
    border-radius: var(--acc-radius);
    padding: 10px 14px;
    font-size: 0.9rem;
    margin-bottom: 16px;
    border: 1px solid transparent;
}

.account-alert--danger {
    background: var(--acc-danger-bg);
    color: var(--acc-danger);
}

.account-alert--success {
    background: var(--acc-success-bg);
    color: var(--acc-success);
}

.account-alert--warning {
    background: var(--acc-warning-bg);
    color: var(--acc-warning);
}

.account-alert--info {
    background: var(--acc-info-bg);
    color: var(--acc-info);
}

/* asp-validation-summary renders a list; inside an alert it reads as plain text. */
.account-alert ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.validation-summary-valid {
    display: none;
}

/* ---- Company selection --------------------------------------------------------------------------------- */

.tenant-list {
    display: grid;
    gap: 8px;
}

.tenant-option {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    text-align: left;
    background: var(--acc-surface);
    color: var(--acc-text);
    border: 1px solid var(--acc-border);
    border-radius: var(--acc-radius);
}

.tenant-option:hover {
    background: var(--acc-surface-muted);
}

.tenant-option__initial {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    border-radius: var(--acc-radius);
    background: var(--acc-surface-muted);
    border: 1px solid var(--acc-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.tenant-option__name {
    flex: 1;
    min-width: 0;
    font-weight: 500;
    overflow-wrap: anywhere;
}

.tenant-option__chevron {
    color: var(--acc-text-muted);
}

/* Signed-in person shown on the sign-in page ("continue as"). */
.signed-in-person {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--acc-border);
    border-radius: var(--acc-radius);
    margin-bottom: 16px;
}

.person-initials {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border-radius: 50%;
    background: var(--acc-surface-muted);
    border: 1px solid var(--acc-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.divider-text {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--acc-text-muted);
    font-size: 0.85rem;
    margin: 20px 0 16px;
}

.divider-text::before,
.divider-text::after {
    content: "";
    flex: 1;
    border-top: 1px solid var(--acc-border);
}

/* ---- "Mi cuenta" and administration (signed-in portal pages) ------------------------------------------ */

.portal-header {
    background: var(--acc-surface);
    border-bottom: 1px solid var(--acc-border);
}

.portal-header .navbar {
    padding-top: 10px;
    padding-bottom: 10px;
}

.portal-header .navbar-brand img {
    height: 26px;
}

.portal-header .nav-link {
    color: var(--acc-text-muted);
    border-radius: var(--acc-radius);
    padding: 6px 12px !important;
}

.portal-header .nav-link:hover,
.portal-header .nav-link.active,
.portal-header .nav-link[aria-current="page"] {
    color: var(--acc-text);
    background: var(--acc-surface-muted);
}

.portal-header .navbar-toggler {
    border-color: var(--acc-border);
}

.portal-header .dropdown-menu {
    background: var(--acc-surface);
    border: 1px solid var(--acc-border);
    border-radius: var(--acc-radius);
}

.portal-header .dropdown-item {
    color: var(--acc-text);
}

.portal-header .dropdown-item:hover,
.portal-header .dropdown-item:focus {
    background: var(--acc-surface-muted);
    color: var(--acc-text);
}

.portal-main {
    padding-top: 28px;
    padding-bottom: 48px;
}

.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0 0 4px;
}

.page-header p {
    color: var(--acc-text-muted);
    margin: 0;
}

.panel {
    background: var(--acc-surface);
    border: 1px solid var(--acc-border);
    border-radius: var(--acc-radius-lg);
    padding: 20px 24px;
}

@media (max-width: 575.98px) {
    .panel {
        padding: 16px;
    }
}

.panel + .panel {
    margin-top: 16px;
}

.panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.panel__title {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0;
}

.panel__description {
    color: var(--acc-text-muted);
    font-size: 0.9rem;
    margin: 0 0 16px;
}

.facts {
    display: grid;
    grid-template-columns: minmax(140px, 200px) 1fr;
    gap: 10px 16px;
    margin: 0;
}

.facts dt {
    color: var(--acc-text-muted);
    font-weight: 400;
    font-size: 0.9rem;
}

.facts dd {
    margin: 0;
    overflow-wrap: anywhere;
}

@media (max-width: 575.98px) {
    .facts {
        grid-template-columns: 1fr;
        gap: 2px;
    }

    .facts dd {
        margin-bottom: 10px;
    }
}

.account-nav {
    position: sticky;
    top: 16px;
}

.account-nav .nav-link {
    color: var(--acc-text-muted);
    border-radius: var(--acc-radius);
    padding: 8px 12px;
}

.account-nav .nav-link:hover,
.account-nav .nav-link.active {
    color: var(--acc-text);
    background: var(--acc-surface-muted);
}

.badge-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 500;
}

.badge-status--active {
    background: var(--acc-success-bg);
    color: var(--acc-success);
}

.badge-status--inactive {
    background: var(--acc-surface-muted);
    color: var(--acc-text-muted);
}

/* Collapsible forms ("Cambiar correo", "Cambiar contraseña"): a native <details>, keyboard-ready without script. */
.disclosure > summary {
    list-style: none;
    display: inline-block;
}

.disclosure > summary::-webkit-details-marker {
    display: none;
}

.disclosure[open] > summary {
    margin-bottom: 4px;
}

/* ---- Theme switch (light / dark / device) -------------------------------------------------------------------- */
.theme-switch {
    display: inline-flex;
    padding: 2px;
    gap: 2px;
    border: 1px solid var(--acc-border);
    border-radius: 999px;
    background: var(--acc-surface);
}

.theme-switch__option {
    width: 30px;
    height: 26px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--acc-text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.theme-switch__option:hover {
    color: var(--acc-text);
    background: var(--acc-hover);
}

.theme-switch__option[aria-pressed="true"] {
    color: var(--acc-text);
    background: var(--acc-selected);
}

.theme-switch__option svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.account-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

/* ---- Administration ------------------------------------------------------------------------------------------ */

/* Page header: breadcrumb, title, description and the page's main action. */
.page-header--actions {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px 24px;
}

.page-header__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

@media (max-width: 575.98px) {
    .page-header__actions,
    .page-header__actions > .btn {
        width: 100%;
    }
}

/* Search and filters above a list. */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.toolbar__search {
    flex: 1 1 260px;
    min-width: 0;
}

.toolbar__filter {
    flex: 0 1 240px;
}

@media (max-width: 575.98px) {
    .toolbar__filter,
    .toolbar .btn {
        flex: 1 1 100%;
    }
}

/* Lists: a table on wide screens, one card per row on phones (each cell carries its column name in data-label). */
.data-table {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
}

.data-table th {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--acc-text-muted);
    background: var(--acc-surface-muted);
    padding: 10px 16px;
    border-bottom: 1px solid var(--acc-border);
    white-space: nowrap;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--acc-border);
    vertical-align: middle;
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.data-table tbody tr:hover {
    background: var(--acc-hover);
}

.data-table__primary {
    font-weight: 600;
    color: var(--acc-text);
    text-decoration: none;
}

.data-table__primary:hover {
    text-decoration: underline;
    color: var(--acc-text);
}

.data-table__secondary {
    display: block;
    font-size: 0.85rem;
    color: var(--acc-text-muted);
    overflow-wrap: anywhere;
}

.data-table__actions {
    text-align: right;
    white-space: nowrap;
}

.panel--flush {
    padding: 0;
    overflow: hidden;
}

@media (max-width: 767.98px) {
    .data-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }

    .data-table,
    .data-table tbody,
    .data-table tr,
    .data-table td {
        display: block;
        width: 100%;
    }

    .data-table tr {
        padding: 12px 16px;
        border-bottom: 1px solid var(--acc-border);
    }

    .data-table tbody tr:last-child {
        border-bottom: 0;
    }

    .data-table td {
        border: 0;
        padding: 3px 0;
        display: flex;
        gap: 12px;
    }

    .data-table td[data-label]::before {
        content: attr(data-label);
        flex: 0 0 38%;
        color: var(--acc-text-muted);
        font-size: 0.85rem;
    }

    .data-table td.data-table__lead {
        flex-direction: column;
        gap: 0;
        padding-bottom: 6px;
    }

    .data-table td.data-table__lead::before {
        display: none;
    }

    .data-table__actions {
        text-align: left;
        padding-top: 8px !important;
    }
}

.list-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--acc-border);
}

.empty-state {
    text-align: center;
    padding: 40px 16px;
}

.empty-state__title {
    font-weight: 600;
    margin: 0 0 4px;
}

.empty-state__message {
    color: var(--acc-text-muted);
    margin: 0 0 16px;
}

/* Status badges: the same five meanings everywhere. */
.badge-status--warning {
    background: var(--acc-warning-bg);
    color: var(--acc-warning);
}

.badge-status--danger {
    background: var(--acc-danger-bg);
    color: var(--acc-danger);
}

.badge-status--info {
    background: var(--acc-info-bg);
    color: var(--acc-info);
}

.badge-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

/* Forms of the administration: a section title with its explanation on the left, the fields on the right. */
.form-section {
    display: grid;
    grid-template-columns: minmax(200px, 280px) 1fr;
    gap: 16px 32px;
}

.form-section + .form-section {
    border-top: 1px solid var(--acc-border);
    margin-top: 24px;
    padding-top: 24px;
}

.form-section__title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 4px;
}

.form-section__description {
    color: var(--acc-text-muted);
    font-size: 0.9rem;
    margin: 0;
}

@media (max-width: 767.98px) {
    .form-section {
        grid-template-columns: 1fr;
    }
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 24px;
}

@media (max-width: 575.98px) {
    .form-actions {
        flex-direction: column-reverse;
    }

    .form-actions > .btn {
        width: 100%;
    }
}

/* A list of checkboxes (companies, roles): each option is a full-width, clickable row. */
.choice-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px;
}

.choice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid var(--acc-border);
    border-radius: var(--acc-radius);
    background: var(--acc-surface);
    cursor: pointer;
}

.choice:hover {
    background: var(--acc-hover);
}

.choice:has(.form-check-input:checked) {
    border-color: var(--acc-border-strong);
    background: var(--acc-selected);
}

.choice:has(.form-check-input:disabled) {
    cursor: not-allowed;
    background: var(--acc-disabled-bg);
}

.choice .form-check-input {
    flex: 0 0 auto;
    margin: 0.15em 0 0;
}

.choice__text {
    min-width: 0;
}

.choice__label {
    display: block;
    font-weight: 500;
    overflow-wrap: anywhere;
}

.choice__hint {
    display: block;
    font-size: 0.8rem;
    color: var(--acc-text-muted);
}

/* Actions on a record, each with what it does: support actions on a user, deactivating a company... */
.action-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 24px;
    padding: 14px 0;
}

.action-row + .action-row {
    border-top: 1px solid var(--acc-border);
}

.action-row__text {
    flex: 1 1 260px;
    min-width: 0;
}

.action-row__title {
    font-weight: 600;
    margin: 0;
}

.action-row__description {
    color: var(--acc-text-muted);
    font-size: 0.9rem;
    margin: 0;
}

.action-row .disclosure {
    flex: 0 0 auto;
}

.action-row .disclosure[open] {
    flex: 1 1 100%;
}

.panel--danger {
    border-color: color-mix(in srgb, var(--acc-danger) 45%, var(--acc-border));
}

/* The person at the top of a user's page. */
.record-heading {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.record-heading__initials {
    width: 52px;
    height: 52px;
    flex: 0 0 52px;
    border-radius: 50%;
    background: var(--acc-surface-muted);
    border: 1px solid var(--acc-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.1rem;
}

.record-heading__text {
    min-width: 0;
}

.record-heading__text h1 {
    overflow-wrap: anywhere;
}

/* The temporary password field with its "generate" and "copy" buttons. */
.input-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

/* ---- The ZOE zebra beside the sign-in card (wide screens only) ---------------------------------------------- */
.login-stage {
    position: relative;
}

.login-mascot {
    display: none;
}

@media (min-width: 992px) {
    .login-mascot {
        display: block;
        position: absolute;
        right: 100%;
        top: 60%;
        transform: translateY(-50%);
        height: 350px;
        max-width: none;
        margin-right: 32px;
        pointer-events: none;
        user-select: none;
    }
}
