/**
 * Custom Filter Block Styles
 */

/* Main wrapper */
.custom-filter-wrapper {
    background: #fff;
    border-radius: 8px;
}

/* Title */
.custom-filter-title {
    margin: 0 0 15px 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
    text-align: center;
}

/* Switch container */
.custom-switch-container {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
}

/* Custom radio switch styling - MAXIMUM SPECIFICITY */
.custom-filter-wrapper .custom-switch-container .custom-switch {
    position: relative !important;
    width: 240px !important;
    height: 35px !important;
    background: #8dc63f5c !important;
    border-radius: 18px !important;
    border: 1px solid #0d81429e !important;
    overflow: hidden !important;
    cursor: pointer !important;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
    transform: translateZ(0); /* Enable hardware acceleration */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.custom-filter-wrapper .custom-switch-container .custom-switch:hover {
    border-color: #0d8142 !important;
    transform: translateZ(0) scale(1.02) !important;
}

/* Hide default radio buttons */
.custom-filter-wrapper .custom-switch-container .custom-switch input[type="radio"] {
    display: none !important;
}

/* Switch labels */
.custom-filter-wrapper .custom-switch-container .custom-switch .switch-label {
    position: absolute !important;
    top: 0 !important;
    height: 100% !important;
    line-height: 35px !important;
    text-align: center !important;
    cursor: pointer !important;
    z-index: 2 !important;
    font-weight: 600 !important;
    font-size: 12px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    color: #0d8142 !important;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
    margin: 0 !important;
    padding: 0 5px !important;
    user-select: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
}

/* Icon styles */
.switch-icon {
    width: 14px !important;
    height: 14px !important;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
    opacity: 0.7 !important;
}

.switch-label.active .switch-icon {
    opacity: 1 !important;
    transform: scale(1.1) !important;
}

/* Active state styles */
.custom-filter-wrapper .custom-switch-container .custom-switch .switch-label.active {
    color: #fff !important;
    transform: scale(1.05) !important;
}

/* Position labels correctly */
.custom-filter-wrapper .custom-switch-container .custom-switch .switch-left {
    left: 0 !important;
    width: 50% !important;
}

.custom-filter-wrapper .custom-switch-container .custom-switch .switch-right {
    right: 0 !important;
    width: 50% !important;
}

/* Active label - MAXIMUM SPECIFICITY */
.custom-filter-wrapper .custom-switch-container .custom-switch input[type="radio"]:checked + .switch-label {
    color: #fff !important;
}

/* Ensure default state (o-nha) is properly styled on page load */
.custom-filter-wrapper .custom-switch-container .custom-switch input[type="radio"][value="o-nha"]:checked + .switch-label {
    color: #fff !important;
}

.custom-filter-wrapper .custom-switch-container .custom-switch input[type="radio"][value="mang-di"]:checked + .switch-label {
    color: #fff !important;
}

/* Switch slider (background) */
.custom-filter-wrapper .custom-switch-container .custom-switch .switch-slider {
    position: absolute !important;
    top: 2px !important;
    left: 2px !important;
    width: calc(50% - 4px) !important;
    height: calc(100% - 4px) !important;
    background: linear-gradient(135deg, #2d8659 0%, #369962 100%) !important;
    border-radius: 16px !important;
    transition: all 0.35s cubic-bezier(0.68, -0.55, 0.265, 1.55) !important;
    z-index: 1 !important;
}

/* When "o-nha" is checked (left side active - default) */
.custom-filter-wrapper .custom-switch-container .custom-switch input[type="radio"][value="o-nha"]:checked ~ .switch-slider {
    left: 2px !important;
    background: linear-gradient(135deg, #2d8659 0%, #369962 100%) !important;
}

/* When "mang-di" is checked (right side active) */
.custom-filter-wrapper .custom-switch-container .custom-switch input[type="radio"][value="mang-di"]:checked ~ .switch-slider {
    left: calc(50% + 2px) !important;
    background: linear-gradient(135deg, #8dc540 0%, #9ed14f 100%) !important;
}

/* Ensure proper spacing */
.custom-switch {
    display: inline-block;
}

/* Initial active state - HIGHEST SPECIFICITY */
.custom-filter-wrapper .custom-switch-container .custom-switch .initial-active {
    color: #fff !important;
}

/* Force styling for initial state */
.custom-filter-wrapper .custom-switch-container .custom-switch input[type="radio"]:checked + .switch-label,
.custom-filter-wrapper .custom-switch-container .custom-switch input[type="radio"][value="o-nha"]:checked + .switch-label,
.custom-filter-wrapper .custom-switch-container .custom-switch input[type="radio"][value="mang-di"]:checked + .switch-label {
    color: #fff !important;
    transform: scale(1.05) !important;
}

/* iPhone-like press effect */
.custom-filter-wrapper .custom-switch-container .custom-switch:active {
    transform: translateZ(0) scale(0.98) !important;
    transition: transform 0.1s ease !important;
}

/* Enhanced hover effects */
.custom-filter-wrapper .custom-switch-container .custom-switch .switch-label:hover {
    transform: scale(1.1) !important;
    transition: transform 0.2s ease !important;
}

.custom-filter-wrapper .custom-switch-container .custom-switch .switch-label:active {
    transform: scale(0.95) !important;
    transition: transform 0.1s ease !important;
}

/* Add subtle pulse animation to active label */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.8; }
    100% { opacity: 1; }
}

.custom-filter-wrapper .custom-switch-container .custom-switch input[type="radio"]:checked + .switch-label {
    animation: pulse 0.3s ease-in-out !important;
}

/* Smooth background transitions */
.custom-filter-wrapper .custom-switch-container .custom-switch {
    transition: background 0.3s ease, border-color 0.3s ease, transform 0.3s ease !important;
}

/* Remove margins from labels */
.custom-switch .switch-label {
    margin: 0;
    padding: 0;
}

/* Products container */
.filtered-products-container {
    position: relative;
    min-height: 200px;
    transition: opacity 0.3s ease;
}

.filtered-products-container.loading {
    opacity: 0.6;
}

.filtered-products-container.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #2d8659;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 10;
}

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

/* Loading message */
.loading-message {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* UX Builder Row Styling - Minimal intervention */
.row.o-nha,
.row.mang-di {
    display: none; /* Initially hidden, will be shown by JavaScript */
}

/* Ensure rows are visible when activated */
.row.o-nha.active,
.row.mang-di.active {
    display: flex; /* Or whatever display type Flatsome uses */
}

/* Flickity Page Dots - Continuous Rectangle Bar Style */
.flickity-page-dots {
    bottom: 20px !important;
    display: flex !important;
    justify-content: center !important;
    gap: 0 !important; /* No gap - continuous bars */
    padding: 0 20px !important;
}

.flickity-page-dots .dot {
    width: 60px !important; /* Longer bars */
    height: 4px !important;
    border-radius: 0 !important; /* No border radius for continuous look */
    background: #ddd !important;
    opacity: 0.6 !important;
    transition: all 0.3s ease !important;
    margin: 0 !important;
    border: none !important;
}

/* Active dot - gray color */
.flickity-page-dots .dot.is-selected {
    background: #646464 !important;
    opacity: 1 !important;
    transform: none !important; /* No scale - just color change */
}

/* Hover effects */
.flickity-page-dots .dot:hover {
    background: #646464 !important;
    opacity: 0.8 !important;
    transform: none !important;
}

/* Mobile responsive */
@media (max-width: 767px) {
    .flickity-page-dots {
        bottom: 15px !important;
        gap: 0 !important; /* No gap on mobile */
        padding: 0 15px !important;
    }

    .flickity-page-dots .dot {
        width: 45px !important; /* Still longer on mobile */
        height: 3px !important;
        border-radius: 0 !important; /* No border radius on mobile */
    }
}

/* Shopee Button Hover Effects - Red Background */
.shopee-btn {
    transition: all 0.3s ease !important;
}

.shopee-btn:hover {
    background: #ee4d2d !important; /* Shopee red background */
    border-color: #ee4d2d !important;
    color: #ffffff !important; /* White text */
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(238, 77, 45, 0.4) !important;
}

/* Shopee Button Icon Hover - White Icon (for PNG) */
.shopee-btn:hover .icon {
    transform: scale(1.1) !important;
}

.shopee-btn:hover .icon img {
    filter: brightness(0) invert(1) !important; /* Convert PNG to white */
    transform: scale(1.1) !important;
}

/* Alternative for PNG icons - use opacity/contrast */
.shopee-btn:hover .icon img.shopee-icon {
    filter: brightness(0) invert(1) !important;
    opacity: 1 !important;
}

/* Shopee Button Text Hover - White Text */
.shopee-btn:hover .button-text {
    color: #ffffff !important; /* White text */
}

/* Alternative red bar version for Shopee buttons */
.shopee-btn.red-bar:hover {
    background: linear-gradient(90deg, #ee4d2d 0%, #ff5a3c 100%) !important; /* Red gradient */
    border: 2px solid #ee4d2d !important;
}

.shopee-btn.red-bar:hover::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 3px;
    background: #ffffff; /* White bar */
    border-radius: 2px;
}

/* Shopee style icon with red background on hover */
.shopee-btn-icon:hover {
    background: #ee4d2d !important; /* Red background */
    border-radius: 50% !important;
    width: 50px !important;
    height: 50px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 4px 12px rgba(238, 77, 45, 0.4) !important;
}

/* PNG icon hover effects */
.shopee-btn-icon:hover img {
    filter: brightness(0) invert(1) !important; /* Convert PNG to white */
    transform: scale(1.2) !important;
}

/* Additional PNG icon hover variations */
.shopee-btn:hover img.shopee-icon {
    filter: brightness(0) invert(1) !important;
}

.shopee-btn:hover .icon img {
    filter: brightness(0) invert(1) !important;
}

/* SVG/Font icon fallback */
.shopee-btn:hover svg {
    color: #ffffff !important;
    fill: #ffffff !important;
}

.shopee-btn:hover i {
    color: #ffffff !important;
}

.shopee-btn:hover .fa,
.shopee-btn:hover .fas,
.shopee-btn:hover .far {
    color: #ffffff !important;
}

/* Responsive design */
@media (max-width: 768px) {
    .custom-filter-wrapper .custom-switch-container .custom-switch {
        width: 180px !important;
        height: 32px !important;
        border-radius: 16px !important;
    }

    .custom-filter-wrapper .custom-switch-container .custom-switch .switch-label {
        font-size: 11px !important;
        line-height: 32px !important;
    }

    .custom-filter-wrapper .custom-switch-container .custom-switch .switch-slider {
        width: calc(50% - 4px) !important;
        height: calc(100% - 4px) !important;
        top: 2px !important;
        left: 2px !important;
        border-radius: 14px !important;
    }

    .custom-filter-wrapper .custom-switch-container .custom-switch input[type="radio"][value="mang-di"]:checked ~ .switch-slider {
        left: calc(50% + 2px) !important;
    }
}

@media (max-width: 480px) {
    .custom-filter-title {
        font-size: 16px !important;
    }

    .custom-filter-wrapper .custom-switch-container .custom-switch {
        width: 190px !important;
        height: 28px !important;
        border-radius: 14px !important;
    }

    .custom-filter-wrapper .custom-switch-container .custom-switch .switch-label {
        font-size: 10px !important;
        line-height: 28px !important;
    }

    .custom-filter-wrapper .custom-switch-container .custom-switch .switch-slider {
        width: calc(50% - 3px) !important;
        height: calc(100% - 3px) !important;
        top: 1.5px !important;
        left: 1.5px !important;
        border-radius: 12px !important;
    }

    .custom-filter-wrapper .custom-switch-container .custom-switch input[type="radio"][value="mang-di"]:checked ~ .switch-slider {
        left: calc(50% + 1.5px) !important;
    }
}

/* No products found message */
.no-products-found {
    text-align: center;
    padding: 40px 20px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    margin: 30px 0;
}

.no-products-icon {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.6;
}

.no-products-message {
    font-size: 18px;
    font-weight: 500;
    color: #666;
    margin: 0 0 10px 0;
}

.no-products-hint {
    font-size: 14px;
    color: #999;
    margin: 0;
}

/* Smooth transitions */
.filtered-products-grid .product-small {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.filtered-products-grid .product-small:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Toggle descriptions */
.toggle-descriptions {
    text-align: center;
    margin: 20px 0 30px 0;
    padding: 0;
}

.toggle-description {
    font-size: 14px;
    line-height: 1.5;
    color: #666;
    margin: 0;
    padding: 15px 300px;
    transition: all 0.3s ease;
    display: none;
}

.toggle-description.active {
    display: block;
    animation: fadeIn 0.5s ease-in-out;
}

/* Color-coded descriptions - no background, no border */
.toggle-description.o-nha {
    /* No background or border */
}

.toggle-description.mang-di {
    /* No background or border */
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive design for descriptions */
@media (max-width: 768px) {
    .toggle-description {
        font-size: 13px;
        padding: 12px 50px;
    }
}

@media (max-width: 480px) {
    .toggle-description {
        font-size: 12px;
        padding: 10px 20px;
    }
}

@media (max-width: 320px) {
    .toggle-description {
        font-size: 11px;
        padding: 8px 10px;
    }
}