/* Shared styles for the customer pages (users, subscribers, reviews). Builds on product_list.css (load that first). */

/* Keeps cards scrolled to after paging clear of the fixed top bar. */
.sp .sp-card {
    scroll-margin-top: calc(var(--sb-top, 72px) + 16px);
}

/* ---------- List table ---------- */
.cu-table {
    width: 100%;
    margin: 0;
    border-collapse: separate;
    border-spacing: 0;
}

.cu-table thead th {
    padding: 10px 16px;
    border-bottom: 1px solid var(--sp-border);
    background: #fafbfc;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--sp-muted);
}

.cu-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--sp-border);
    font-size: .875rem;
    vertical-align: middle;
}

.cu-table tbody tr:last-child td {
    border-bottom: 0;
}

.cu-table tbody tr:not(.sp-state):not(.cu-skel-row):hover {
    background: #fafbff;
}

.cu-table .c-idx {
    width: 56px;
    color: var(--sp-muted);
    font-variant-numeric: tabular-nums;
}

.cu-table .c-actions {
    width: 1%;
    white-space: nowrap;
}

.cu-skel-row td {
    padding: 16px;
}

.cu-skel-row .cu-skel-person {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cu-skel-row .cu-skel-person > div {
    flex: 1;
}

.cu-skel-row .sp-skel.is-round {
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

/* Dims a list while it reloads (search, paging) without covering the page. */
.cu-is-loading {
    opacity: .55;
    pointer-events: none;
    transition: opacity .15s;
}

/* ---------- Person cell ---------- */
.cu-person {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.cu-avatar {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--cu-av-bg, var(--sp-primary-soft));
    color: var(--cu-av-fg, var(--sp-primary));
    font-size: .8125rem;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
    user-select: none;
}

.cu-avatar i {
    font-size: 1.15rem;
}

.cu-av-0 { --cu-av-bg: #eef1fb; --cu-av-fg: #1f3bb3; }
.cu-av-1 { --cu-av-bg: #ecfdf3; --cu-av-fg: #067647; }
.cu-av-2 { --cu-av-bg: #fff1ec; --cu-av-fg: #c4320a; }
.cu-av-3 { --cu-av-bg: #f4f3ff; --cu-av-fg: #5925dc; }
.cu-av-4 { --cu-av-bg: #fdf2fa; --cu-av-fg: #c11574; }
.cu-av-5 { --cu-av-bg: #ecfdff; --cu-av-fg: #0e7090; }

.cu-person-info {
    min-width: 0;
}

.cu-name {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    font-weight: 600;
    line-height: 1.35;
    word-break: break-word;
}

.cu-sub {
    margin-top: 2px;
    overflow: hidden;
    font-size: .8125rem;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--sp-muted);
}

.sp-badge.is-registered {
    background: var(--sp-success-soft);
    color: var(--sp-success);
}

.sp-badge.is-guest {
    background: #f1f3f7;
    color: #4b5563;
}

/* ---------- Contact links ---------- */
.cu-contact {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.cu-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    color: var(--sp-text);
    text-decoration: none;
}

.cu-link i {
    flex: none;
    font-size: 1rem;
    color: var(--sp-muted);
}

.cu-link span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

a.cu-link:hover {
    color: var(--sp-primary);
}

a.cu-link:hover i {
    color: var(--sp-primary);
}

.cu-none {
    color: #9ca3af;
}

.cu-email-row {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.cu-copy {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--sp-muted);
    font-size: .95rem;
}

.cu-copy:hover {
    background: #f1f3f7;
    color: var(--sp-text);
}

.cu-copy.is-done {
    color: var(--sp-success);
}

.cu-date {
    font-weight: 600;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.cu-date small {
    display: block;
    margin-top: 2px;
    font-size: .75rem;
    font-weight: 500;
    color: var(--sp-muted);
}

/* ---------- Block-level empty / error state (for non-table lists) ---------- */
.cu-state {
    padding: 56px 16px;
    text-align: center;
}

.cu-state h3 {
    margin: 0 0 4px;
    font-size: 1rem;
    font-weight: 700;
}

.cu-state p {
    max-width: 420px;
    margin: 0 auto;
    font-size: .875rem;
    color: var(--sp-muted);
}

/* ---------- Reviews ---------- */
.rv-summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .8125rem;
    color: var(--sp-muted);
}

.rv-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr));
    gap: 12px;
    padding: 16px;
}

.rv-list > .cu-state {
    grid-column: 1 / -1;
}

.rv-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
    padding: 16px;
    border: 1px solid var(--sp-border);
    border-radius: 12px;
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
}

.rv-card:hover {
    border-color: #d5dae6;
    box-shadow: 0 6px 16px -10px rgba(16, 24, 40, .25);
}

.rv-card.is-removing {
    opacity: .4;
    pointer-events: none;
}

.rv-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 0;
}

.rv-head .cu-person-info {
    flex: 1;
}

.rv-product {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 4px;
    max-width: 45%;
    padding: 3px 10px;
    border: 1px solid var(--sp-border);
    border-radius: 999px;
    background: #fafbfc;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .72rem;
    font-weight: 600;
    color: var(--sp-text);
    text-decoration: none;
}

.rv-product span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rv-product i {
    font-size: .9rem;
    color: var(--sp-muted);
}

a.rv-product:hover {
    border-color: var(--sp-primary);
    color: var(--sp-primary);
}

.rv-rating {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    font-size: .8125rem;
    color: var(--sp-muted);
}

.rv-stars {
    display: inline-flex;
    gap: 1px;
    font-size: 1.05rem;
    line-height: 1;
    color: #d0d5dd;
}

.rv-stars .is-on {
    color: #f5a623;
}

.rv-score {
    font-weight: 700;
    color: var(--sp-text);
    font-variant-numeric: tabular-nums;
}

.rv-text {
    margin: 0;
    font-size: .875rem;
    line-height: 1.6;
    color: #374151;
    white-space: pre-line;
    word-break: break-word;
}

.rv-text.is-clamped {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.rv-text.is-empty {
    font-style: italic;
    color: #9ca3af;
}

.rv-more {
    align-self: flex-start;
    margin-top: -6px;
}

.rv-photos {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.rv-photo {
    position: relative;
    width: 76px;
    height: 76px;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--sp-border);
    border-radius: 10px;
    background: #f1f3f7;
    color: #a3a9b6;
    cursor: zoom-in;
}

.rv-photo > i {
    font-size: 1.3rem;
}

.rv-photo img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .2s;
}

.rv-photo:hover img {
    transform: scale(1.05);
}

.rv-photo:focus-visible {
    outline: 2px solid var(--sp-primary);
    outline-offset: 2px;
}

.rv-foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--sp-border);
}

