/* =================================
   PSM Sidebar Taxonomy Filters Widget
   ================================= */

/* Base Styles */
.psm-sidebar-filters {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px 20px 10px 20px !important;
    position: relative;
}

/* ULTIMATE comma/bullet removal - Override everything */
.psm-sidebar-filters * {
    list-style: none !important;
}

.psm-sidebar-filters ul,
.psm-sidebar-filters ol,
.psm-sidebar-filters li {
    list-style-type: none !important;
    list-style-position: outside !important;
    list-style-image: none !important;
    list-style: none !important;
    margin: 0 !important;
    padding-left: 0 !important;
}

.psm-sidebar-filters li::before,
.psm-sidebar-filters li::after,
.psm-sidebar-filters li::marker {
    content: none !important;
    display: none !important;
}

/* Force pointer cursor for all term links - Override any inline styles */
.psm-sidebar-filters .psm-term-link,
.psm-sidebar-filters a.psm-term-link {
    cursor: pointer !important;
}

/* NUCLEAR OPTION: Remove ALL content from pseudo-elements - BUT PRESERVE COLOR PREVIEW */
.psm-sidebar-filters .psm-term-item::before,
.psm-sidebar-filters .psm-term-item::after,
.psm-sidebar-filters .psm-term-link::before,
.psm-sidebar-filters .psm-term-link::after,
.psm-sidebar-filters .psm-term-name::before,
.psm-sidebar-filters .psm-term-name::after,
.psm-sidebar-filters .psm-term-count::before,
.psm-sidebar-filters .psm-term-count::after {
    content: "" !important;
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
}

/* Preserve color preview functionality */
.psm-color-preview {
    display: inline-block !important;
    visibility: visible !important;
    width: 16px !important;
    height: 16px !important;
}

/* Remove any automatic commas from WordPress or theme */
.psm-term-item,
.psm-term-item *,
.psm-term-link,
.psm-term-link *,
.psm-term-name {
    list-style: none !important;
}

.psm-term-item::before,
.psm-term-item::after,
.psm-term-link::before,
.psm-term-link::after,
.psm-term-name::before,
.psm-term-name::after {
    content: none !important;
    display: none !important;
}

/* Force remove all list-style elements */
.psm-terms-list,
.psm-terms-list li,
.psm-term-item {
    list-style-type: none !important;
    list-style-position: outside !important;
    list-style-image: none !important;
    list-style: none !important;
}

/* Remove pseudo-element content from WordPress/theme */
.psm-term-item::marker {
    content: none !important;
}

.psm-sidebar-filters ul,
.psm-sidebar-filters li {
    list-style: none !important;
}

/* Widget Title */
.psm-widget-title {
    margin: 0 0 20px 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
    text-align: left;
}

body.rtl .psm-widget-title {
    text-align: right;
}

/* Section Titles */
.psm-taxonomy-title {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin: 0 0 15px 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    user-select: none;
    text-align: left;
}

body.rtl .psm-taxonomy-title {
    justify-content: flex-start;
    text-align: right;
    direction: rtl;
}

.psm-title-content {
    display: flex;
    align-items: center;
    flex: 1;
    text-align: left;
}

body.rtl .psm-title-content {
    text-align: right;
}

.psm-title-icon {
    margin-right: 8px;
    color: #007cba;
    font-size: 14px;
}

body.rtl .psm-title-icon {
    margin-left: 8px;
    margin-right: 0;
}

/* Taxonomy Sections */
.psm-taxonomy-section {
    margin-bottom: 20px;
}

.psm-taxonomy-section:last-child {
    margin-bottom: 0;
}

/* Modern Container Structure - No UL/LI Issues */
.psm-terms-container,
.psm-terms-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.psm-term-item {
    margin-bottom: 2px;
    list-style: none !important;
}

/* Remove any list-style markers completely */
.psm-term-item::marker,
.psm-term-item::before {
    content: none !important;
    display: none !important;
}

