/**
 * Cross-Sale & Up-Sale Products Styling
 * Default styles for related product sections (Frequently Bought Together, Up-sale bundles)
 * Themes can override these styles in their own SCSS/CSS files
 */

/* ==========================================================================
   CSS Variables (customizable by themes)
   ========================================================================== */
:root {
    --ec-related-primary: #0d6efd;
    --ec-related-black: #1f2937;
    --ec-related-gray-50: #f8fafc;
    --ec-related-gray-100: #f1f5f9;
    --ec-related-gray-200: #e2e8f0;
    --ec-related-gray-300: #cbd5e1;
    --ec-related-gray-500: #64748b;
    --ec-related-gray-600: #475569;
    --ec-related-border-radius: 16px;
    --ec-related-card-radius: 12px;
    --ec-related-transition: all 0.3s ease;
}

/* ==========================================================================
   Cross-Sale Section (Frequently Bought Together)
   ========================================================================== */
.ec-cross-sale-section {
    margin-bottom: 70px;
}

@media (max-width: 575px) {
    .ec-cross-sale-section {
        margin-bottom: 50px;
    }
}

.ec-cross-sale-wrapper {
    background: linear-gradient(135deg, var(--ec-related-gray-50) 0%, var(--ec-related-gray-100) 100%);
    border: 1px solid var(--ec-related-gray-200);
    border-radius: var(--ec-related-border-radius);
    padding: 28px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}

@media (max-width: 575px) {
    .ec-cross-sale-wrapper {
        padding: 20px 16px;
        border-radius: 12px;
    }
}

/* Header */
.ec-cross-sale-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px dashed var(--ec-related-gray-300);
}

.ec-cross-sale-icon {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, var(--ec-related-primary) 0%, var(--ec-related-black) 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.ec-cross-sale-icon svg {
    color: white;
    width: 24px;
    height: 24px;
}

@media (max-width: 575px) {
    .ec-cross-sale-icon {
        width: 44px;
        height: 44px;
    }
    .ec-cross-sale-icon svg {
        width: 20px;
        height: 20px;
    }
}

.ec-cross-sale-title h4 {
    font-size: 20px;
    font-weight: 700;
    color: var(--ec-related-black);
    margin: 0 0 6px 0;
}

.ec-cross-sale-title p {
    font-size: 14px;
    color: var(--ec-related-gray-500);
    margin: 0;
}

@media (max-width: 575px) {
    .ec-cross-sale-title h4 {
        font-size: 17px;
    }
    .ec-cross-sale-title p {
        font-size: 13px;
    }
}

/* Slider */
.ec-cross-sale-slider {
    position: relative;
}

.ec-cross-sale-slider .swiper-slide {
    max-width: 260px;
    height: auto;
}

@media (max-width: 575px) {
    .ec-cross-sale-slider .swiper-slide {
        max-width: 220px;
    }
}

.ec-cross-sale-slider .ec-swiper-scrollbar {
    background-color: var(--ec-related-gray-200);
    width: calc(100% - 200px);
    margin: 20px auto 0;
    height: 4px;
    border-radius: 2px;
}

@media (max-width: 575px) {
    .ec-cross-sale-slider .ec-swiper-scrollbar {
        width: calc(100% - 60px);
    }
}

.ec-cross-sale-slider .swiper-scrollbar-drag {
    background-color: var(--ec-related-primary);
    border-radius: 2px;
}

/* Product Card */
.ec-cross-sale-card {
    position: relative;
    height: 100%;
}

.ec-cross-sale-plus {
    position: absolute;
    left: -16px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    background: white;
    border: 2px solid var(--ec-related-gray-200);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.ec-cross-sale-plus svg {
    color: var(--ec-related-primary);
    width: 20px;
    height: 20px;
}

@media (max-width: 575px) {
    .ec-cross-sale-plus {
        width: 28px;
        height: 28px;
        left: -12px;
    }
    .ec-cross-sale-plus svg {
        width: 16px;
        height: 16px;
    }
}

/* RTL Support */
[dir='rtl'] .ec-cross-sale-plus {
    left: auto;
    right: -16px;
}

@media (max-width: 575px) {
    [dir='rtl'] .ec-cross-sale-plus {
        right: -12px;
    }
}

.ec-cross-sale-card-inner {
    background: white;
    border: 1px solid var(--ec-related-gray-200);
    border-radius: var(--ec-related-card-radius);
    padding: 16px;
    height: 100%;
    display: flex;
    flex-direction: column;
    transition: var(--ec-related-transition);
}

.ec-cross-sale-card-inner:hover {
    border-color: var(--ec-related-primary);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    transform: translateY(-4px);
}

@media (max-width: 575px) {
    .ec-cross-sale-card-inner {
        padding: 12px;
        border-radius: 10px;
    }
}

/* Product Thumbnail */
.ec-cross-sale-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    background: var(--ec-related-gray-50);
    margin-bottom: 14px;
}

.ec-cross-sale-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.ec-cross-sale-thumb:hover img {
    transform: scale(1.05);
}

/* Product Badge */
.ec-cross-sale-thumb .ec-product-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 1;
}

