/**
 * WooCommerce Tillbehör & Reservdelar - Kompakt Karusell Styles
 * Anpassad för Blocksy-temat
 */

.wc-carousel-section {
    margin: 30px 0;
    padding: 20px 0;
    border-top: 1px solid #e0e0e0;
    clear: both;
    max-width: 100%;
    width: 100%;
}

.wc-reservdelar-section {
    border-top-color: #dc3545;
}

.wc-tillbehor-section {
    border-top-color: #28a745;
}

.carousel-title {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 20px;
    text-align: left;
    color: #333;
    position: relative;
}

.wc-reservdelar-section .carousel-title {
    color: #dc3545;
}

.wc-tillbehor-section .carousel-title {
    color: #28a745;
}

.carousel-title::after {
    content: '';
    display: block;
    width: 40px;
    height: 2px;
    margin: 8px 0 0 0;
    border-radius: 1px;
}

.wc-reservdelar-section .carousel-title::after {
    background: linear-gradient(90deg, #dc3545, #ff6b6b);
}

.wc-tillbehor-section .carousel-title::after {
    background: linear-gradient(90deg, #28a745, #20c997);
}

.carousel-container {
    position: relative;
    margin: 20px 0;
    max-width: 100%;
    width: 100%;
}

.carousel-wrapper {
    overflow: hidden;
    border-radius: 8px;
    max-width: 100%;
    width: 100%;
}

.carousel-track {
    display: flex;
    transition: transform 0.5s ease-in-out;
    gap: 15px;
}

.carousel-slide {
    flex: 0 0 auto;
    width: calc(100% / var(--products-per-slide, 4));
    min-width: 0;
}

.product-item {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    transition: all 0.3s ease;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.wc-reservdelar-section .product-item {
    border-color: #f8d7da;
}

.wc-tillbehor-section .product-item {
    border-color: #d4edda;
}

.product-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.wc-reservdelar-section .product-item:hover {
    border-color: #dc3545;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.15);
}

.wc-tillbehor-section .product-item:hover {
    border-color: #28a745;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.15);
}

.product-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.wc-reservdelar-section .product-item::before {
    background: linear-gradient(90deg, #dc3545, #ff6b6b);
}

.wc-tillbehor-section .product-item::before {
    background: linear-gradient(90deg, #28a745, #20c997);
}

.product-item:hover::before {
    opacity: 1;
}

.product-image {
    text-align: center;
    margin-bottom: 12px;
    position: relative;
    overflow: hidden;
    border-radius: 6px;
    flex-shrink: 0;
}

.product-image a {
    display: block;
    position: relative;
    width: 100%;
    height: 150px;
    overflow: hidden;
    border-radius: 6px;
    background-color: #f8f9fa;
}

.product-image img {
    width: 100%;
    height: 150px;
    object-fit: contain;
    transition: transform 0.3s ease;
    border-radius: 6px;
    background-color: #f8f9fa;
}

.product-item:hover .product-image img {
    transform: scale(1.03);
}

.product-content {
    text-align: left;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.product-title {
    font-size: 14px;
    font-weight: 500;
    margin: 0 0 8px 0;
    line-height: 1.3;
    flex-grow: 1;
}

.product-title a {
    color: #333;
    text-decoration: none;
    transition: color 0.3s ease;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.wc-reservdelar-section .product-title a:hover {
    color: #dc3545;
}

.wc-tillbehor-section .product-title a:hover {
    color: #28a745;
}

.product-price {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.wc-reservdelar-section .product-price {
    color: #dc3545;
}

.wc-tillbehor-section .product-price {
    color: #28a745;
}

.product-price .woocommerce-Price-amount {
    color: inherit;
}

.product-actions {
    margin-top: auto;
    flex-shrink: 0;
}

.product-add-to-cart {
    background: linear-gradient(135deg, #007cba, #00a0d2) !important;
    color: #fff !important;
    border: none !important;
    padding: 8px 16px !important;
    border-radius: 20px !important;
    font-weight: 500 !important;
    font-size: 12px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.3px !important;
    transition: all 0.3s ease !important;
    cursor: pointer !important;
    display: inline-block !important;
    text-decoration: none !important;
    min-width: 100px !important;
    width: 100% !important;
}

.wc-reservdelar-section .product-add-to-cart {
    background: linear-gradient(135deg, #dc3545, #ff6b6b) !important;
}

.wc-tillbehor-section .product-add-to-cart {
    background: linear-gradient(135deg, #28a745, #20c997) !important;
}

.product-add-to-cart:hover {
    transform: translateY(-1px) !important;
    box-shadow: 0 3px 10px rgba(0, 124, 186, 0.25) !important;
}

.wc-reservdelar-section .product-add-to-cart:hover {
    box-shadow: 0 3px 10px rgba(220, 53, 69, 0.25) !important;
}

.wc-tillbehor-section .product-add-to-cart:hover {
    box-shadow: 0 3px 10px rgba(40, 167, 69, 0.25) !important;
}

.product-add-to-cart:active {
    transform: translateY(0) !important;
}

/* Carousel Navigation */
.carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.carousel-nav:hover {
    background: #f8f9fa;
    border-color: #007cba;
    transform: translateY(-50%) scale(1.05);
}

.carousel-nav:active {
    transform: translateY(-50%) scale(0.95);
}

.carousel-prev {
    left: -20px;
}

.carousel-next {
    right: -20px;
}

.carousel-nav svg {
    width: 16px;
    height: 16px;
    color: #333;
    transition: color 0.3s ease;
}

.carousel-nav:hover svg {
    color: #007cba;
}

/* Carousel Dots */
.carousel-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 15px;
}

.carousel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: none;
    background: #e0e0e0;
    cursor: pointer;
    transition: all 0.3s ease;
}

.carousel-dot:hover {
    background: #007cba;
    transform: scale(1.2);
}

.carousel-dot.active {
    background: #007cba;
    transform: scale(1.3);
}

.wc-reservdelar-section .carousel-dot.active,
.wc-reservdelar-section .carousel-dot:hover {
    background: #dc3545;
}

.wc-tillbehor-section .carousel-dot.active,
.wc-tillbehor-section .carousel-dot:hover {
    background: #28a745;
}

/* Loading state */
.product-add-to-cart.loading {
    opacity: 0.7;
    cursor: not-allowed;
}

.product-add-to-cart.loading::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-left: 6px;
    border: 2px solid #fff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive design */
@media (max-width: 1200px) {
    .carousel-slide {
        width: calc(100% / 3);
    }
}

@media (max-width: 992px) {
    .carousel-slide {
        width: calc(100% / 2);
    }
    
    .carousel-title {
        font-size: 20px;
    }
    
    .carousel-nav {
        width: 35px;
        height: 35px;
    }
    
    .carousel-prev {
        left: -18px;
    }
    
    .carousel-next {
        right: -18px;
    }
}

@media (max-width: 768px) {
    .carousel-slide {
        width: calc(100% / 2);
    }
    
    .product-item {
        padding: 12px;
    }
    
    .carousel-title {
        font-size: 18px;
    }
    
    .carousel-nav {
        display: none;
    }
    
    .product-image a {
        height: 120px;
    }
    
    .product-image img {
        height: 120px;
    }
}

@media (max-width: 480px) {
    .carousel-slide {
        width: 100%;
    }
    
    .product-item {
        padding: 10px;
    }
    
    .carousel-title {
        font-size: 16px;
    }
    
    .product-image a {
        height: 100px;
    }
    
    .product-image img {
        height: 100px;
    }
}

/* Blocksy theme compatibility - match the constrained width */
.ct-container .wc-carousel-section {
    margin-left: auto;
    margin-right: auto;
    max-width: 1200px; /* Match typical content width */
    width: 100%;
    padding-left: 20px;
    padding-right: 20px;
}

/* Match the content width of other product blocks */
.woocommerce div.product .wc-carousel-section {
    max-width: 100%;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

/* Ensure carousel sections respect the same constraints as other content */
.entry-content .wc-carousel-section,
.woocommerce .wc-carousel-section {
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    margin-left: auto;
    margin-right: auto;
}

/* Match the width of other product content blocks */
.woocommerce div.product .summary .wc-carousel-section,
.woocommerce div.product .entry-summary .wc-carousel-section {
    max-width: 100%;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

/* Ensure carousel respects the same width constraints as product tabs */
.woocommerce-tabs .wc-carousel-section {
    max-width: 100%;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

/* Force carousel to inherit the same width constraints as parent content */
.is-width-constrained .wc-carousel-section {
    max-width: 100%;
    width: 100%;
    margin-left: 0;
    margin-right: 0;
}

/* Match the exact same styling as other content sections */
.wc-carousel-section {
    margin-left: auto;
    margin-right: auto;
    max-width: 100%;
    width: 100%;
}

/* Carousel elements inherit proper width from parent */
.woocommerce div.product .wc-carousel-section .carousel-container,
.woocommerce div.product .wc-carousel-section .carousel-wrapper,
.woocommerce div.product .wc-carousel-section .carousel-track {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
    box-sizing: border-box;
}

/* Carousel now inherits proper width from parent container */
.woocommerce div.product .wc-carousel-section {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
    box-sizing: border-box;
    overflow: hidden;
}

/* Hide default related products completely */
.woocommerce .woocommerce-product-rating + .woocommerce-tabs + .woocommerce-output-related-products,
.woocommerce .related.products,
.woocommerce .upsells.products {
    display: none !important;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .wc-carousel-section {
        border-top-color: #333;
    }
    
    .product-item {
        background: #1a1a1a;
        border-color: #333;
        color: #fff;
    }
    
    .product-title a {
        color: #fff;
    }
    
    .carousel-nav {
        background: #1a1a1a;
        border-color: #333;
    }
    
    .carousel-nav svg {
        color: #fff;
    }
}

/* Animation for when section loads */
.wc-carousel-section {
    animation: fadeInUp 0.4s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Ensure proper spacing with other WooCommerce elements */
.woocommerce div.product .wc-carousel-section {
    margin-top: 1.5em;
    max-width: 100%;
    width: 100%;
}

/* Force carousel to respect parent container width */
.wc-carousel-section {
    box-sizing: border-box;
    /* Inherit the same width constraints as parent content */
    width: 100%;
    max-width: inherit;
    margin-left: inherit;
    margin-right: inherit;
    /* Force it to stay within parent bounds */
    overflow: hidden;
    position: relative;
}

.carousel-container,
.carousel-wrapper,
.carousel-track {
    box-sizing: border-box;
    max-width: 100%;
    width: 100%;
}

/* Ensure product items don't exceed container width */
.carousel-slide {
    box-sizing: border-box;
    max-width: 100%;
}

.product-item {
    box-sizing: border-box;
    max-width: 100%;
}

/* Force carousel to match the width of other content sections */
.woocommerce div.product .wc-carousel-section {
    width: 100%;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    padding-left: 0;
    padding-right: 0;
    overflow: hidden;
    box-sizing: border-box;
    /* Match the same max-width as other content */
    max-width: 1200px;
}

/* Ensure carousel container respects the same width constraints */
.woocommerce div.product .wc-carousel-section .carousel-container {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
    box-sizing: border-box;
}

/* Touch/swipe support */
.carousel-track {
    touch-action: pan-y;
}

/* Smooth scrolling for carousel */
.carousel-wrapper {
    scroll-behavior: smooth;
}

/* Focus styles for accessibility */
.carousel-nav:focus,
.carousel-dot:focus,
.product-add-to-cart:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .product-item {
        border-width: 2px;
    }
    
    .carousel-nav {
        border-width: 2px;
    }
}