/**
 * Safety Eye Guard Filters - Stylesheet
 * Redesigned to match reference image
 * Theme-independent with strong specificity to prevent conflicts
 * 
 * @package Safety_Eye_Guard_Filters
 */

/* ===========================
   Reset & Theme Override
   =========================== */
.segf-filters-wrapper,
.segf-filters-wrapper *,
.segf-filters-wrapper *::before,
.segf-filters-wrapper *::after {
    box-sizing: border-box !important;
    margin: 0 !important;
    padding: 0 !important;
}

.segf-filters-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif !important;
    font-size: 13px !important;
    line-height: 1.4 !important;
    color: #333 !important;
    text-align: left !important;
    direction: ltr !important;
}

.segf-filters-wrapper *,
.segf-filters-wrapper *::before,
.segf-filters-wrapper *::after {
    font-family: inherit !important;
    font-weight: inherit !important;
    font-style: normal !important;
    text-decoration: none !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    word-spacing: normal !important;
    line-height: inherit !important;
    border: none !important;
    outline: none !important;
    /* box-shadow: none !important; */
    background: none !important;
    color: inherit !important;
}

/* Reset buttons */
.segf-filters-wrapper button {
    display: inline-block !important;
    vertical-align: middle !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
}

/* ===========================
   Filter Container
   =========================== */
.segf-filters-wrapper {
    /* background: #f5f5f5 !important; */
    border: none !important;
    /* border-top: 1px solid #ddd !important; */
    border-bottom: 1px solid #ddd !important;
    margin-bottom: 30px !important;
    position: relative !important;
    /* z-index: 100 !important; */
    max-width: 100% !important;
    padding: 15px !important;
}

.segf-filters-wrapper.sticky {


    position: sticky !important;
    top: 0 !important;
    z-index: 10 !important;
    /* background: #f5f5f5 !important; */
    /* box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1) !important; */
}

/* ===========================
   Filter Tabs Row
   =========================== */
[data-segf-plugin="filters"] .segf-filter-tabs-row,
.segf-filters-wrapper .segf-filter-tabs-row {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px !important;
    flex-wrap: wrap !important;
    width: 100% !important;
    padding-left: 10px;
    padding-right: 10px;
}

/* Filter Item Wrapper */
.segf-filter-item {
    display: block !important;
    position: static !important; /* Crucial for absolute dropdown positioning on desktop */
}

/* FILTERS Label */
[data-segf-plugin="filters"] .segf-filters-label,
.segf-filters-wrapper .segf-filters-label {
    background: #000000 !important;
    color: #fff !important;
    padding: 10px 15px !important;
    font-weight: 700 !important;
    font-size: 13px !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    text-transform: uppercase !important;
    cursor: default !important;
    border: none !important;
    border-radius: 0 !important;
}

.segf-total-count {
    color: #ffffff !important; /* Orange count color */
    font-weight: 700 !important;
}

/* Mobile Toggle Button override for count color */
.segf-mobile-toggle-btn .segf-total-count {
    color: #000000 !important;
}

/* ===========================
   Filter Tabs (Dark Buttons)
   =========================== */
[data-segf-plugin="filters"] .segf-filter-tab,
.segf-filters-wrapper .segf-filter-tab {
    /* background: #333 !important; */
    color: #000000 !important;
    padding: 8px 14px !important;
    border: none !important;
    cursor: pointer !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.3px !important;
    transition: all 0.2s ease !important;
    white-space: nowrap !important;
    display: inline-block !important;
    margin: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    text-shadow: none !important;
}

[data-segf-plugin="filters"] .segf-filter-tab:hover,
.segf-filters-wrapper .segf-filter-tab:hover {
    background:  #788e62 !important;
    color: #fff !important;
}

[data-segf-plugin="filters"] .segf-filter-tab.active,
.segf-filters-wrapper .segf-filter-tab.active {
    background:  #788e62 !important;
    color: #fff !important;
}

/* ===========================
   Clear All Row
   =========================== */
.segf-clear-row {
    margin-top: 12px !important;
    display: none !important;
}

.segf-clear-row.show {
    display: block !important;
}

.segf-clear-all {
    padding: 6px 14px !important;
    background: transparent !important;
    color: #333 !important;
    border: none !important;
    cursor: pointer !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    text-decoration: underline !important;
    transition: color 0.2s ease !important;
    display: block !important;
}

