/**
 * WooCommerce Subcategory Slider Styles
 * File: assets/css/slider.css
 */

.subcategory-slider-wrapper {
    margin: 30px auto;
    position: relative;
    clear: both;
    max-width: 1200px; /* Giới hạn độ rộng tối đa */
/*     padding: 0 15px; */
}

.subcategory-header {
    text-align: center;
    margin-bottom: 30px;
}

.subcategory-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 10px;
    color: #333;
    line-height: 1.2;
}

.subcategory-description {
    font-size: 16px;
    color: #666;
    margin: 0;
    line-height: 1.5;
}

.subcategory-slider-container {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 8px 30px rgba(0,0,0,0.08);
}

.subcategory-slider {
    display: flex;
    transition: transform 0.3s ease;
    gap: 15px;
    padding: 20px;
    will-change: transform;
    min-height: 300px; /* Ensure minimum height */
}

/* Handle single item case */
.subcategory-slider .subcategory-item:only-child {
    max-width: 400px;
    margin: 0 auto;
    flex: 0 0 auto;
}

/* Hide navigation for single item */
.subcategory-slider-wrapper:has(.subcategory-item:only-child) .slider-btn,
.subcategory-slider-wrapper:has(.subcategory-item:only-child) .slider-dots {
    display: none !important;
}

.subcategory-item {
    flex: 0 0 calc(25% - 15px);
    min-width: 280px;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid #f0f0f0;
}

.subcategory-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.15);
    border-color: #007cba;
}

.subcategory-link {
    text-decoration: none;
    color: inherit;
    display: block;
    height: 100%;
}

.subcategory-image {
    height: 220px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    position: relative;
}

.subcategory-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.subcategory-item:hover .subcategory-image img {
    transform: scale(1.08);
}

.no-image-placeholder {
    width: 80px;
    height: 80px;
    background: rgba(0, 124, 186, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #007cba;
    font-size: 24px;
}

.subcategory-info {
    padding: 20px;
    text-align: center;
    background: #fff;
}

.subcategory-name {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: #333;
    line-height: 1.3;
    transition: color 0.3s ease;
}

.subcategory-item:hover .subcategory-name {
    color: #007cba;
}

.product-count {
    font-size: 14px;
    color: #666;
    font-weight: 400;
    display: block;
    margin-bottom: 8px;
}

.subcategory-excerpt {
    font-size: 13px;
    color: #888;
    line-height: 1.4;
    margin: 0;
}

/* Custom category content styles */
.custom-category-content {
    margin: 20px 0;
    padding: 25px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #007cba;
}

.custom-category-content h1 {
    color: #333;
    margin-bottom: 15px;
    font-size: 28px;
    font-weight: 700;
}

.custom-category-content p {
    color: #666;
    line-height: 1.6;
    margin-bottom: 15px;
}

.custom-category-content a {
    color: #007cba;
    text-decoration: none;
    font-weight: 500;
}

.custom-category-content a:hover {
    text-decoration: underline;
}

/* Screen reader only text */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.slider-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.95);
    border: 1px solid #ddd;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    color: #333;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.slider-btn:hover {
    background: #fff;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    color: #007cba;
    border-color: #007cba;
}

.slider-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.2);
}

.prev-btn {
    left: 10px;
}

.next-btn {
    right: 10px;
}

.slider-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(255,255,255,0.7);
}

.slider-btn:disabled:hover {
    background: rgba(255,255,255,0.7);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    color: #333;
    border-color: #ddd;
}

.slider-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
    padding: 0 20px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ddd;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.dot:hover {
    background: #bbb;
}

.dot.active {
    background: #007cba;
    transform: scale(1.2);
}

.dot:focus {
    outline: none;
    border-color: #007cba;
}

/* Loading state */
.subcategory-slider-wrapper.loading {
    opacity: 0.7;
    pointer-events: none;
}

.subcategory-slider-wrapper.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 100;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design - Điều chỉnh container width */
@media (max-width: 1400px) {
    .subcategory-slider-wrapper {
        max-width: 1000px;
    }
}

@media (max-width: 1200px) {
    .subcategory-slider-wrapper {
        max-width: 900px;
        padding: 0 20px;
    }
    
    .subcategory-item {
        flex: 0 0 calc(33.333% - 12px);
        min-width: 260px;
    }
    
    .subcategory-title {
        font-size: 26px;
    }
}

@media (max-width: 1024px) {
    .subcategory-slider-wrapper {
        max-width: 100%;
        padding: 0 15px;
    }
    
    .subcategory-item {
        flex: 0 0 calc(50% - 10px);
        min-width: 240px;
    }
    
    .subcategory-image {
        height: 180px;
    }
    
    .subcategory-title {
        font-size: 24px;
    }
}

@media (max-width: 768px) {
    .subcategory-slider-wrapper {
        margin: 20px auto;
        padding: 0 10px;
    }
    
    .subcategory-item {
        flex: 0 0 calc(100% - 0px);
        min-width: auto;
        max-width: 400px;
        margin: 0 auto;
    }
    
    .subcategory-image {
        height: 200px;
    }
    
    .subcategory-slider {
        padding: 15px;
        gap: 10px;
    }
    
    .subcategory-title {
        font-size: 22px;
    }
    
    .slider-btn {
        width: 40px;
        height: 40px;
        font-size: 14px;
    }
    
    .prev-btn {
        left: 5px;
    }
    
    .next-btn {
        right: 5px;
    }
}

@media (max-width: 480px) {
    .subcategory-item {
        flex: 0 0 calc(100% - 0px);
        min-width: auto;
    }
    
    .subcategory-slider {
        padding: 10px;
        gap: 0;
    }
    
    .subcategory-image {
        height: 180px;
    }
    
    .subcategory-title {
        font-size: 18px;
        margin-bottom: 15px;
    }
    
    .subcategory-info {
        padding: 12px;
    }
    
    .subcategory-name {
        font-size: 15px;
    }
    
    .product-count {
        font-size: 13px;
    }
}

/* RTL Support */
.rtl .prev-btn {
    right: 10px;
    left: auto;
}

.rtl .next-btn {
    left: 10px;
    right: auto;
}

.rtl .subcategory-slider {
    direction: rtl;
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .subcategory-item {
        border: 2px solid #000;
    }
    
    .slider-btn {
        border: 2px solid #000;
        background: #fff;
        color: #000;
    }
    
    .dot {
        border: 2px solid #000;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .subcategory-slider,
    .subcategory-item,
    .subcategory-image img,
    .slider-btn,
    .dot {
        transition: none;
    }
    
    .subcategory-item:hover {
        transform: none;
    }
    
    .subcategory-item:hover .subcategory-image img {
        transform: none;
    }
}

/* Print styles */
@media print {
    .subcategory-slider-wrapper {
        break-inside: avoid;
    }
    
    .slider-btn,
    .slider-dots {
        display: none;
    }
    
    .subcategory-slider {
        display: block;
    }
    
    .subcategory-item {
        display: inline-block;
        width: 48%;
        margin: 1%;
        break-inside: avoid;
    }
}