/* Portal: shell (sidebar, navigation, viewing banner), sign-in pages and building blocks shared by all portal pages.
   Page-specific styles live in portal-requests.css, portal-settings.css and portal-admin.css. */

/* ---------- Shell ---------- */

.page-portal {
    margin: 0;
    background: var(--color-bg);
}

.portal {
    display: flex;
    min-height: 100vh;
}

.portal__sidebar {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    width: 16rem;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
}

.portal__brand {
    display: flex;
    align-items: center;
    min-height: 4.25rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-title);
    text-decoration: none;
}

.portal__logo {
    display: block;
    width: auto;
    max-width: 100%;
    height: 2.25rem;
    object-fit: contain;
}

.portal__company-name {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 600;
}

.portal__nav {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.75rem;
}

.portal__nav-link {
    display: block;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-lg);
    color: var(--color-text-light);
    font-size: 0.925rem;
    font-weight: 500;
    text-decoration: none;
}

.portal__nav-link:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

.portal__nav-link.is-active {
    background: color-mix(in srgb, var(--color-brand) 12%, transparent);
    color: var(--color-primary);
    font-weight: 600;
}

.portal__account {
    padding: 0.75rem;
    border-top: 1px solid var(--color-border);
}

.portal__who {
    margin: 0 0 0.5rem;
    padding: 0 0.75rem;
    color: var(--color-text-light);
    font-size: 0.75rem;
    overflow-wrap: anywhere;
}

.portal__logout {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 0;
    border-radius: var(--radius-lg);
    background: none;
    color: var(--color-text-light);
    font: inherit;
    font-size: 0.925rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
}

.portal__logout:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

.portal__menu-toggle {
    display: none;
}

.portal__main {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.portal__content {
    flex: 1;
    width: 100%;
    max-width: 80rem;
    padding: 2rem;
    box-sizing: border-box;
}

.viewing-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--color-primary);
    color: #ffffff;
    font-size: 0.875rem;
}

.viewing-banner[hidden] {
    display: none;
}

@media (max-width: 52rem) {
    .portal {
        flex-direction: column;
    }

    .portal__sidebar {
        width: auto;
        border-right: 0;
        border-bottom: 1px solid var(--color-border);
    }

    .portal__menu-toggle {
        display: block;
        position: absolute;
        top: 1.1rem;
        right: 1rem;
        padding: 0.4rem 0.8rem;
        border: 1px solid var(--color-border);
        border-radius: var(--radius);
        background: var(--color-surface);
        color: var(--color-text);
        font: inherit;
        font-size: 0.875rem;
        cursor: pointer;
    }

    .portal__sidebar {
        position: relative;
    }

    .portal__sidebar:not(.is-open) .portal__nav,
    .portal__sidebar:not(.is-open) .portal__account {
        display: none;
    }

    .portal__content {
        padding: 1.25rem 1rem;
    }
}

/* ---------- Page building blocks ---------- */

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-head__title {
    margin: 0;
    color: var(--color-primary);
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 500;
}

.page-head__intro {
    margin: 0.25rem 0 0;
    color: var(--color-text-light);
    font-size: 0.925rem;
}

.page-head__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.section {
    margin-bottom: 1.5rem;
}

.section__title {
    margin: 0 0 1rem;
    color: var(--color-primary);
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 500;
}

.section__intro {
    margin: -0.5rem 0 1rem;
    color: var(--color-text-light);
    font-size: 0.875rem;
}

.empty {
    padding: 2rem 1rem;
    color: var(--color-text-light);
    text-align: center;
}