.rv-skel {
    pointer-events: none;
}

/* Photo viewer */
.rv-viewer .modal-content {
    background: #0b0f19;
    border: 0;
    border-radius: 16px;
    overflow: hidden;
}

@media (min-width: 576px) {
    .rv-viewer .modal-dialog {
        max-width: min(880px, calc(100vw - 48px));
    }
}

.rv-viewer-stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 260px;
    max-height: calc(100vh - 140px);
    background: #0b0f19;
}

.rv-viewer-stage img {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 140px);
    object-fit: contain;
}

.rv-viewer-btn {
    position: absolute;
    top: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .14);
    color: #fff;
    font-size: 1.4rem;
    transform: translateY(-50%);
    backdrop-filter: blur(4px);
}

.rv-viewer-btn:hover {
    background: rgba(255, 255, 255, .26);
}

.rv-viewer-btn.is-prev {
    left: 12px;
}

.rv-viewer-btn.is-next {
    right: 12px;
}

.rv-viewer-close {
    top: 12px;
    right: 12px;
    transform: none;
    width: 36px;
    height: 36px;
    font-size: 1.2rem;
}

.rv-viewer-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 16px;
    font-size: .8125rem;
    color: #d0d5dd;
}

.rv-viewer-bar a {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #fff;
    font-weight: 600;
    text-decoration: none;
}

.rv-viewer-bar a:hover {
    text-decoration: underline;
}

/* ---------- Responsive ---------- */
@media (max-width: 767.98px) {
    .cu-table thead {
        display: none;
    }

    .cu-table,
    .cu-table tbody {
        display: block;
    }

    .cu-table tbody tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 10px 12px;
        padding: 14px 16px;
        border-bottom: 1px solid var(--sp-border);
    }

    .cu-table tbody tr:last-child {
        border-bottom: 0;
    }

    .cu-table td {
        display: block;
        min-width: 0;
        padding: 0;
        border: 0;
    }

    .cu-table .c-idx {
        display: none;
    }

    .cu-table .sp-state,
    .cu-table .cu-skel-row,
    .cu-table .sp-state td,
    .cu-table .cu-skel-row td {
        display: block;
    }

    /* Users: person + actions on top, contact details underneath (indented under the avatar). */
    .cu-users .c-person {
        grid-column: 1;
        grid-row: 1;
    }

    .cu-users .c-actions {
        grid-column: 2;
        grid-row: 1;
        align-self: center;
        width: auto;
    }

    .cu-users .c-contact {
        grid-column: 1 / -1;
        grid-row: 2;
        padding-left: 52px;
    }

    .cu-users .c-actions .cu-orders-label {
        display: none;
    }

    /* Subscribers: email on top, date beneath. */
    .cu-subs .c-email {
        grid-column: 1 / -1;
    }

    .cu-subs .c-date {
        grid-column: 1 / -1;
        padding-left: 52px;
    }

    .cu-subs .cu-date small {
        display: inline;
        margin: 0 0 0 6px;
    }

    .rv-list {
        padding: 12px;
        gap: 10px;
    }
}

@media (max-width: 575.98px) {
    .rv-card {
        padding: 14px;
    }

    .rv-product {
        max-width: 40%;
    }

    .rv-photo {
        width: 68px;
        height: 68px;
    }

    .rv-foot .btn.sp-btn {
        flex: 1;
    }

    .rv-viewer-btn.is-prev {
        left: 6px;
    }

    .rv-viewer-btn.is-next {
        right: 6px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .rv-card,
    .rv-photo img {
        transition: none !important;
    }
}
