/* Clients page - B60 OS (page-scoped) */

.clients-page {
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-4);
    width: 100%;
}

.clients-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--ds-space-3);
}

.clients-search {
    display: flex;
    align-items: center;
    gap: var(--ds-space-2);
    flex: 1 1 220px;
    min-width: 180px;
    max-width: min(100%, 380px);
    padding: 0 var(--ds-space-3);
    background: var(--ds-surface);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-md);
    min-height: 40px;
    height: 40px;
    box-sizing: border-box;
}

.clients-search svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    color: var(--ds-text-tertiary);
}

.clients-search .ds-input {
    border: none;
    background: transparent;
    padding: 0;
    min-height: 36px;
    box-shadow: none;
}

.clients-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ds-space-3);
    margin-block-end: 0;
}

.clients-table-wrap {
    overflow-x: auto;
    border: none;
    border-radius: 0;
}

.clients-desktop-table {
    display: table;
    width: 100%;
}

.clients-mobile-list {
    display: none;
}

.clients-row-name {
    display: flex;
    align-items: center;
    gap: var(--ds-space-3);
}

.clients-row-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.clients-row-initials {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--ds-primary-tint);
    color: var(--ds-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--ds-fw-semibold);
    font-size: var(--ds-text-sm);
    flex-shrink: 0;
}

.clients-row-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--ds-space-1);
}

.clients-cell-empty {
    color: var(--ds-text-tertiary);
}

.clients-overflow-wrap {
    position: relative;
}

.clients-overflow-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--ds-radius-md);
    border: 1px solid var(--ds-border);
    background: var(--ds-surface);
    cursor: pointer;
    font-size: var(--ds-text-lg);
    line-height: 1;
    color: var(--ds-text-secondary);
    font-family: inherit;
}

:where(.can-hover) .clients-overflow-btn:hover {
    background: var(--ds-surface-alt);
    color: var(--ds-text-primary);
}

.clients-overflow-menu {
    position: absolute;
    top: calc(100% + 4px);
    inset-inline-end: 0;
    min-width: 140px;
    background: var(--ds-surface);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-md);
    box-shadow: var(--ds-shadow-modal);
    padding: var(--ds-space-1);
    z-index: 20;
}

.clients-overflow-menu button {
    display: block;
    width: 100%;
    text-align: start;
    border: none;
    background: transparent;
    padding: var(--ds-space-2) var(--ds-space-3);
    border-radius: var(--ds-radius-sm);
    font-size: var(--ds-text-sm);
    cursor: pointer;
    font-family: inherit;
    color: var(--ds-text-primary);
}

:where(.can-hover) .clients-overflow-menu button:hover {
    background: var(--ds-surface-alt);
}

.clients-desktop-table tbody tr {
    height: 56px;
}

/* Side drawer for add/edit */
.clients-drawer-overlay {
    position: fixed;
    inset: 0;
    background: var(--ds-bg-overlay);
    z-index: var(--ds-z-modal);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--ds-motion-drawer) var(--ds-ease-standard),
                visibility var(--ds-motion-drawer) var(--ds-ease-standard);
}

.clients-drawer-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

.clients-drawer {
    position: fixed;
    inset-block: 0;
    inset-inline-end: 0;
    width: min(420px, 100vw);
    background: var(--ds-surface);
    border-inline-start: 1px solid var(--ds-border);
    box-shadow: var(--ds-shadow-modal);
    z-index: calc(var(--ds-z-modal) + 1);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform var(--ds-motion-drawer) var(--ds-ease-standard);
}

[dir="rtl"] .clients-drawer {
    transform: translateX(-100%);
}

.clients-drawer-overlay.is-open .clients-drawer {
    transform: translateX(0);
}

.clients-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--ds-space-5);
    border-block-end: 1px solid var(--ds-border);
}

.clients-drawer-title {
    margin: 0;
    font-size: var(--ds-text-lg);
    font-weight: var(--ds-fw-semibold);
}

.clients-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--ds-space-5);
}

.clients-drawer-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--ds-space-3);
    padding: var(--ds-space-4) var(--ds-space-5);
    border-block-start: 1px solid var(--ds-border);
}

.client-photo-upload {
    display: flex;
    gap: var(--ds-space-4);
    align-items: flex-start;
    margin-block-end: var(--ds-space-4);
}

.client-photo-preview {
    width: 72px;
    height: 72px;
    border-radius: var(--ds-radius-lg);
    background: var(--ds-bg-inset);
    border: 1px dashed var(--ds-border-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
    flex-shrink: 0;
}

.client-photo-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.client-photo-hint,
.client-field-hint {
    font-size: var(--ds-text-xs);
    color: var(--ds-text-tertiary);
    margin-block-start: var(--ds-space-1);
}

.clients-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--ds-space-3);
}

