/**
 * SurgiValley Sets — Set Contents Display
 * Professional card grid inspired by ERPNext set contents
 *
 * Design: Numbered badge cards, 4-column responsive grid
 * Color: Mint-green/teal accent (#0d9488 badges, #ecfdf5 background)
 * Mobile: 1 → 2 → 3 → 4 columns responsive
 * Performance: GPU-composited animations, no layout thrash
 */

/* ═══════════════════════════════════════════════════════════
   WRAPPER & HEADER
   ═══════════════════════════════════════════════════════════ */
.sv-set-wrapper {
    margin: 28px 0;
    padding: 28px 32px;
    background: linear-gradient(135deg, #ecfdf5 0%, #f0fdfa 50%, #f0fdf4 100%);
    border: 1px solid #a7f3d0;
    border-radius: 16px;
}

.sv-set-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(167, 243, 208, 0.5);
}

.sv-set-title {
    font-size: 22px;
    font-weight: 700;
    color: #064e3b;
    margin: 0 0 6px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    line-height: 1.3;
}

.sv-set-icon {
    flex-shrink: 0;
    color: #0d9488;
    width: 26px;
    height: 26px;
}

.sv-set-subtitle {
    font-size: 15px;
    color: #6b7280;
    margin: 0;
    line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════════
   CARD GRID — 4 columns desktop, responsive down
   ═══════════════════════════════════════════════════════════ */
.sv-set-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

/* ═══════════════════════════════════════════════════════════
   INDIVIDUAL CARD
   ═══════════════════════════════════════════════════════════ */
.sv-set-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 14px 14px 18px;
    background: #ffffff;
    border: 1px solid #d1fae5;
    border-radius: 12px;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.sv-set-card.sv-matched:hover {
    border-color: #0d9488;
    box-shadow: 0 4px 20px rgba(13, 148, 136, 0.12);
    transform: translateY(-1px);
}

.sv-set-card.sv-unmatched {
    opacity: 0.75;
    border-style: dashed;
    border-color: #d1d5db;
    background: #fafafa;
}

/* Numbered Badge — Teal circle */
.sv-set-badge {
    position: absolute;
    top: -8px;
    left: -8px;
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #0d9488 0%, #14b8a6 100%);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.35);
    z-index: 2;
    border: 2px solid #ecfdf5;
}

/* Card Image */
.sv-set-card-img {
    flex-shrink: 0;
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 8px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
}

.sv-set-card-img img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.2s ease;
}

.sv-set-card.sv-matched:hover .sv-set-card-img img {
    transform: scale(1.08);
}

.sv-set-card-img a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.sv-set-no-img {
    font-size: 28px;
    color: #9ca3af;
    line-height: 1;
}

/* Card Info */
.sv-set-card-info {
    flex: 1;
    min-width: 0;
}

.sv-set-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
    line-height: 1.4;
    margin-bottom: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

a.sv-set-name.sv-linked {
    color: #0f766e;
    text-decoration: none;
    transition: color 0.15s;
}

a.sv-set-name.sv-linked:hover {
    color: #0d9488;
    text-decoration: underline;
}

.sv-set-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Qty Badge — green pill */
.sv-set-qty-badge {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    padding: 3px 10px;
    border-radius: 12px;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

/* SKU — muted code style */
.sv-set-sku {
    font-size: 12px;
    font-family: 'SF Mono', 'Monaco', 'Consolas', 'Courier New', monospace;
    color: #6b7280;
    background: #f3f4f6;
    padding: 2px 8px;
    border-radius: 4px;
    text-decoration: none;
    transition: all 0.15s;
}

a.sv-set-sku:hover {
    color: #0d9488;
    background: #ccfbf1;
}

/* ═══════════════════════════════════════════════════════════
   HOVER PREVIEW — follows cursor, desktop only
   ═══════════════════════════════════════════════════════════ */
.sv-set-hover-preview {
    display: none;
    position: fixed;
    width: 250px;
    background: #fff;
    border: 2px solid #0d9488;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    z-index: 10000;
    padding: 12px;
    pointer-events: none;
    overflow: hidden;
}

.sv-set-hover-preview img {
    width: 100%;
    height: auto;
    max-height: 220px;
    object-fit: contain;
    border-radius: 8px;
}

.sv-set-hover-preview .sv-preview-name {
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
    margin-top: 8px;
    text-align: center;
    line-height: 1.3;
}

.sv-set-hover-preview .sv-preview-sku {
    font-size: 11px;
    color: #6b7280;
    text-align: center;
    font-family: monospace;
    margin-top: 2px;
}

/* ═══════════════════════════════════════════════════════════
   SKELETON LOADING (while AJAX loads)
   ═══════════════════════════════════════════════════════════ */
.sv-set-loading {
    opacity: 0.7;
}

.sv-skeleton-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 14px 14px 18px;
    background: #fff;
    border: 1px solid #d1fae5;
    border-radius: 12px;
    min-height: 80px;
}