.segf-clear-all:hover {
    color: #d32f2f !important;
}

/* ===========================
   Filter Dropdowns
   =========================== */
.segf-filter-dropdown {
    display: none !important;
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    background: #fff !important;
    border: 1px solid #ddd !important;
    border-top: none !important;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1) !important;
    max-height: 320px !important;
    overflow-y: auto !important;
    z-index: 1000 !important;
}

.segf-filter-dropdown.active {
    display: block !important;
}

.segf-filter-group {
    padding: 12px 14px !important;
}

.segf-filter-columns {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)) !important;
    gap: 8px !important;
}

/* ===========================
   Filter Options (Checkboxes)
   =========================== */
.segf-filter-option {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 5px 0 !important;
    cursor: pointer !important;
    transition: color 0.15s ease !important;
    margin: 0 !important;
    line-height: 1.3 !important;
    background: transparent !important;
    border: none !important;
}

.segf-filter-option:hover {
    color: #0073aa !important;
}

.segf-filter-option input[type="checkbox"] {
    width: 14px !important;
    height: 14px !important;
    min-width: 14px !important;
    max-width: 14px !important;
    min-height: 14px !important;
    max-height: 14px !important;
    cursor: pointer !important;
    accent-color: #0073aa !important;
    margin: 0 !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
    border: 1px solid #ccc !important;
    border-radius: 2px !important;
    background: #fff !important;
    vertical-align: middle !important;
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    transform: none !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.segf-filter-option label {
    cursor: pointer !important;
    font-size: 12px !important;
    color: #333 !important;
    flex: 1 !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1.3 !important;
    font-weight: 400 !important;
    background: transparent !important;
    border: none !important;
    text-align: left !important;
    width: auto !important;
    min-height: auto !important;
}

.segf-filter-option label::before,
.segf-filter-option label::after {
    display: none !important;
    content: none !important;
}

.segf-filter-option .term-count {
    font-size: 10px !important;
    color: #999 !important;
    margin-left: 4px !important;
    line-height: 1 !important;
    font-weight: 400 !important;
}

.segf-filter-option input[type="checkbox"]:checked+label {
    font-weight: 600 !important;
    color: #0073aa !important;
}

/* ===========================
   Loading State
   =========================== */
.segf-loading-overlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: rgba(255, 255, 255, 0.85) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 1000 !important;
}

.segf-spinner {
    width: 40px !important;
    height: 40px !important;
    border: 3px solid #f0f0f0 !important;
    border-top: 3px solid #0073aa !important;
    border-radius: 50% !important;
    animation: segf-spin 0.8s linear infinite !important;
}

@keyframes segf-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ===========================
   Responsive Design
   =========================== */


/* ===========================
   Mobile Responsive Toggle
   =========================== */
.segf-mobile-toggle-row {
    display: none !important;
    width: 100% !important;
    margin-bottom: 10px !important;
}

.segf-mobile-toggle-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    background: #fff !important;
    color: #333 !important;
    padding: 12px 16px !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    border: 1px solid #ddd !important;
    cursor: pointer !important;
    text-align: left !important;
}

.segf-mobile-toggle-btn::after {
    content: '\25BC' !important; /* Down arrow */
    font-size: 12px !important;
    font-weight: normal !important;
    transform: rotate(0deg);
    transition: transform 0.3s ease;
}

.segf-mobile-toggle-btn.active::after {
    content: '\25BC' !important;
    transform: rotate(180deg);
}

/* Tablet */
@media (max-width: 1024px) {
    .segf-filter-tab {
        padding: 7px 12px !important;
        font-size: 10px !important;
    }

    .segf-filter-columns {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
        gap: 6px !important;
    }

    .segf-filter-option label {
        font-size: 11px !important;
    }
}