/* Hierarchical Structure */
.psm-term-item.child-term {
    padding-left: 20px;
    position: relative;
}

/* RTL Support */
body.rtl .psm-term-item.child-term {
    padding-right: 20px;
    padding-left: 0;
}

.psm-hierarchy-icon {
    margin-right: 8px;
    color: #ccc;
    font-family: monospace;
    font-size: 12px;
}

body.rtl .psm-hierarchy-icon {
    margin-left: 8px;
    margin-right: 0;
    transform: scaleX(-1);
}

.psm-term-link {
    display: flex;
    align-items: center;
    padding: 8px 0;
    color: #666;
    text-decoration: none;
    font-size: 14px;
    border-radius: 4px;
    justify-content: flex-start;
    cursor: pointer !important;
}

/* RTL Text Alignment */
body.rtl .psm-term-link {
    justify-content: flex-start;
    text-align: right;
    direction: rtl;
}

.psm-term-link.active {
    color: #007cba;
    font-weight: 600;
}

.psm-term-name {
    flex: 1;
    text-align: left;
}

body.rtl .psm-term-name {
    text-align: right;
}

.psm-term-count {
    margin-left: 8px;
    font-size: 12px;
    color: #999;
    background-color: #f5f5f5;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 500;
}

body.rtl .psm-term-count {
    margin-right: 8px;
    margin-left: 0;
}

/* Color Preview */
.psm-color-preview {
    width: 16px !important;
    height: 16px !important;
    border-radius: 50%;
    margin-right: 8px;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    display: inline-block !important;
    visibility: visible !important;
}

body.rtl .psm-color-preview {
    margin-left: 8px;
    margin-right: 0;
}

.psm-color-shape-square .psm-color-preview {
    border-radius: 0;
}

.psm-color-shape-rounded .psm-color-preview {
    border-radius: 4px;
}

/* More Controls */
.psm-more-controls {
    margin-top: 10px;
    text-align: center;
}

.psm-show-more,
.psm-show-less {
    background: none;
    border: 1px solid #ddd;
    color: #666;
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 12px;
}

.psm-show-more:hover,
.psm-show-less:hover {
    background-color: #007cba;
    color: white;
    border-color: #007cba;
}