.sv-skeleton-badge {
    position: absolute;
    top: -9px;
    left: -9px;
    width: 30px;
    height: 30px;
    background: #a7f3d0;
    border-radius: 50%;
    animation: sv-pulse 1.5s ease infinite;
}

.sv-skeleton-img {
    width: 72px;
    height: 72px;
    background: #e5e7eb;
    border-radius: 8px;
    flex-shrink: 0;
    animation: sv-pulse 1.5s ease infinite 0.1s;
}

.sv-skeleton-text {
    flex: 1;
    height: 16px;
    background: #e5e7eb;
    border-radius: 4px;
    animation: sv-pulse 1.5s ease infinite 0.2s;
}

.sv-skeleton-sku {
    width: 80px;
    height: 12px;
    background: #e5e7eb;
    border-radius: 4px;
    animation: sv-pulse 1.5s ease infinite 0.3s;
}

@keyframes sv-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ═══════════════════════════════════════════════════════════
   ERROR STATE
   ═══════════════════════════════════════════════════════════ */
.sv-set-error {
    text-align: center;
    padding: 24px;
    color: #6b7280;
    font-size: 14px;
}

.sv-set-error button {
    margin-top: 10px;
    padding: 8px 20px;
    background: #0d9488;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.15s;
}

.sv-set-error button:hover {
    background: #0f766e;
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — 4 → 3 → 2 → 1 column cascade
   ═══════════════════════════════════════════════════════════ */

/* Large tablets / narrow desktops */
@media (max-width: 1200px) {
    .sv-set-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Tablets */
@media (max-width: 768px) {
    .sv-set-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }

    .sv-set-wrapper {
        padding: 20px;
        margin: 20px 0;
    }

    .sv-set-title {
        font-size: 19px;
    }

    .sv-set-card {
        padding: 14px 14px 14px 18px;
    }

    .sv-set-card-img {
        width: 60px;
        height: 60px;
    }

    .sv-set-hover-preview {
        display: none !important;
    }
}

/* Mobile phones */
@media (max-width: 480px) {
    .sv-set-wrapper {
        padding: 16px;
        margin: 14px 0;
        border-radius: 12px;
    }

    .sv-set-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .sv-set-card {
        padding: 12px 12px 12px 16px;
        gap: 12px;
    }

    .sv-set-card-img {
        width: 52px;
        height: 52px;
    }

    .sv-set-title {
        font-size: 17px;
        gap: 8px;
    }

    .sv-set-icon {
        width: 22px;
        height: 22px;
    }

    .sv-set-subtitle {
        font-size: 13px;
    }

    .sv-set-badge {
        width: 26px;
        height: 26px;
        font-size: 11px;
        top: -7px;
        left: -7px;
    }

    .sv-set-name {
        font-size: 13px;
        -webkit-line-clamp: 3;
    }

    .sv-set-qty-badge {
        font-size: 10px;
        padding: 2px 8px;
    }

    .sv-set-sku {
        font-size: 11px;
    }
}

/* ═══════════════════════════════════════════════════════════
   RTL SUPPORT (for Arabic locale)
   ═══════════════════════════════════════════════════════════ */
[dir="rtl"] .sv-set-badge {
    left: auto;
    right: -8px;
}

[dir="rtl"] .sv-set-card {
    padding: 14px 18px 14px 14px;
}

@media (max-width: 480px) {
    [dir="rtl"] .sv-set-badge {
        right: -7px;
    }

    [dir="rtl"] .sv-set-card {
        padding: 12px 16px 12px 12px;
    }
}

/* ═══════════════════════════════════════════════════════════
   LEGACY TABLE OVERRIDE — ensures old cached HTML still looks decent
   ═══════════════════════════════════════════════════════════ */
.sv-set-contents .sv-set-table {
    width: 100%;
    border-collapse: collapse;
}

.sv-set-contents .sv-set-table th,
.sv-set-contents .sv-set-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    vertical-align: middle;
}

