/* ==========================================================================
   Shared authenticated-workspace patterns.

   Everything here is theme-safe by construction: it only reads the semantic
   tokens declared in custom.css (--theme-*), never a raw page-specific hex.
   Page stylesheets keep page-specific layout only; anything duplicated across
   Orders / Transactions / Sites / Notifications / Profile lives here.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Compact page header — one pattern for every CRUD/workspace page.
   Replaces the tall .page-hero card; the Dashboard hero is a separate
   component and intentionally keeps its own treatment.
   -------------------------------------------------------------------------- */

.page-head {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.page-head-main {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.page-head-text {
    min-width: 0;
}

.page-head-eyebrow {
    display: block;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--theme-text-secondary);
    margin-bottom: .3rem;
}

.page-head-title {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -.02em;
    color: var(--theme-text);
    line-height: 1.2;
}

.page-head-description {
    margin: .25rem 0 0;
    font-size: .875rem;
    line-height: 1.5;
    color: var(--theme-text-secondary);
}

.page-head-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
}

.page-head-actions > * {
    width: 100%;
}

@media (min-width: 768px) {
    .page-head-main {
        flex-direction: row;
        align-items: flex-end;
        justify-content: space-between;
    }

    .page-head-title {
        font-size: 1.6rem;
    }

    .page-head-actions {
        flex-shrink: 0;
        justify-content: flex-end;
    }

    .page-head-actions > * {
        width: auto;
    }
}

/* --------------------------------------------------------------------------
   Toolbar — filter chips + search on one row (desktop), stacked on mobile.
   -------------------------------------------------------------------------- */

.workspace-toolbar {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    margin-bottom: 1rem;
}

.workspace-chips {
    display: flex;
    align-items: center;
    gap: .4rem;
    overflow-x: auto;
    scrollbar-width: thin;
    padding-bottom: .15rem;
    -webkit-overflow-scrolling: touch;
}

.workspace-chip {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    flex-shrink: 0;
    min-height: 2.25rem;
    padding: .4rem .8rem;
    border-radius: var(--radius-pill);
    border: 1px solid var(--theme-border);
    background: var(--theme-container);
    color: var(--theme-text-secondary);
    font-size: .8rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 150ms ease-out, color 150ms ease-out, border-color 150ms ease-out;
}

.workspace-chip:hover {
    color: var(--theme-text);
    border-color: var(--theme-border-strong);
    background: var(--theme-row-hover);
}

.workspace-chip.is-active {
    background: var(--color-ink);
    border-color: var(--color-ink);
    color: #fff;
}

[data-theme="dark"] .workspace-chip.is-active {
    background: var(--color-accent-teal-bg);
    border-color: var(--color-accent-teal-bg);
    color: var(--color-accent-teal-text);
}

.workspace-chip-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.4rem;
    padding: 0 .35rem;
    border-radius: var(--radius-pill);
    background: var(--theme-surface-subtle);
    color: inherit;
    font-size: .7rem;
    font-weight: 700;
}

.workspace-chip.is-active .workspace-chip-count {
    background: rgba(255, 255, 255, 0.22);
}

[data-theme="dark"] .workspace-chip.is-active .workspace-chip-count {
    background: rgba(4, 52, 44, 0.22);
}

.workspace-search {
    display: flex;
    align-items: center;
    gap: .5rem;
    width: 100%;
}

.workspace-search-field {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}

.workspace-search-field > i {
    position: absolute;
    left: .7rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--theme-text-secondary);
    font-size: .85rem;
    pointer-events: none;
}

.workspace-search-input {
    width: 100%;
    min-height: 2.4rem;
    padding: .45rem .7rem .45rem 2rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--theme-border);
    background: var(--theme-input-bg);
    color: var(--theme-text);
    font-size: .85rem;
    transition: border-color 120ms ease-out, box-shadow 120ms ease-out;
}

.workspace-search-input::placeholder {
    color: var(--theme-text-secondary);
    opacity: .8;
}

.workspace-search-input:focus {
    outline: none;
    border-color: var(--theme-focus-ring);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--theme-focus-ring) 25%, transparent);
}

@media (min-width: 992px) {
    .workspace-toolbar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
    }

    .workspace-search {
        width: auto;
        flex: 0 0 auto;
    }

    .workspace-search-field {
        width: 17rem;
    }
}