[dir='rtl'] .ec-cross-sale-thumb .ec-product-badge {
    left: auto;
    right: 8px;
}

.ec-cross-sale-thumb .ec-product-badge span {
    display: inline-block;
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    line-height: 1;
}

.ec-cross-sale-thumb .ec-product-badge .badge-sale {
    background-color: #dc3545;
    color: white;
}

.ec-cross-sale-thumb .ec-product-badge .badge-hot {
    background-color: #fd7e14;
    color: white;
}

.ec-cross-sale-thumb .ec-product-badge .badge-new {
    background-color: #198754;
    color: white;
}

/* Product Content */
.ec-cross-sale-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.ec-cross-sale-name {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    margin: 0 0 10px 0;
    flex: 1;
}

.ec-cross-sale-name a {
    color: var(--ec-related-black);
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.2s ease;
}

.ec-cross-sale-name a:hover {
    color: var(--ec-related-primary);
}

/* Product Price */
.ec-cross-sale-price {
    margin-bottom: 12px;
}

.ec-cross-sale-price .ec-price {
    font-size: 16px;
    font-weight: 700;
    color: var(--ec-related-primary);
}

.ec-cross-sale-price .ec-price-old {
    font-size: 13px;
    color: #94a3b8;
    text-decoration: line-through;
    margin-left: 6px;
}

[dir='rtl'] .ec-cross-sale-price .ec-price-old {
    margin-left: 0;
    margin-right: 6px;
}

/* Add to Cart Button */
.ec-cross-sale-add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, var(--ec-related-primary) 0%, var(--ec-related-black) 100%);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--ec-related-transition);
    margin-top: auto;
}

.ec-cross-sale-add-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.ec-cross-sale-add-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    color: white;
}

.ec-cross-sale-add-btn:active {
    transform: translateY(0);
}

.ec-cross-sale-add-btn.has-options {
    background: linear-gradient(135deg, var(--ec-related-gray-500) 0%, var(--ec-related-gray-600) 100%);
}

/* ==========================================================================
   Up-Sale Section (Bundle Discounts)
   ========================================================================== */
.ec-up-sale-section {
    margin-bottom: 70px;
}

@media (max-width: 575px) {
    .ec-up-sale-section {
        margin-bottom: 50px;
    }
}

.ec-up-sale-wrapper {
    background: linear-gradient(135deg, #fff9f0 0%, #fff5eb 100%);
    border: 2px solid #ff6b35;
    border-radius: var(--ec-related-border-radius);
    padding: 24px;
    box-shadow: 0 4px 20px rgba(255, 107, 53, 0.1);
}

@media (max-width: 575px) {
    .ec-up-sale-wrapper {
        padding: 16px;
        border-radius: 12px;
    }
}

/* Header */
.ec-up-sale-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px dashed #ffcbb3;
}