.sv-set-contents .sv-set-table th {
    background: #f9fafb;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.sv-set-contents .sv-set-thumb {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 4px;
    vertical-align: middle;
    margin-right: 8px;
}

.sv-set-contents .sv-set-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: #0f766e;
}

.sv-set-contents .sv-set-link:hover {
    color: #0d9488;
}

/* Hide old hover-preview div from table renderer */
.sv-hover-preview,
#sv-hover-preview {
    display: none !important;
}

/* ═══════════════════════════════════════════════════════════
   CURRENTLY VIEWING — SET MEMBER HIGHLIGHT
   When a set member product is viewed, its card in the set grid
   gets a teal highlight + "Currently Viewing" badge.
   ═══════════════════════════════════════════════════════════ */
.sv-set-card.sv-current-member {
    border-color: #0d9488;
    background: linear-gradient(135deg, #ecfdf5 0%, #ccfbf1 100%);
    box-shadow: 0 0 0 2px rgba(13, 148, 136, 0.2), 0 4px 12px rgba(13, 148, 136, 0.12);
}

.sv-set-card.sv-current-member .sv-set-badge {
    background: linear-gradient(135deg, #0d9488, #14b8a6) !important;
    box-shadow: 0 2px 8px rgba(13, 148, 136, 0.4) !important;
}

.sv-set-card.sv-current-member .sv-set-name {
    color: #064e3b;
    font-weight: 600;
}

.sv-set-current-label {
    display: inline-block;
    margin-top: 8px;
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 600;
    color: #0d9488;
    background: #ccfbf1;
    border: 1px solid #99f6e4;
    border-radius: 12px;
    letter-spacing: 0.02em;
}

/* ═══════════════════════════════════════════════════════════
   VARIANT GROUP STYLES — Dual-mode support
   ═══════════════════════════════════════════════════════════ */

/* Variant group wrapper */
.sv-set-wrapper.sv-variant-group .sv-set-header {
    border-left-color: #4f46e5;
}

.sv-set-wrapper.sv-variant-group .sv-set-title {
    color: #4338ca;
}

/* Variant card — compact, buyable */
.sv-variant-card {
    position: relative;
    border: 2px solid #e0e7ff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.sv-variant-card:hover {
    border-color: #818cf8;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
}

/* Currently viewing variant — highlighted */
.sv-variant-card.sv-current-variant {
    border-color: #4f46e5;
    background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
}

/* Spec badge (e.g., "3mm", "10fr") — pill-style */
.sv-spec-badge {
    background: linear-gradient(135deg, #4f46e5, #6366f1) !important;
    color: white !important;
    font-weight: 700;
    font-size: 12px;
    padding: 4px 10px !important;
    border-radius: 14px !important;
    min-width: 36px !important;
    width: auto !important;
    height: auto !important;
    white-space: nowrap;
    line-height: 1.3;
    letter-spacing: 0.02em;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.35) !important;
    text-align: center;
}

/* Variant price display */
.sv-variant-price {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.sv-price-current {
    font-weight: 700;
    font-size: 15px;
    color: #059669;
}

.sv-price-old {
    font-size: 13px;
    color: #9ca3af;
    text-decoration: line-through;
    font-weight: 400;
}

.sv-price-sale {
    font-weight: 700;
    font-size: 15px;
    color: #dc2626;
}

/* View Details button */
.sv-variant-view-btn {
    display: inline-block;
    margin-top: 8px;
    padding: 5px 14px;
    font-size: 12px;
    font-weight: 600;
    color: #4f46e5;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.2s;
}

.sv-variant-view-btn:hover {
    background: #4f46e5;
    color: white;
    border-color: #4f46e5;
}

/* Currently viewing label — variant */
.sv-variant-current-label {
    display: inline-block;
    margin-top: 8px;
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 600;
    color: #4f46e5;
    background: #e0e7ff;
    border-radius: 12px;
    letter-spacing: 0.02em;
}

/* Responsive: variant cards */
@media (max-width: 768px) {
    .sv-variant-group .sv-set-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .sv-variant-view-btn {
        width: 100%;
        text-align: center;
    }
}