/* --------------------------------------------------------------------------
   Data list — the shared modern replacement for bulky CRUD tables.
   Desktop renders a table-like grid of rows; below 768px each row becomes a
   stacked card via the .data-row-cell[data-label] labels.
   -------------------------------------------------------------------------- */

.data-list {
    background: var(--theme-container);
    border: 1px solid var(--theme-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.data-list-head,
.data-row {
    display: grid;
    gap: 1rem;
    align-items: center;
    padding: .75rem 1.1rem;
}

.data-list-head {
    background: var(--theme-header-row);
    border-bottom: 1px solid var(--theme-border);
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--theme-text-secondary);
}

.data-row {
    background: var(--theme-row);
    border-bottom: 1px solid var(--theme-border);
    transition: background-color 150ms ease-out;
}

.data-row:last-child {
    border-bottom: 0;
}

.data-row:hover,
.data-row:focus-within {
    background: var(--theme-row-hover);
}

.data-row-primary {
    font-weight: 600;
    color: var(--theme-text);
    overflow-wrap: anywhere;
}

.data-row-secondary {
    font-size: .8rem;
    color: var(--theme-text-secondary);
    overflow-wrap: anywhere;
}

.data-row-id {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    color: var(--theme-text-secondary);
}

.data-row-amount {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    color: var(--theme-text);
}

.data-row-media {
    display: flex;
    align-items: center;
    gap: .7rem;
    min-width: 0;
}

.data-row-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    flex-shrink: 0;
    border-radius: 10px;
    background: var(--theme-surface-subtle);
    border: 1px solid var(--theme-border);
    color: var(--theme-text-secondary);
    font-size: .9rem;
}

.data-row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .4rem;
    flex-wrap: wrap;
}

.data-row-cell-label {
    display: none;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--theme-text-secondary);
    margin-bottom: .2rem;
}

@media (max-width: 767.98px) {
    .data-list-head {
        display: none;
    }

    .data-row {
        grid-template-columns: minmax(0, 1fr) !important;
        gap: .6rem;
        padding: 1rem;
    }

    .data-row-cell-label {
        display: block;
    }

    .data-row-actions {
        justify-content: flex-start;
    }

    .data-row-actions > * {
        flex: 1 1 auto;
        justify-content: center;
    }
}

/* Compact action button used inside data rows — always carries a visible
   label, so a row can never render an empty outlined button. */
.data-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    min-height: 2.25rem;
    padding: .4rem .8rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--theme-border);
    background: var(--theme-container);
    color: var(--theme-text);
    font-size: .8rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 150ms ease-out, border-color 150ms ease-out, color 150ms ease-out;
}

.data-action:hover,
.data-action:focus-visible {
    background: var(--theme-row-hover);
    border-color: var(--theme-border-strong);
    color: var(--theme-text);
}

.data-action--primary {
    background: var(--brand-teal-500);
    border-color: var(--brand-teal-500);
    color: var(--brand-navy-950);
}

.data-action--primary:hover,
.data-action--primary:focus-visible {
    background: var(--brand-teal-600);
    border-color: var(--brand-teal-600);
    color: var(--brand-navy-950);
}

.data-action--danger {
    background: var(--theme-danger-soft);
    border-color: color-mix(in srgb, var(--danger-text) 35%, transparent);
    color: var(--danger-text);
}

.data-action--danger:hover,
.data-action--danger:focus-visible {
    background: color-mix(in srgb, var(--danger-text) 18%, transparent);
    border-color: color-mix(in srgb, var(--danger-text) 55%, transparent);
    color: var(--danger-text);
}

.data-row-note {
    font-size: .75rem;
    color: var(--theme-text-muted);
}

/* --------------------------------------------------------------------------
   Compact empty state — replaces the tall empty card inside list containers.
   -------------------------------------------------------------------------- */

.workspace-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    text-align: center;
    padding: 2rem 1.25rem;
    background: var(--theme-container);
    border: 1px solid var(--theme-border);
    border-radius: var(--radius-lg);
}

.workspace-empty-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 12px;
    background: var(--theme-surface-subtle);
    color: var(--theme-text-secondary);
    font-size: 1.15rem;
}

