/**
 * Product Info Related Modal (Rebuilt)
 * Desktop: centered modal, Mobile: bottom sheet.
 */

.psm-related-modal-wrapper {
    display: inline-flex;
    align-items: center;
    position: relative;
    z-index: 30;
}

.psm-related-modal-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 1px solid rgba(15, 23, 42, 0.15);
    background: #f8fafc;
    color: #0f172a;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.psm-related-modal-toggle:hover {
    background: #eef2f7;
    border-color: rgba(15, 23, 42, 0.25);
}

.psm-related-modal-toggle:focus-visible {
    outline: 2px solid #0b62f5;
    outline-offset: 2px;
}

.psm-related-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.98);
    width: min(820px, 92vw);
    max-height: min(80vh, 720px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 28px 80px rgba(15, 23, 42, 0.22);
    border: 1px solid rgba(15, 23, 42, 0.08);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    z-index: 2147483647;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
}

.psm-related-modal.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.psm-related-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

.psm-related-modal-title {
    font-size: 14px;
    font-weight: 600;
    color: #334155;
}

.psm-related-modal-close {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: 1px solid transparent;
    background: #f8fafc;
    color: #64748b;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.psm-related-modal-close:hover {
    background: #0f172a;
    color: #ffffff;
    border-color: #0f172a;
}

.psm-related-modal-grid {
    padding: 16px 20px 20px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.psm-related-modal-card {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 12px;
    border-radius: 12px;
    text-decoration: none;
    background: #ffffff;
    color: #0f172a;
    border: 1px solid rgba(15, 23, 42, 0.08);
    transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.psm-related-modal-card:hover,
.psm-related-modal-card:focus-visible {
    border-color: rgba(15, 23, 42, 0.2);
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.12);
    transform: translateY(-2px);
}

.psm-related-modal-thumb {
    width: 56px;
    height: 56px;
    border-radius: 10px;
    overflow: hidden;
    background: #eef2f7;
    flex-shrink: 0;
}

.psm-related-modal-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.psm-related-modal-details {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.psm-related-modal-name {
    font-size: 14px;
    font-weight: 600;
    color: #0f172a;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.psm-related-modal-meta {
    font-size: 12px;
    color: #64748b;
}

.psm-related-modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 2147483646;
    pointer-events: auto;
}

.psm-related-modal-backdrop.is-visible {
    display: block;
}

body.psm-related-modal-open {
    overflow: hidden;
}

@media (max-width: 900px) {
    .psm-related-modal {
        width: min(720px, 94vw);
    }
}

@media (max-width: 768px) {
    .psm-related-modal {
        width: 100%;
        max-height: 85vh;
        border-radius: 18px 18px 0 0;
        margin: 0;
        bottom: 0;
        top: auto;
        left: 0;
        right: 0;
        transform: translateY(100%);
        pointer-events: auto;
    }

    .psm-related-modal.is-visible {
        transform: translateY(0);
    }

    .psm-related-modal-header {
        padding: 14px 18px;
    }

    .psm-related-modal-grid {
        grid-template-columns: 1fr;
        padding: 16px;
        gap: 12px;
    }

    .psm-related-modal-card {
        padding: 12px;
    }

    .psm-related-modal-thumb {
        width: 52px;
        height: 52px;
    }
}

@media (min-width: 769px) {
    .psm-related-modal {
        top: 50%;
        left: 50%;
    }
}