/* Profile detail view */
.clients-profile {
    max-width: 900px;
    margin-inline: auto;
}

.clients-profile-header {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ds-space-5);
    align-items: flex-start;
}

.clients-profile-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: var(--ds-space-3);
}

.clients-stat-mini {
    text-align: center;
    padding: var(--ds-space-4);
}

.clients-stat-mini-value {
    font-size: var(--ds-text-xl);
    font-weight: var(--ds-fw-bold);
    color: var(--ds-text-primary);
    font-variant-numeric: tabular-nums;
}

.clients-stat-mini-label {
    font-size: var(--ds-text-xs);
    color: var(--ds-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-block-start: var(--ds-space-1);
}

.clients-fin-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--ds-space-4);
    text-align: center;
}

.clients-fin-cell {
    padding: var(--ds-space-4);
    background: var(--ds-bg-inset);
    border-radius: var(--ds-radius-md);
}

.clients-fin-cell.is-debt {
    background: var(--ds-danger-tint);
}

.clients-fin-cell.is-credit {
    background: var(--ds-success-tint);
}

.clients-fin-value {
    font-size: var(--ds-text-xl);
    font-weight: var(--ds-fw-bold);
    font-variant-numeric: tabular-nums;
}

.clients-fin-label {
    font-size: var(--ds-text-xs);
    color: var(--ds-text-secondary);
    text-transform: uppercase;
    margin-block-start: var(--ds-space-1);
}

.clients-mobile-card {
    padding: var(--ds-space-4);
    border-block-end: 1px solid var(--ds-border);
}

.clients-mobile-card:last-child {
    border-block-end: none;
}

@media (max-width: 768px) {
    .clients-desktop-table {
        display: none !important;
    }

    .clients-mobile-list {
        display: block;
        border: 1px solid var(--ds-border);
        border-radius: var(--ds-radius-lg);
        overflow: hidden;
    }

    .clients-form-row {
        grid-template-columns: 1fr;
    }

    .clients-fin-grid {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    .clients-drawer,
    .clients-drawer-overlay {
        transition: none;
    }
}

/* Wave 4 T-N: repeated inline styles lifted from clients.js */
.clients-muted { color: var(--text-secondary); }
.clients-meta { font-size: 11px; color: var(--text-secondary); }
.clients-meta-sm { font-size: 12px; color: var(--text-secondary); }
.clients-meta-caps {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
}
.clients-meta-caps-mt {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-top: 4px;
}
.clients-meta-danger { font-size: 11px; color: var(--danger); }
.clients-icon-md {
    vertical-align: middle;
    margin-inline-end: 8px;
}
.clients-icon-sm {
    vertical-align: middle;
    margin-inline-end: 4px;
}
.clients-fw-medium { font-weight: 500; }
.clients-fw-semibold { font-weight: 600; }
.clients-pad-16 { padding: 16px; }
.clients-mb-16 { margin-bottom: 16px; }
.clients-w-full { width: 100%; }
.clients-center-pad {
    text-align: center;
    padding: 16px;
}
.clients-kv-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.clients-print-caption {
    text-align: center;
    font-size: 11px;
    font-family: Arial, sans-serif;
    padding: 4px 0;
}
.clients-panel-inset {
    background: var(--bg-tertiary);
    padding: 16px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
}
.clients-flex-between {
    display: flex;
    justify-content: space-between;
}
.clients-value-success {
    font-size: 20px;
    font-weight: 700;
    color: var(--success);
}
.clients-value-info {
    font-size: 20px;
    font-weight: 700;
    color: var(--info);
}
.clients-row-between-mb {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 13px;
}
.clients-row-muted {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 13px;
    color: var(--text-secondary);
}
.clients-row-success {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 13px;
    color: var(--success);
}
.clients-row-danger {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--danger);
}
.clients-field-grow {
    flex: 1;
    min-width: 120px;
}
.clients-field-label {
    font-size: 12px;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 4px;
}

/* --- Client profile panel (Clients.viewClientOrders) ----------------------
 *
 * On top of the page, full height at the end edge, over a dimmed page
 * (.panel-scrim, components.css) that closes it on a tap (owner,
 * 2026-10-15) -- the same layer as the product editor. The filled arrows
 * step to the next client.
 */
.cprof {
    --cprof-width: 520px;
    position: fixed;
    top: 0;
    bottom: 0;
    inset-inline-end: 0;
    z-index: 195;
    width: min(var(--cprof-width), 100%);
    display: flex;
    flex-direction: column;
    background: var(--ds-surface);
    border-radius: var(--radius-xl) 0 0 var(--radius-xl);
    box-shadow: var(--ds-shadow-modal);
    animation: cprof-in 180ms var(--ds-ease-standard, ease-out);
}