/* Mobile - Only for small mobile devices */
@media (max-width: 767px) {
    .segf-filters-wrapper {
        padding: 10px !important;
    }
    
    .segf-mobile-toggle-row {
        display: block !important;
    }

    /* Hide the default desktop label on mobile */
    [data-segf-plugin="filters"] .segf-filters-label,
    .segf-filters-wrapper .segf-filters-label {
        display: none !important;
    }

    /* Hide tabs row initially on mobile with high specificity */
    [data-segf-plugin="filters"] .segf-filter-tabs-row,
    .segf-filters-wrapper .segf-filter-tabs-row {
        display: none !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0 !important; /* Remove gap for seamless accordion */
        width: 100% !important;
        padding: 0 !important;
        border: 1px solid #ddd !important;
        border-top: none !important;
    }
    
    /* Show tabs row when active */
    [data-segf-plugin="filters"] .segf-filter-tabs-row.active,
    .segf-filters-wrapper .segf-filter-tabs-row.active {
        display: flex !important;
    }

    .segf-filter-item {
        width: 100% !important;
        border-bottom: 1px solid #ddd !important;
    }

    .segf-filter-tab {
        padding: 12px 16px !important;
        justify-content: space-between !important;
        font-size: 13px !important;
        width: 100% !important;
        text-align: left !important;
        background: #f9f9f9 !important;
        border: none !important; /* Border handled by item wrapper */
        color: #333 !important;
        margin: 0 !important;
    }
    
    .segf-filter-tab::after {
        content: '\25BC' !important; /* Down arrow */
        float: right !important;
        font-size: 10px !important;
        font-weight: normal !important;
        margin-top: 4px !important;
        transform: rotate(0deg);
        transition: transform 0.3s ease;
    }
    
    .segf-filter-tab.active::after {
        content: '\25BC' !important;
        transform: rotate(180deg);
    }

    .segf-clear-row {
        margin-top: 10px !important;
        text-align: left !important;
    }

    .segf-clear-all {
        display: inline-block !important;
        padding-left: 0 !important;
    }

    /* Dropdown styling for mobile accordion effect */
    .segf-filter-dropdown {
        position: static !important; /* Flow naturally in document */
        max-height: none !important;
        box-shadow: none !important;
        border: none !important;
        border-top: 1px solid #eee !important;
        display: none !important;
        width: 100% !important;
        top: auto !important;
        background: #fff !important;
    }
    
    .segf-filter-dropdown.active {
        display: block !important;
        animation: none !important;
    }

    .segf-filter-group {
        padding: 10px 15px !important;
        background: #fff !important;
    }

    .segf-filter-columns {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }
    
    .segf-filter-option {
        padding: 6px 0 !important;
    }
}

@media (max-width: 480px) {
    .segf-filter-tab {
        font-size: 10px !important;
        padding: 9px 10px !important;
    }

    .segf-filter-group {
        padding: 8px 10px !important;
    }

    .segf-filter-option {
        padding: 4px 0 !important;
    }

    .segf-filter-option label {
        font-size: 11px !important;
    }

    .segf-filter-option input[type="checkbox"] {
        width: 13px !important;
        height: 13px !important;
        min-width: 13px !important;
    }
}

/* ===========================
   Theme Compatibility
   =========================== */

/* Ensure proper spacing with WooCommerce elements */
.woocommerce-products-header+.segf-filters-wrapper {
    margin-top: 20px;
}

.segf-filters-wrapper+.woocommerce-notices-wrapper {
    margin-top: 20px;
}

/* Compatibility with Astra/Avanam themes */
.ast-container .segf-filters-wrapper,
.avanam-container .segf-filters-wrapper {
    max-width: 100%;
}

/* ===========================
   Accessibility
   =========================== */
.segf-filter-tab:focus,
.segf-filter-option input:focus,
.segf-clear-all:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.segf-filter-option input:focus+label {
    color: #0073aa;
}

/* ===========================
   Print Styles
   =========================== */
@media print {
    .segf-filters-wrapper {
        display: none;
    }
}

/* ===========================
   Additional UI Enhancements
   =========================== */

/* Scrollbar styling for dropdown */
.segf-filter-dropdown::-webkit-scrollbar {
    width: 6px !important;
}

.segf-filter-dropdown::-webkit-scrollbar-track {
    background: #f5f5f5 !important;
}

.segf-filter-dropdown::-webkit-scrollbar-thumb {
    background: #bbb !important;
    border-radius: 3px !important;
}

.segf-filter-dropdown::-webkit-scrollbar-thumb:hover {
    background: #999 !important;
}

/* No results message */
.segf-no-results {
    padding: 30px 16px !important;
    text-align: center !important;
    color: #666 !important;
    font-size: 13px !important;
    line-height: 1.4 !important;
}

/* Animation for dropdown */
@keyframes segf-slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.segf-filter-dropdown.active {
    animation: segf-slideDown 0.3s ease;
}