/**
 * KL Products Frontend Styles - FIXED VERSION
 * Mobile-first, SEO-optimized CSS
 * Column settings now come from inline styles per gallery
 */

/* Base Container */
.kl-products-container {
    width: 100%;
    margin: 0 auto;
    padding: 20px 0;
}

/* Grid Layout - Base styles only, columns set inline */
.kl-products-grid {
    display: grid;
    gap: 20px;
    /* grid-template-columns is now set inline per gallery */
}

/* Product Card */
.kl-product-card {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.kl-product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

/* Product Image */
.kl-product-image {
    position: relative;
    width: 100%;
    padding-bottom: 100%; /* 1:1 Aspect Ratio */
    overflow: hidden;
    background: #f5f5f5;
}

.kl-product-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.kl-product-card:hover .kl-product-image img {
    transform: scale(1.05);
}

/* Lazy Loading Placeholder */
.kl-product-image.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #8B4513;
    border-radius: 50%;
    animation: kl-spin 1s linear infinite;
    z-index: 1;
}

@keyframes kl-spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Product Content */
.kl-product-content {
    padding: 15px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.kl-product-title {
    font-size: 0.875em;  /* 14px equivalent, reduced 25% from 1.125em */
    font-weight: 600;
    color: #333;
    margin: 0 0 8px 0;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.kl-product-price {
    font-size: 1.25em;  /* 20px equivalent */
    font-weight: 700;
    color: #8B4513;
    margin: 8px 0;
}

.kl-product-price .sale-price {
    color: #ff4444;
    margin-right: 8px;
}

.kl-product-price .regular-price {
    text-decoration: line-through;
    color: #999;
    font-size: 1em;  /* 16px equivalent */
    font-weight: 400;
}

.kl-product-description {
    font-size: 0.875em;  /* 14px equivalent */
    line-height: 1.5;
    color: #666;
    margin: 10px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    flex: 1;
}

/* Product Button */
.kl-product-button {
    display: inline-block;
    width: 100%;
    padding: 12px 20px;
    background: #8B4513;
    color: #fff;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: 4px;
    font-size: 1em;  /* 16px equivalent */
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease;
    margin-top: auto;
}

.kl-product-button:hover {
    background: #723710;
    color: #fff;
    text-decoration: none;
    transform: translateY(-2px);
}

/* Out of Stock */
.kl-product-card.out-of-stock .kl-product-image::after {
    content: 'Out of Stock';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.8);
    color: #fff;
    padding: 10px 20px;
    border-radius: 4px;
    font-weight: 600;
    z-index: 2;
}

.kl-product-card.out-of-stock img {
    opacity: 0.5;
}

/* Slider View */
.kl-products-slider {
    position: relative;
    overflow: hidden;
    padding: 0 40px;
}

.kl-slider-wrapper {
    display: flex;
    transition: transform 0.3s ease;
    gap: 20px;
}

.kl-slider-item {
    flex: 0 0 calc(33.333% - 14px);
    min-width: 0;
}

.kl-slider-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.9);
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: background 0.3s ease;
    z-index: 10;
    font-size: 1.25em;  /* 20px equivalent */
}

.kl-slider-nav:hover {
    background: #fff;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.kl-slider-nav:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.kl-slider-prev {
    left: 0;
}

.kl-slider-next {
    right: 0;
}

/* Single Product View */
.kl-single-product {
    display: flex;
    gap: 30px;
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin: 20px 0;
}

.kl-single-product-image {
    flex: 0 0 40%;
    max-width: 400px;
}

.kl-single-product-image img {
    width: 100%;
    height: auto;
    border-radius: 4px;
}

.kl-single-product-content {
    flex: 1;
}

.kl-single-product-title {
    font-size: 1.5em;  /* 24px equivalent */
    font-weight: 700;
    color: #333;
    margin: 0 0 15px 0;
}

/* Alignment classes */
.kl-single-product.align-center {
    flex-direction: column;
    text-align: center;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.kl-single-product.align-right {
    flex-direction: row-reverse;
}

/* Load More Button */
.kl-load-more-wrapper {
    text-align: center;
    margin: 40px 0 20px;
}

.kl-load-more-button {
    display: inline-block;
    padding: 12px 30px;
    background: #8B4513;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 1em;  /* 16px equivalent */
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s ease;
}

.kl-load-more-button:hover {
    background: #723710;
    transform: translateY(-2px);
}

.kl-load-more-button.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Quick View Modal */
.kl-quick-view-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.kl-quick-view-modal.active {
    display: flex;
}

.kl-quick-view-content {
    background: #fff;
    max-width: 900px;
    width: 90%;
    max-height: 90vh;
    overflow: auto;
    border-radius: 8px;
    position: relative;
}

.kl-quick-view-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 30px;
    height: 30px;
    background: #333;
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125em;  /* 18px equivalent */
    z-index: 10;
}

/* Responsive Design - Tablet */
@media (max-width: 768px) {
    .kl-slider-item {
        flex: 0 0 calc(50% - 10px);
    }
    
    .kl-single-product {
        flex-direction: column;
    }
    
    .kl-single-product-image {
        flex: none;
        max-width: 100%;
    }
    
    .kl-product-button {
        font-size: 0.875em;  /* 14px equivalent */
        padding: 10px 15px;
    }
}

/* Responsive Design - Mobile */
@media (max-width: 480px) {
    .kl-products-container {
        padding: 10px;
    }
    
    .kl-slider-item {
        flex: 0 0 100%;
    }
    
    .kl-slider-nav {
        width: 30px;
        height: 30px;
        font-size: 1em;  /* 16px equivalent */
    }
    
    .kl-product-content {
        padding: 12px;
    }
    
    .kl-product-title {
        font-size: 0.75em;  /* 12px equivalent, reduced 25% from 1em */
    }
    
    .kl-product-price {
        font-size: 1.125em;  /* 18px equivalent */
    }
}

/* Accessibility */
.kl-product-card:focus-within {
    outline: 2px solid #8B4513;
    outline-offset: 2px;
}

.kl-product-button:focus,
.kl-slider-nav:focus,
.kl-load-more-button:focus {
    outline: 2px solid #8B4513;
    outline-offset: 2px;
}

/* Error Messages */
.kl-error {
    color: #f44336;
    padding: 10px;
    background: #ffebee;
    border-left: 4px solid #f44336;
    margin: 10px 0;
}

/* Print Styles */
@media print {
    .kl-product-button,
    .kl-slider-nav,
    .kl-load-more-button,
    .kl-quick-view-modal {
        display: none !important;
    }
    
    .kl-product-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* Custom CSS Override Point */
/* Users can add custom CSS in settings that will override these styles */