/**
 * Thanos Theme - Filter Bar Styles (Compact Version)
 *
 * All filters in a single row on desktop
 * @package Thanos_Theme
 */

/* ==========================================================================
   CSS Variables
   ========================================================================== */

.thanos-filter-bar {
    --filter-bg: var(--thanos-bg-card, #1a1a2e);
    --filter-border: var(--thanos-border, rgba(255, 255, 255, 0.1));
    --filter-input-bg: rgba(255, 255, 255, 0.05);
    --filter-input-bg-hover: rgba(255, 255, 255, 0.08);
    --filter-text: var(--thanos-text, #fff);
    --filter-text-muted: rgba(255, 255, 255, 0.6);
    --filter-primary: var(--thanos-primary, #e91e63);
    --filter-radius: 6px;
    --filter-radius-lg: 10px;
}

/* ==========================================================================
   Filter Bar Container - COMPACT DESKTOP LAYOUT
   ========================================================================== */

.thanos-filter-bar {
    background: var(--filter-bg);
    border-radius: var(--filter-radius-lg);
    padding: 12px 15px;
    margin-bottom: 20px;
    border: 1px solid var(--filter-border);
    position: relative;
    box-sizing: border-box;
}

/* ==========================================================================
   Mobile Header (Hidden on Desktop)
   ========================================================================== */

.thanos-filter-bar .thanos-filter-header {
    display: none !important;
}

.thanos-filter-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--filter-text);
}

.thanos-filter-header-title svg {
    width: 16px;
    height: 16px;
    opacity: 0.8;
}

.thanos-filter-header-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--filter-input-bg);
    border: 1px solid var(--filter-border);
    border-radius: var(--filter-radius);
    color: var(--filter-text-muted);
    font-size: 12px;
}

.thanos-filter-header-toggle svg {
    width: 14px;
    height: 14px;
    transition: transform 0.3s ease;
}

.thanos-filter-bar.filter-collapsed .thanos-filter-header-toggle svg {
    transform: rotate(180deg);
}

.thanos-filter-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--filter-primary);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 9px;
}

/* ==========================================================================
   Filter Content - SINGLE ROW FLEX LAYOUT
   ========================================================================== */

.thanos-filter-bar .thanos-filter-content {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

/* ==========================================================================
   Filter Rows - INLINE on Desktop
   ========================================================================== */

.thanos-filter-bar .thanos-filter-row {
    display: contents; /* Let children flow into parent flex */
}

/* ==========================================================================
   Filter Groups - Compact Inline
   ========================================================================== */

.thanos-filter-bar .thanos-filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* Hide labels on desktop for compact view */
.thanos-filter-bar .thanos-filter-label {
    display: none;
}

.thanos-filter-bar .thanos-filter-select {
    padding: 8px 30px 8px 12px;
    background-color: var(--filter-input-bg);
    border: 1px solid var(--filter-border);
    border-radius: var(--filter-radius);
    color: var(--filter-text);
    font-size: 13px;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.5)' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 14px;
    transition: border-color 0.2s ease, background-color 0.2s ease;
    box-sizing: border-box;
    min-width: 120px;
}

.thanos-filter-bar .thanos-filter-select:hover {
    border-color: var(--filter-primary);
    background-color: var(--filter-input-bg-hover);
}

.thanos-filter-bar .thanos-filter-select:focus {
    outline: none;
    border-color: var(--filter-primary);
    box-shadow: 0 0 0 2px rgba(233, 30, 99, 0.15);
}

.thanos-filter-bar .thanos-filter-select option {
    background: var(--filter-bg);
    color: var(--filter-text);
}

/* ==========================================================================
   Checkbox - Compact Inline
   ========================================================================== */

.thanos-filter-bar .thanos-filter-checkbox-group {
    flex-shrink: 0;
}

.thanos-filter-bar .thanos-filter-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 8px 12px;
    background: var(--filter-input-bg);
    border: 1px solid var(--filter-border);
    border-radius: var(--filter-radius);
    transition: all 0.2s ease;
    user-select: none;
    white-space: nowrap;
}

.thanos-filter-bar .thanos-filter-checkbox:hover {
    border-color: var(--filter-primary);
    background-color: var(--filter-input-bg-hover);
}

.thanos-filter-bar .thanos-filter-checkbox input[type="checkbox"] {
    display: none;
}

.thanos-filter-bar .thanos-filter-checkbox .checkbox-custom {
    width: 16px;
    height: 16px;
    border: 2px solid var(--filter-border);
    border-radius: 3px;
    position: relative;
    transition: all 0.2s ease;
    flex-shrink: 0;
    background: transparent;
}