.workspace-empty-title {
    font-size: .95rem;
    font-weight: 700;
    color: var(--theme-text);
}

.workspace-empty-message {
    font-size: .85rem;
    color: var(--theme-text-secondary);
    max-width: 34rem;
}

.workspace-empty-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .5rem;
    margin-top: .35rem;
}

/* --------------------------------------------------------------------------
   Shared form validation states — one design for every authenticated and auth
   form. Soft danger border on the field, message directly beneath with an
   icon, plus a compact summary alert for multi-error / non-field errors.
   -------------------------------------------------------------------------- */

.form-stack {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.form-stack-dimmed {
    opacity: .6;
    transition: opacity 180ms ease-out;
}

.form-field .form-label {
    display: block;
    font-size: .82rem;
    font-weight: 600;
    color: var(--theme-text);
}

.form-field .form-control {
    min-height: 2.6rem;
    border-radius: var(--radius-sm);
    /* A distinct input surface so fields read as separate from the card they
       sit on, in dark mode as well as light. */
    background: var(--theme-input-bg);
    border-color: var(--theme-border-strong);
    color: var(--theme-text);
}

.form-field .form-control:focus {
    border-color: var(--theme-focus-ring);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--theme-focus-ring) 25%, transparent);
}

.form-field .form-control::placeholder {
    color: var(--theme-text-secondary);
    opacity: .85;
}

.form-field .form-text {
    font-size: .78rem;
    color: var(--theme-text-secondary);
}

.form-hint {
    margin: 0 0 .75rem;
    font-size: .82rem;
    color: var(--theme-text-secondary);
}

.form-section-head {
    margin-bottom: 1.15rem;
}

.form-section-head-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    margin-bottom: .5rem;
}

.form-section-badge {
    display: inline-flex;
    align-items: center;
    padding: .15rem .55rem;
    border-radius: var(--radius-pill);
    border: 1px solid var(--theme-border);
    background: var(--theme-surface-subtle);
    color: var(--theme-text);
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.form-section-hint {
    font-size: .78rem;
    color: var(--theme-text-secondary);
}

.form-section-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -.01em;
    color: var(--theme-text);
}

.form-section-description {
    margin: .3rem 0 0;
    font-size: .85rem;
    line-height: 1.5;
    color: var(--theme-text-secondary);
}

.form-note {
    padding: .7rem .85rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--theme-border);
    background: var(--theme-surface-subtle);
    font-size: .84rem;
    color: var(--theme-text);
}

.form-note-link {
    padding: 0;
    border: 0;
    background: none;
    color: var(--brand-teal-600);
    font-size: inherit;
    font-weight: 600;
    text-decoration: underline;
}

.form-note-success {
    font-size: .82rem;
    font-weight: 600;
    color: var(--success-text);
}

/* .is-invalid / .invalid-feedback are aliased onto the same design so forms
   still using Bootstrap's validation classes (the site setup form) look
   identical to forms using <x-ui.field>, without rewriting them. */
.field-invalid,
.form-control.field-invalid,
.form-select.field-invalid,
.form-control.is-invalid,
.form-select.is-invalid {
    border-color: color-mix(in srgb, var(--danger-text) 60%, var(--theme-border));
    background-color: color-mix(in srgb, var(--danger-text) 6%, var(--theme-input-bg));
    background-image: none;
    padding-right: .75rem;
}

.field-invalid:focus,
.form-control.field-invalid:focus,
.form-control.is-invalid:focus,
.form-select.is-invalid:focus {
    border-color: var(--danger-text);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger-text) 22%, transparent);
}

.invalid-feedback {
    display: block;
    margin-top: .4rem;
    font-size: .8rem;
    line-height: 1.45;
    color: var(--danger-text);
}

.invalid-feedback::before,
.field-error-inline::before {
    content: '\F33A';
    font-family: 'bootstrap-icons';
    margin-right: .3rem;
    font-size: .85rem;
    vertical-align: -.05em;
    color: var(--danger-text);
}

/* The site setup form renders its messages as .text-danger.small rather than
   .invalid-feedback; give those the same icon + spacing treatment. */
.field-error-inline {
    display: block;
    margin-top: .4rem;
    font-size: .8rem;
    line-height: 1.45;
    color: var(--danger-text);
}

