/**
 * Modal de Productos Relacionados - LIMPIO
 * Sin conflictos ni !important innecesarios
 *
 * @package eSaicoWC
 * @version 1.0.0
 */

/* Contenedor principal del modal */
#modal-related-products {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    z-index: 999999;
    display: none;
}

#modal-related-products.active {
    display: block;
}

/* Overlay oscuro */
#modal-related-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    cursor: pointer;
}

/* Contenedor del contenido */
.modal-content-modern {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 1000px;
    max-height: 90vh;
    background: #ffffff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    z-index: 2;
}

/* Header del modal */
.modal-header-modern {
    background: linear-gradient(135deg, var(--esaico-primary, #10b981) 0%, var(--esaico-primary-dark, #059669) 100%);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header-modern h2 {
    color: #ffffff;
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-header-modern h2 i {
    font-size: 24px;
}

/* Botón cerrar */
#modal-related-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #ffffff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#modal-related-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* Body del modal */
#modal-related-body {
    padding: 24px;
    max-height: calc(90vh - 80px);
    overflow-y: auto;
    background: #ffffff;
}

/* Grid de productos relacionados */
.esaico-related-grid-modal {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

/* Cards de productos */
.related-product-card {
    background: #f8f9fa;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    cursor: pointer;
}

.related-product-card:hover {
    border-color: var(--esaico-primary, #10b981);
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.related-product-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.related-product-image {
    position: relative;
    width: 100%;
    padding-top: 100%;
    overflow: hidden;
    background: #ffffff;
}

.related-product-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.related-product-card:hover .related-product-image img {
    transform: scale(1.1);
}

.related-product-info {
    padding: 16px;
}

.related-product-title {
    font-size: 15px;
    font-weight: 600;
    color: #212529;
    margin: 0 0 8px 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.related-product-price {
    font-size: 18px;
    font-weight: 700;
    color: var(--esaico-primary, #10b981);
}

.related-product-free {
    display: inline-block;
    padding: 6px 12px;
    background: rgba(16, 185, 129, 0.1);
    color: var(--esaico-primary, #10b981);
    font-size: 14px;
    font-weight: 600;
    border-radius: 20px;
}

/* Loading spinner */
.loading-spinner {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
}

.loading-spinner i {
    font-size: 48px;
    color: var(--esaico-primary, #10b981);
    margin-bottom: 16px;
    display: inline-block;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Scrollbar del body */
#modal-related-body::-webkit-scrollbar {
    width: 8px;
}

#modal-related-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

#modal-related-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 10px;
}

#modal-related-body::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Responsive */
@media (max-width: 768px) {
    .modal-content-modern {
        width: 95%;
        max-height: 95vh;
    }

    .modal-header-modern {
        padding: 16px 20px;
    }

    .modal-header-modern h2 {
        font-size: 18px;
    }

    #modal-related-body {
        padding: 16px;
    }

    .esaico-related-grid-modal {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .esaico-related-grid-modal {
        grid-template-columns: 1fr;
    }
}