.thanos-filter-bar .thanos-filter-checkbox:hover .checkbox-custom {
    border-color: var(--filter-primary);
}

.thanos-filter-bar .thanos-filter-checkbox input:checked + .checkbox-custom {
    background: var(--filter-primary);
    border-color: var(--filter-primary);
}

.thanos-filter-bar .thanos-filter-checkbox input:checked + .checkbox-custom::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 4px;
    height: 8px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.thanos-filter-bar .thanos-filter-checkbox .checkbox-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--filter-text);
}

/* ==========================================================================
   Advanced Filter - INLINE on same row
   ========================================================================== */

.thanos-filter-bar .thanos-filter-advanced {
    display: contents; /* Flow into parent flex */
}

/* Advanced content - INLINE on same row when expanded */
.thanos-filter-bar .thanos-filter-advanced-content {
    display: none;
}

.thanos-filter-bar .thanos-filter-advanced.expanded .thanos-filter-advanced-content {
    display: contents; /* Flow inline with other filters */
}

.thanos-filter-bar .thanos-filter-advanced-content .thanos-filter-row {
    display: contents;
}

.thanos-filter-bar .thanos-filter-advanced-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: transparent;
    border: 1px dashed var(--filter-border);
    border-radius: var(--filter-radius);
    color: var(--filter-text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    margin-left: auto; /* Push to right */
}

.thanos-filter-bar .thanos-filter-advanced-toggle:hover {
    background: var(--filter-input-bg);
    border-color: var(--filter-primary);
    border-style: solid;
    color: var(--filter-text);
}

.thanos-filter-bar .thanos-filter-advanced-toggle svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    opacity: 0.7;
}

.thanos-filter-bar .thanos-filter-advanced-toggle .toggle-arrow {
    transition: transform 0.3s ease;
}

.thanos-filter-bar .thanos-filter-advanced.expanded .thanos-filter-advanced-toggle {
    background: var(--filter-input-bg);
    border-style: solid;
    border-color: var(--filter-primary);
    color: var(--filter-text);
    /* Keep margin-left: auto to push toggle + actions to right */
}

.thanos-filter-bar .thanos-filter-advanced.expanded .thanos-filter-advanced-toggle .toggle-arrow {
    transform: rotate(180deg);
}

/* ==========================================================================
   Filter Actions - INLINE with filters
   ========================================================================== */

.thanos-filter-bar .thanos-filter-actions {
    display: contents; /* Flow into parent flex */
}

.thanos-filter-bar .thanos-filter-actions .thanos-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--filter-radius);
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
    white-space: nowrap;
}

.thanos-filter-bar .thanos-filter-actions .thanos-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.thanos-filter-bar .thanos-filter-actions .thanos-btn-primary {
    background: var(--filter-primary);
    color: #fff;
}

.thanos-filter-bar .thanos-filter-actions .thanos-btn-primary:hover {
    filter: brightness(1.1);
}

.thanos-filter-bar .thanos-filter-actions .thanos-btn-outline {
    background: transparent;
    color: var(--filter-text-muted);
    border: 1px solid var(--filter-border);
}

.thanos-filter-bar .thanos-filter-actions .thanos-btn-outline:hover {
    background: var(--filter-input-bg);
    color: var(--filter-text);
}

/* Hide filter count on desktop - too cluttered */
.thanos-filter-bar .thanos-filter-count {
    display: none;
}

/* ==========================================================================
   Filter Tags (Active Filters)
   ========================================================================== */

.thanos-filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 15px;
}

.filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px 4px 10px;
    background: var(--filter-input-bg, rgba(255, 255, 255, 0.05));
    color: var(--filter-text, #fff);
    border: 1px solid var(--filter-border, rgba(255, 255, 255, 0.1));
    border-radius: 50px;
    font-size: 12px;
    font-weight: 500;
}

.filter-tag .tag-remove {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--filter-primary, #e91e63);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1;
}

.filter-tag .tag-remove:hover {
    filter: brightness(0.85);
    transform: scale(1.1);
}

/* ==========================================================================
   Loading State
   ========================================================================== */

.thanos-filter-bar.loading {
    pointer-events: none;
    opacity: 0.7;
}

.thanos-filter-bar.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 15px;
    width: 20px;
    height: 20px;
    margin-top: -10px;
    border: 2px solid transparent;
    border-top-color: var(--filter-primary);
    border-radius: 50%;
    animation: filterSpin 0.8s linear infinite;
}

