/* Product dedupe & substitution — Admin modal. Scoped to .pm-sub-* */

.pm-sub-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 9100;
    display: none;
    align-items: stretch;
    justify-content: stretch;
    padding: 2vh 1.5vw;
    box-sizing: border-box;
}

.pm-sub-panel {
    background: #fff;
    color: #1a2b3c;
    width: 100%;
    height: calc(100vh - 4vh);
    max-height: calc(100vh - 4vh);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
}

.pm-sub-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.4rem;
    border-bottom: 2px solid #f0f1f3;
    flex-shrink: 0;
}

.pm-sub-title {
    margin: 0;
    font-size: 1.25rem;
}

.pm-sub-close {
    background: none;
    border: none;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    color: #6c757d;
}

.pm-sub-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 0 1.25rem 1.25rem;
}

.pm-sub-toolbar {
    flex-shrink: 0;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 0.9rem 1rem;
    margin-bottom: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.pm-sub-search-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.pm-sub-search {
    flex: 1;
    border: 1px solid #ced4da;
    border-radius: 8px;
    padding: 0.65rem 0.8rem;
    font-size: 1rem;
}

.pm-sub-status,
.pm-sub-note,
.pm-sub-empty {
    color: #526070;
    font-size: 0.92rem;
}

.pm-sub-layout {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(300px, 0.9fr) minmax(380px, 1.25fr);
    gap: 0.8rem;
}

.pm-sub-results,
.pm-sub-detail {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    min-height: 0;
    overflow: auto;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 0.85rem;
    background: #fff;
}

.pm-sub-result {
    text-align: left;
    background: #fff;
    border: 1px solid #e4e7eb;
    border-radius: 12px;
    padding: 0;
    cursor: pointer;
}

.pm-sub-result.is-active {
    border-color: #0d6efd;
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.15);
}

.pm-sub-card {
    display: flex;
    gap: 0.75rem;
    padding: 0.7rem;
}

.pm-sub-card-text {
    min-width: 0;
}

.pm-sub-meta {
    font-size: 0.82rem;
    color: #526070;
    word-break: break-all;
}

.pm-sub-thumb {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
    background: #f4f6f8;
}

.pm-sub-thumb-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.68rem;
    color: #6c757d;
    text-align: center;
}

.pm-sub-counts {
    margin: 0;
    padding-left: 1.1rem;
}

.pm-sub-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    position: sticky;
    bottom: 0;
    background: #fff;
    padding: 0.75rem 0 0.15rem;
    border-top: 1px solid #e4e7eb;
    margin-top: 0.35rem;
}

.pm-sub-check {
    display: flex;
    gap: 0.4rem;
    align-items: flex-start;
    font-size: 0.9rem;
    color: #1a2b3c;
}

.pm-sub-btn {
    border: 1px solid #ced4da;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 0.55rem 0.9rem;
    cursor: pointer;
}

.pm-sub-btn:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.pm-sub-btn-primary {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
    border-color: #0891b2;
    color: #fff;
}

.pm-sub-btn-danger {
    color: #b02a37;
}

.pm-sub-results h3,
.pm-sub-scan h3,
.pm-sub-detail h3,
.pm-sub-preview h3 {
    margin: 0.4rem 0 0;
    font-size: 0.95rem;
}

.pm-sub-scan {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.pm-sub-scan-pair {
    border: 1px solid #e4e7eb;
    border-radius: 12px;
    padding: 0.75rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.35rem 1rem;
}

.pm-sub-scan-pair .pm-sub-scan-reason,
.pm-sub-scan-pair .pm-sub-btn {
    grid-column: 1 / -1;
}

.pm-sub-scan-pair .pm-sub-btn {
    justify-self: start;
}

.pm-sub-preview {
    border: 1px solid #d6e4ff;
    background: #f7faff;
    border-radius: 12px;
    padding: 0.75rem;
}

@media (max-width: 760px) {
    .pm-sub-overlay {
        padding: 0;
    }

    .pm-sub-panel {
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .pm-sub-body {
        overflow: auto;
    }

    .pm-sub-layout {
        grid-template-columns: 1fr;
        overflow: visible;
    }

    .pm-sub-results,
    .pm-sub-detail {
        overflow: visible;
    }
}