.field-error {
    display: flex;
    align-items: flex-start;
    gap: .35rem;
    margin: .4rem 0 0;
    padding: 0;
    list-style: none;
    font-size: .8rem;
    line-height: 1.45;
    color: var(--danger-text);
}

.field-error i {
    flex-shrink: 0;
    margin-top: .12rem;
    font-size: .85rem;
}

.field-error-messages {
    margin: 0;
    padding: 0;
    list-style: none;
    min-width: 0;
}

.form-alert {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .7rem .9rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: .85rem;
    line-height: 1.5;
}

.form-alert i {
    flex-shrink: 0;
    margin-top: .1rem;
}

.form-alert-title {
    font-weight: 700;
}

.form-alert-list {
    margin: .3rem 0 0;
    padding-left: 1.1rem;
}

.form-alert--danger {
    background: var(--theme-danger-soft);
    border-color: color-mix(in srgb, var(--danger-text) 30%, transparent);
    color: var(--danger-text);
}

.form-alert--success {
    background: var(--theme-success-soft);
    border-color: color-mix(in srgb, var(--success-text) 30%, transparent);
    color: var(--success-text);
}

.form-alert--warning {
    background: var(--theme-warning-soft);
    border-color: color-mix(in srgb, var(--warning-text) 30%, transparent);
    color: var(--warning-text);
}

.form-alert--info {
    background: var(--theme-info-soft);
    border-color: color-mix(in srgb, var(--theme-info-text) 30%, transparent);
    color: var(--theme-info-text);
}

/* --------------------------------------------------------------------------
   Notification list — severity is carried by a small icon + badge and a subtle
   soft border, never a thick full-red border or a card nested in a card.
   -------------------------------------------------------------------------- */

.notification-list {
    display: flex;
    flex-direction: column;
    gap: .6rem;
}

.notification-item {
    display: flex;
    align-items: flex-start;
    gap: .85rem;
    padding: .9rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--theme-border);
    background: var(--theme-container);
    transition: background-color 150ms ease-out, border-color 150ms ease-out;
}

.notification-item.is-unread {
    background: var(--theme-surface-subtle);
}

.notification-item--critical {
    border-color: color-mix(in srgb, var(--danger-text) 28%, var(--theme-border));
    background: color-mix(in srgb, var(--danger-text) 5%, var(--theme-container));
}

.notification-item--warning {
    border-color: color-mix(in srgb, var(--warning-text) 28%, var(--theme-border));
    background: color-mix(in srgb, var(--warning-text) 5%, var(--theme-container));
}

.notification-item-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
    border-radius: 50%;
    font-size: .9rem;
    background: var(--theme-surface-subtle);
    color: var(--theme-text-secondary);
}

.notification-item--critical .notification-item-icon {
    background: var(--theme-danger-soft);
    color: var(--danger-text);
}

.notification-item--warning .notification-item-icon {
    background: var(--theme-warning-soft);
    color: var(--warning-text);
}

.notification-item-body {
    flex: 1 1 auto;
    min-width: 0;
}

.notification-item-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .45rem;
}

.notification-item-title {
    font-size: .92rem;
    font-weight: 700;
    color: var(--theme-text);
}

.notification-item-meta,
.notification-item-time {
    font-size: .78rem;
    color: var(--theme-text-secondary);
}

.notification-item-message {
    margin-top: .3rem;
    font-size: .85rem;
    color: var(--theme-text);
}

.notification-item-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-top: .5rem;
}

.notification-severity-badge {
    display: inline-flex;
    align-items: center;
    padding: .15rem .5rem;
    border-radius: var(--radius-pill);
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.notification-severity-badge--critical {
    background: var(--theme-danger-soft);
    color: var(--danger-text);
}

.notification-severity-badge--warning {
    background: var(--theme-warning-soft);
    color: var(--warning-text);
}

.notification-unread-dot {
    display: inline-block;
    width: .45rem;
    height: .45rem;
    border-radius: 50%;
    background: var(--brand-teal-500);
    flex-shrink: 0;
}

@media (max-width: 575.98px) {
    .notification-item-footer > form,
    .notification-item-footer > a {
        width: 100%;
    }

    .notification-item-footer .data-action {
        width: 100%;
    }
}