body[dir="rtl"] .cprof {
    border-radius: 0 var(--radius-xl) var(--radius-xl) 0;
    animation-name: cprof-in-rtl;
}

@keyframes cprof-in {
    from { opacity: 0; transform: translateX(24px); }
    to { opacity: 1; transform: none; }
}

@keyframes cprof-in-rtl {
    from { opacity: 0; transform: translateX(-24px); }
    to { opacity: 1; transform: none; }
}

.clients-table-row {
    cursor: pointer;
}

.clients-table-row.is-active > td {
    background: var(--ds-primary-tint);
}

.clients-mobile-card.is-active {
    border-color: var(--ds-primary);
}

.cprof-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ds-space-3);
    padding: var(--ds-space-2) var(--ds-space-4);
    border-bottom: 1px solid var(--ds-border);
}

.cprof-nav,
.cprof-head-actions {
    display: flex;
    align-items: center;
    gap: var(--ds-space-1);
}

.cprof-icon-btn {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: var(--ds-radius-md);
    background: transparent;
    color: var(--ds-text-secondary);
    cursor: pointer;
}

:where(.can-hover) .cprof-icon-btn:hover:not(:disabled) {
    background: var(--ds-bg-inset);
    color: var(--ds-text-primary);
}

.cprof-icon-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

/*
 * Previous / "3 / 12" / next as one filled button in the cafe colour, with
 * the primary button's sheen: with the panel over the list, these are how
 * you move to the next client. Hover and press darken whatever the colour is.
 */
.cprof .cprof-nav {
    gap: 0;
    overflow: hidden;
    border-radius: var(--ds-radius-md);
    background-color: var(--ds-primary);
    background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0) 55%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.18),
        0 1px 2px rgba(30, 27, 57, 0.10),
        0 6px 16px color-mix(in srgb, var(--ds-primary) 28%, transparent);
    color: var(--ds-text-on-accent);
}

.cprof-nav .cprof-icon-btn {
    width: 48px;
    height: 44px;
    border-radius: 0;
    color: inherit;
}

:where(.can-hover) .cprof-nav .cprof-icon-btn:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.12);
    color: inherit;
}

.cprof-nav .cprof-icon-btn:active:not(:disabled) {
    background: rgba(0, 0, 0, 0.2);
}

.cprof-nav .cprof-icon-btn:focus-visible {
    outline: 2px solid var(--ds-text-on-accent);
    outline-offset: -4px;
}

.cprof-nav .cprof-icon-btn:disabled {
    opacity: 0.4;
}

/* The arrows point the way the list runs. */
body[dir="rtl"] .cprof-nav svg {
    transform: scaleX(-1);
}

.cprof-pos {
    align-self: stretch;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 64px;
    padding-inline: var(--ds-space-2);
    border-inline: 1px solid rgba(255, 255, 255, 0.22);
    font-size: var(--ds-text-sm);
    font-weight: var(--ds-fw-semibold);
    font-variant-numeric: tabular-nums;
    color: inherit;
}

.cprof-more {
    position: relative;
}

.cprof-menu {
    position: absolute;
    top: calc(100% + 4px);
    inset-inline-end: 0;
    z-index: 2;
    min-width: 210px;
    padding: 8px;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-md);
    background: var(--ds-surface);
    box-shadow: var(--ds-shadow-modal);
}

.cprof-menu[hidden] {
    display: none;
}

.cprof-menu button {
    width: 100%;
    min-height: 40px;
    padding: 0 var(--ds-space-3);
    border: 0;
    border-radius: var(--ds-radius-sm);
    background: transparent;
    color: var(--ds-text-primary);
    font: inherit;
    font-size: var(--ds-text-sm);
    text-align: start;
    cursor: pointer;
}

:where(.can-hover) .cprof-menu button:hover {
    background: var(--ds-bg-inset);
}

.cprof-menu button.is-danger {
    color: var(--ds-danger-text);
}

.cprof-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: var(--ds-space-5);
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-5);
}

.cprof-id {
    display: flex;
    align-items: center;
    gap: var(--ds-space-4);
}

.cprof-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.cprof-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.cprof-avatar-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ds-primary-tint);
    color: var(--ds-primary);
    font-size: 26px;
    font-weight: 700;
}

.cprof-photo-btn {
    position: absolute;
    inset-inline-end: -2px;
    bottom: -2px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--ds-surface);
    border-radius: 50%;
    background: var(--ds-primary);
    color: var(--ds-text-on-accent, #fff);
    cursor: pointer;
}

.cprof-id-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cprof-name {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--ds-text-primary);
    overflow-wrap: anywhere;
}