@keyframes filterSpin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   Visibility Classes
   ========================================================================== */

@media screen and (min-width: 769px) {
    .thanos-filter-bar.thanos-filter-hide-desktop {
        display: none !important;
    }
}

@media screen and (max-width: 768px) {
    .thanos-filter-bar.thanos-filter-hide-mobile {
        display: none !important;
    }
}

/* ==========================================================================
   Responsive - Tablet (max-width: 992px)
   ========================================================================== */

@media screen and (max-width: 992px) {
    .thanos-filter-bar .thanos-filter-select {
        min-width: 110px;
    }
}

/* ==========================================================================
   Responsive - Mobile (max-width: 768px)
   ========================================================================== */

@media screen and (max-width: 768px) {
    .thanos-filter-bar {
        padding: 15px;
    }

    /* Show mobile header */
    .thanos-filter-bar .thanos-filter-header {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 15px;
    }

    /* Collapse content on mobile */
    .thanos-filter-bar.filter-collapsed .thanos-filter-content {
        display: none !important;
    }

    .thanos-filter-bar.filter-collapsed .thanos-filter-header {
        margin-bottom: 0;
    }

    /* Stack filters vertically on mobile */
    .thanos-filter-bar .thanos-filter-content {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .thanos-filter-bar .thanos-filter-row {
        display: contents;
    }

    .thanos-filter-bar .thanos-filter-group {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
    }

    /* Show labels on mobile */
    .thanos-filter-bar .thanos-filter-label {
        display: block;
        font-size: 10px;
        font-weight: 600;
        color: var(--filter-text-muted);
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .thanos-filter-bar .thanos-filter-select {
        width: 100%;
        min-width: unset;
    }

    .thanos-filter-bar .thanos-filter-checkbox-group {
        grid-column: span 2;
    }

    .thanos-filter-bar .thanos-filter-checkbox {
        justify-content: center;
    }

    /* Advanced section full width */
    .thanos-filter-bar .thanos-filter-advanced {
        display: block;
        grid-column: span 2;
        margin-top: 5px;
        padding-top: 10px;
        border-top: 1px solid var(--filter-border);
    }

    .thanos-filter-bar .thanos-filter-advanced-toggle {
        width: 100%;
        justify-content: center;
    }

    .thanos-filter-bar .thanos-filter-advanced-content {
        margin-top: 10px;
        padding-top: 10px;
    }

    .thanos-filter-bar .thanos-filter-advanced.expanded .thanos-filter-advanced-content {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }

    /* Actions full width */
    .thanos-filter-bar .thanos-filter-actions {
        display: flex;
        grid-column: span 2;
        gap: 10px;
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid var(--filter-border);
    }

    .thanos-filter-bar .thanos-filter-actions .thanos-btn {
        flex: 1;
    }

    /* Show filter count on mobile */
    .thanos-filter-bar .thanos-filter-count {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        padding: 4px 10px;
        background: rgba(233, 30, 99, 0.15);
        color: var(--filter-primary);
        border-radius: 50px;
        font-size: 11px;
        font-weight: 600;
        margin-left: auto;
    }
}

/* ==========================================================================
   Responsive - Small Mobile (max-width: 480px)
   ========================================================================== */

@media screen and (max-width: 480px) {
    .thanos-filter-bar .thanos-filter-content {
        grid-template-columns: 1fr;
    }

    .thanos-filter-bar .thanos-filter-checkbox-group {
        grid-column: span 1;
    }

    .thanos-filter-bar .thanos-filter-advanced {
        grid-column: span 1;
    }

    .thanos-filter-bar .thanos-filter-advanced.expanded .thanos-filter-advanced-content {
        grid-template-columns: 1fr;
    }

    .thanos-filter-bar .thanos-filter-actions {
        grid-column: span 1;
        flex-direction: column;
    }
}

/* ==========================================================================
   Light Mode
   ========================================================================== */

[data-theme="light"] .thanos-filter-bar {
    --filter-bg: #ffffff;
    --filter-border: #e0e0e0;
    --filter-input-bg: #f5f5f5;
    --filter-input-bg-hover: #eeeeee;
    --filter-text: #333333;
    --filter-text-muted: #666666;
}

[data-theme="light"] .thanos-filter-bar .thanos-filter-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='rgba(0,0,0,0.5)' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

[data-theme="light"] .filter-tag {
    background: #f0f0f0;
    border-color: #ddd;
}