/* Reset Button */
.psm-reset-button {
    width: 100%;
    padding: 10px 20px;
    background: linear-gradient(135deg, #007cba 0%, #005a87 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    margin-top: 20px;
}

.psm-reset-button:hover {
    background: linear-gradient(135deg, #005a87 0%, #004666 100%);
}

/* =================================
   Style Presets
   ================================= */

/* Classic List Style */
.psm-sidebar-style-classic .psm-sidebar-filters {
    background: #fafafa;
    border: 1px solid #e0e0e0;
}

.psm-sidebar-style-classic .psm-term-link {
    border-bottom: 1px solid #eee;
    padding: 10px 0;
    margin-bottom: 0;
}

.psm-sidebar-style-classic .psm-term-link:last-child {
    border-bottom: none;
}

/* Modern Cards Style */
.psm-sidebar-style-modern .psm-taxonomy-section {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.psm-sidebar-style-modern .psm-term-link {
    background: #f8f9fa;
    margin-bottom: 5px;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer !important;
}

.psm-sidebar-style-modern .psm-term-link:hover {
    background: #e9ecef;
    border-color: #007cba;
    padding-left: 12px;
}

/* Minimal Lines Style */
.psm-sidebar-style-minimal .psm-sidebar-filters {
    background: transparent;
    border: none;
    padding: 0;
}

.psm-sidebar-style-minimal .psm-taxonomy-section {
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 20px;
    margin-bottom: 20px;
}

.psm-sidebar-style-minimal .psm-taxonomy-section:last-child {
    border-bottom: none;
}

.psm-sidebar-style-minimal .psm-taxonomy-title {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #999;
    margin-bottom: 10px;
}

.psm-sidebar-style-minimal .psm-term-link {
    padding: 6px 0;
    font-size: 13px;
}

/* Badge Style */
.psm-sidebar-style-badge .psm-terms-container,
.psm-sidebar-style-badge .psm-terms-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.psm-sidebar-style-badge .psm-term-link {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 12px;
    white-space: nowrap;
    cursor: pointer !important;
}

.psm-sidebar-style-badge .psm-term-link:hover {
    background: #e7e7e7;
    color: white;
    border-color: #e7e7e7;
    padding-left: 12px;
}

.psm-sidebar-style-badge .psm-term-count {
    background: rgba(255, 255, 255, 0.3);
    margin-left: 5px;
}

/* Accordion Style */
.psm-sidebar-style-accordion .psm-taxonomy-title {
    background: #000000;
    padding: 12px 15px;
    margin: 0 0 0 0;
    border-radius: 6px;
    border: 1px solid #000000;
    position: relative;
}

.psm-sidebar-style-accordion .psm-taxonomy-title:hover {
    background: #000000;
}

.psm-sidebar-style-accordion .psm-terms-container,
.psm-sidebar-style-accordion .psm-terms-list {
    background: #fff;
    border: 1px solid #e9ecef;
    border-top: none;
    border-radius: 0 0 6px 6px;
    padding: 10px 15px;
    margin-bottom: 10px;
}

.psm-sidebar-style-accordion .psm-term-link {
    padding: 5px 0;
}

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

/* Tablet */
@media (max-width: 1024px) {
    .psm-sidebar-filters {
        padding: 15px;
    }
    
    .psm-sidebar-style-badge .psm-terms-list {
        gap: 6px;
    }
    
    .psm-sidebar-style-badge .psm-term-link {
        font-size: 11px;
        padding: 5px 10px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .psm-sidebar-filters {
        padding: 12px;
    }
    
    .psm-widget-title {
        font-size: 16px;
        margin-bottom: 15px;
    }
    
    .psm-taxonomy-title {
        font-size: 14px;
    }
    
    .psm-term-link {
        font-size: 13px;
        padding: 6px 0;
    }
    
    .psm-reset-button {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    /* Mobile Optimized Badge Style */
    .psm-sidebar-style-badge .psm-terms-container,
    .psm-sidebar-style-badge .psm-terms-list {
        gap: 4px;
    }
    
    .psm-sidebar-style-badge .psm-term-link {
        font-size: 10px;
        padding: 4px 8px;
    }
    
    /* Collapse sections on mobile */
    .psm-taxonomy-sections {
        max-height: 400px;
        overflow-y: auto;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .psm-sidebar-filters {
        padding: 10px;
    }
    
    .psm-color-preview {
        width: 14px;
        height: 14px;
        margin-right: 6px;
    }
    
    .psm-term-count {
        font-size: 10px;
        padding: 1px 4px;
    }
    
    .psm-title-icon {
        margin-right: 6px;
        font-size: 12px;
    }
}

/* =================================
   Loading State
   ================================= */
.psm-sidebar-filters.loading {
    position: relative;
    pointer-events: none;
}

.psm-sidebar-filters.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

.psm-sidebar-filters.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 #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 10;
}

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

/* No Results Message */
.psm-no-results {
    text-align: center;
    color: #999;
    padding: 20px;
    font-style: italic;
    border: 1px dashed #ddd;
    border-radius: 6px;
    margin: 10px 0;
    background: #f9f9f9;
}

/* Search Loading Enhancement */
.psm-sidebar-filters.loading .psm-taxonomy-sections {
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .psm-term-link {
        border: 1px solid;
    }
    
    .psm-term-link:hover,
    .psm-term-link.active {
        background: #000;
        color: #fff;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .psm-term-link,
    .psm-terms-container,
    .psm-terms-list,
    .psm-reset-button {
        transition: none;
    }
    
    .psm-term-item {
        animation: none;
        opacity: 1;
    }
    
    .psm-term-link::before {
        display: none;
    }
}