/* Data tables scroll sideways on small screens instead of squeezing. */
.table-wrap {
    overflow-x: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table th,
.table td {
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
    vertical-align: middle;
}

.table th {
    background: var(--color-bg);
    color: var(--color-text-light);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    white-space: nowrap;
}

.table tbody tr:last-child td {
    border-bottom: 0;
}

.table tbody tr.is-clickable {
    cursor: pointer;
}

.table tbody tr.is-clickable:hover {
    background: color-mix(in srgb, var(--color-brand) 5%, transparent);
}

.table__actions {
    text-align: right;
    white-space: nowrap;
}

.table__number {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.table tfoot td {
    background: var(--color-bg);
    font-weight: 600;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
}

.tab {
    margin-bottom: -1px;
    padding: 0.6rem 1rem;
    border: 0;
    border-bottom: 2px solid transparent;
    background: none;
    color: var(--color-text-light);
    font: inherit;
    font-size: 0.925rem;
    font-weight: 500;
    cursor: pointer;
}

.tab:hover {
    color: var(--color-text);
}

.tab.is-active,
.tab[aria-selected="true"] {
    border-bottom-color: var(--color-brand);
    color: var(--color-primary);
    font-weight: 600;
}

.tab__count {
    display: inline-block;
    min-width: 1.4rem;
    margin-left: 0.35rem;
    padding: 0 0.4rem;
    border-radius: 999px;
    background: var(--color-bg);
    color: var(--color-text-light);
    font-size: 0.75rem;
    line-height: 1.4rem;
    text-align: center;
}

.badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    background: var(--color-bg);
    color: var(--color-text-light);
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge--brand {
    background: color-mix(in srgb, var(--color-brand) 15%, transparent);
    color: var(--color-primary);
}

.badge--success {
    background: #dcfce7;
    color: #166534;
}

.badge--warning {
    background: #fef3c7;
    color: #92400e;
}

.badge--danger {
    background: var(--color-danger-soft);
    color: var(--color-danger);
}

/* Forms in portal pages and dialogs; .field, .field__label, .field__error and .input come from coas.css. */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    gap: 1rem 1.25rem;
}

.form-grid--single {
    grid-template-columns: 1fr;
}

.form-grid__wide {
    grid-column: 1 / -1;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

.form-message {
    margin: 0.75rem 0 0;
    font-size: 0.875rem;
}

.form-message--error {
    color: var(--color-danger);
}

.form-message--success {
    color: var(--color-success);
}

.details {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.4rem 1.25rem;
    margin: 0;
    font-size: 0.9rem;
}

.details dt {
    color: var(--color-text-light);
}

.details dd {
    margin: 0;
    overflow-wrap: anywhere;
}

/* ---------- Portal dialog (Views/PortalPages/Page.cshtml) ---------- */

.portal-dialog {
    width: min(32rem, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    padding: 0;
    border: 0;
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: 0 20px 50px rgb(0 0 0 / 0.25);
}

.portal-dialog--wide {
    width: min(64rem, calc(100vw - 2rem));
}

.portal-dialog::backdrop {
    background: rgb(0 0 0 / 0.4);
}

.portal-dialog__inner {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 2rem);
}

.portal-dialog__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
}

.portal-dialog__title {
    margin: 0;
    color: var(--color-primary);
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 500;
}

.portal-dialog__close {
    padding: 0 0.35rem;
    border: 0;
    background: none;
    color: var(--color-text-light);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}

.portal-dialog__body {
    padding: 1.25rem;
    overflow-y: auto;
}

.portal-dialog__body > p:first-child {
    margin-top: 0;
}

.portal-dialog__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

/* ---------- Sign-in pages ---------- */

.page-auth {
    margin: 0;
    background: var(--color-bg);
}

.auth {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
    box-sizing: border-box;
}

.auth__card {
    width: 100%;
    max-width: 26rem;
    box-sizing: border-box;
}

.auth__logo {
    display: block;
    height: 2.25rem;
    width: auto;
    margin: 0 auto 1.5rem;
}

.auth__title {
    margin: 0 0 0.35rem;
    color: var(--color-primary);
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 500;
    text-align: center;
}

.auth__intro {
    margin: 0 0 1.25rem;
    color: var(--color-text-light);
    font-size: 0.9rem;
    text-align: center;
}

.auth__form {
    display: grid;
    gap: 1rem;
}

.auth__links {
    margin-top: 1rem;
    font-size: 0.875rem;
    text-align: center;
}

.link-button {
    padding: 0;
    border: 0;
    background: none;
    color: var(--color-brand);
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}