.cprof-contact {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ds-space-1) var(--ds-space-3);
    font-size: var(--ds-text-sm);
    color: var(--ds-text-secondary);
}

.cprof-address {
    margin: 0;
    font-size: var(--ds-text-xs);
    color: var(--ds-text-secondary);
}

.cprof-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cprof-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border: 1px solid var(--ds-border);
    border-radius: 999px;
    background: var(--ds-bg-inset);
    font-size: 12.5px;
    color: var(--ds-text-secondary);
    white-space: nowrap;
}

.cprof-chip.is-ok { background: var(--ds-success-tint); border-color: transparent; color: var(--ds-success-text); }
.cprof-chip.is-danger { background: var(--ds-danger-tint); border-color: transparent; color: var(--ds-danger-text); }
.cprof-chip.is-warn { background: var(--ds-warning-tint); border-color: transparent; color: #B45309; }
.cprof-chip.is-info { background: var(--ds-info-tint); border-color: transparent; color: #1D4ED8; }

.cprof-cap {
    text-transform: capitalize;
}

.cprof-muted {
    font-size: var(--ds-text-xs);
    color: var(--ds-text-tertiary);
}

/* The balance leads: it is what a client is looked up for at the counter. */
.cprof-balance {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--ds-space-4) var(--ds-space-5);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    background: var(--ds-bg-inset);
}

.cprof-balance.is-debt {
    background: var(--ds-danger-tint);
    border-color: rgba(239, 68, 68, 0.25);
}

.cprof-balance.is-credit {
    background: var(--ds-success-tint);
    border-color: rgba(16, 185, 129, 0.25);
}

.cprof-balance-label {
    font-size: var(--ds-text-sm);
    font-weight: var(--ds-fw-semibold);
    color: var(--ds-text-secondary);
}

.cprof-balance-amount {
    font-size: 30px;
    font-weight: 800;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    color: var(--ds-text-primary);
}

.cprof-balance.is-debt .cprof-balance-amount { color: var(--ds-danger-text); }
.cprof-balance.is-credit .cprof-balance-amount { color: var(--ds-success-text); }

.cprof-balance-sum,
.cprof-note {
    margin: 0;
    font-size: var(--ds-text-xs);
    color: var(--ds-text-secondary);
}

.cprof-note {
    margin-block-start: var(--ds-space-2);
}

.cprof-balance-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ds-space-2);
    margin-block-start: var(--ds-space-3);
}

.cprof-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--ds-space-2);
}

.cprof-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--ds-space-3);
    border-radius: var(--ds-radius-md);
    background: var(--ds-bg-inset);
    min-width: 0;
}

.cprof-stat-value {
    font-size: 15px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--ds-text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cprof-stat-label {
    font-size: 12px;
    color: var(--ds-text-secondary);
}

.cprof-section {
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-3);
}

.cprof-section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--ds-space-3);
}

.cprof-section-head h3 {
    margin: 0;
    font-size: var(--ds-text-sm);
    font-weight: var(--ds-fw-semibold);
    color: var(--ds-text-primary);
}

.cprof-orders {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cprof-order {
    width: 100%;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ds-space-3);
    padding: var(--ds-space-2) var(--ds-space-3);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-md);
    background: var(--ds-surface);
    color: inherit;
    font: inherit;
    text-align: start;
    cursor: pointer;
}

:where(.can-hover) .cprof-order:hover {
    background: var(--ds-bg-inset);
}

.cprof-order.is-unpaid {
    border-inline-start: 3px solid var(--ds-danger);
}

.cprof-order-main,
.cprof-order-side {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.cprof-order-side {
    align-items: flex-end;
    flex-shrink: 0;
}

.cprof-order-date {
    font-size: var(--ds-text-sm);
    font-weight: 500;
    color: var(--ds-text-primary);
}

.cprof-order-total {
    font-size: var(--ds-text-sm);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--ds-text-primary);
}

.cprof-notes {
    margin: 0;
    padding: var(--ds-space-3);
    border-radius: var(--ds-radius-md);
    background: var(--ds-bg-inset);
    font-size: var(--ds-text-sm);
    line-height: 1.55;
    white-space: pre-wrap;
}

.cprof-dl {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: var(--ds-space-2) var(--ds-space-4);
    margin: 0;
    font-size: var(--ds-text-sm);
}

.cprof-dl dt {
    color: var(--ds-text-secondary);
}

.cprof-dl dd {
    margin: 0;
    text-align: end;
    color: var(--ds-text-primary);
}

.cprof-empty {
    margin: 0;
    padding: var(--ds-space-5);
    text-align: center;
    color: var(--ds-text-secondary);
    font-size: var(--ds-text-sm);
}