.ec-up-sale-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #ff6b35 0%, #ff8c5a 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ec-up-sale-icon svg {
    color: white;
    width: 24px;
    height: 24px;
}

.ec-up-sale-title h4 {
    font-size: 18px;
    font-weight: 700;
    color: #d4380d;
    margin: 0 0 4px 0;
}

.ec-up-sale-title p {
    font-size: 13px;
    color: #666;
    margin: 0;
}

/* Product List */
.ec-up-sale-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Product Item */
.ec-up-sale-item {
    background: white;
    border: 1px solid #e8e8e8;
    border-radius: 10px;
    transition: var(--ec-related-transition);
}

.ec-up-sale-item:hover {
    border-color: #ff6b35;
    box-shadow: 0 2px 12px rgba(255, 107, 53, 0.15);
}

.ec-up-sale-item-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    cursor: pointer;
    margin: 0;
}

@media (max-width: 575px) {
    .ec-up-sale-item-inner {
        gap: 10px;
        padding: 10px;
    }
}

/* Checkbox */
.ec-up-sale-checkbox {
    position: relative;
    flex-shrink: 0;
}

.ec-up-sale-checkbox input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.ec-up-sale-checkmark {
    width: 22px;
    height: 22px;
    background: white;
    border: 2px solid #ddd;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--ec-related-transition);
}

.ec-up-sale-checkbox input[type="checkbox"]:checked ~ .ec-up-sale-checkmark {
    background-color: #ff6b35;
    border-color: #ff6b35;
}

.ec-up-sale-checkmark::after {
    content: '';
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    display: none;
}

.ec-up-sale-checkbox input[type="checkbox"]:checked ~ .ec-up-sale-checkmark::after {
    display: block;
}

/* Product Thumbnail */
.ec-up-sale-thumb {
    position: relative;
    width: 70px;
    height: 70px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    background: #f8f8f8;
}

@media (max-width: 575px) {
    .ec-up-sale-thumb {
        width: 60px;
        height: 60px;
    }
}

.ec-up-sale-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Product Info */
.ec-up-sale-info {
    flex: 1;
    min-width: 0;
}

.ec-up-sale-name {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 6px 0;
    line-height: 1.4;
}

.ec-up-sale-name a {
    color: #333;
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ec-up-sale-name a:hover {
    color: #ff6b35;
}

.ec-up-sale-price {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.ec-up-sale-price .ec-price {
    font-size: 15px;
    font-weight: 700;
    color: #ff6b35;
}

.ec-up-sale-price .ec-price-old {
    font-size: 13px;
    color: #999;
    text-decoration: line-through;
}

.ec-up-sale-discount-badge {
    font-size: 11px;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #ff6b35 0%, #ff8c5a 100%);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Summary Footer */
.ec-up-sale-summary {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px dashed #ffcbb3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.ec-up-sale-total {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ec-up-sale-total-label {
    font-size: 14px;
    color: #666;
}

.ec-up-sale-total-price {
    font-size: 20px;
    font-weight: 700;
    color: #d4380d;
}

.ec-up-sale-total-saved {
    font-size: 13px;
    color: #52c41a;
    font-weight: 600;
}

.ec-up-sale-add-all-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #ff6b35 0%, #e85d2a 100%);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--ec-related-transition);
}

.ec-up-sale-add-all-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
    color: white;
}

.ec-up-sale-add-all-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.ec-up-sale-add-all-btn svg {
    width: 18px;
    height: 18px;
}

/* ==========================================================================
   Loading Spinner
   ========================================================================== */
.ec-related-loading {
    position: relative;
    min-height: 200px;
}

.ec-related-loading .loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid var(--ec-related-gray-200);
    border-top-color: var(--ec-related-primary);
    border-radius: 50%;
    animation: ec-spinner 0.8s linear infinite;
}

@keyframes ec-spinner {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */
.ec-related-hidden {
    display: none !important;
}

.ec-related-text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ec-related-text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
