/* =====================================================
   ETSY-STYLE SORT & FILTER UI
   =====================================================
   Clean, minimal design inspired by modern marketplaces
   ===================================================== */

/* =====================================================
   GRID HEADER CONTROLS - Etsy Layout
   ===================================================== */
.grid-header-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    padding: 0;
}

.grid-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.grid-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* =====================================================
   SHOW/HIDE FILTERS BUTTON (Etsy Style)
   ===================================================== */
.filter-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #fff;
    border: 1px solid #d4d4d4;
    border-radius: 24px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #222;
    transition: all 0.15s ease;
    font-family: inherit;
}

.filter-toggle-btn:hover {
    border-color: #222;
}

.filter-toggle-btn.active {
    background: #222;
    border-color: #222;
    color: #fff;
}

.filter-toggle-btn svg {
    width: 16px;
    height: 16px;
}

.filter-toggle-btn.active svg {
    stroke: #fff;
}

/* =====================================================
   DESKTOP SORT SELECTOR
   ===================================================== */
.etsy-sort-selector {
    position: relative;
    display: inline-block;
}

.etsy-sort-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #fff;
    border: 1px solid #d4d4d4;
    border-radius: 24px;
    cursor: pointer;
    font-size: 14px;
    color: #222;
    transition: all 0.15s ease;
    font-family: inherit;
}

.etsy-sort-trigger:hover {
    border-color: #222;
}

.etsy-sort-trigger.active {
    border-color: #222;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.etsy-sort-trigger .sort-text {
    font-weight: 400;
}

.etsy-sort-trigger .sort-text strong {
    font-weight: 600;
}

.etsy-sort-trigger .sort-chevron {
    transition: transform 0.2s ease;
    color: #666;
}

.etsy-sort-trigger.active .sort-chevron {
    transform: rotate(180deg);
}

/* Dropdown */
.etsy-sort-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
    z-index: 1000;
    overflow: hidden;
}

.etsy-sort-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.etsy-sort-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    color: #222;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.15s ease;
}

.etsy-sort-option:hover {
    background: #f5f5f5;
}

.etsy-sort-option.active {
    font-weight: 600;
    color: #1A6355;
}

.etsy-sort-option .option-check {
    color: #1A6355;
}

/* =====================================================
   MOBILE SORT BUTTON
   ===================================================== */
.etsy-sort-mobile-trigger {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid #d4d4d4;
    border-radius: 24px;
    font-size: 13px;
    font-weight: 500;
    color: #222;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}

.etsy-sort-mobile-trigger svg {
    color: #666;
    width: 14px;
    height: 14px;
}

/* =====================================================
   MOBILE BOTTOM SHEET
   ===================================================== */
.etsy-sort-sheet {
    position: fixed;
    inset: 0;
    z-index: 10000;
    pointer-events: none;
}

.etsy-sort-sheet.show {
    pointer-events: auto;
}

.etsy-sort-sheet .sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0);
    transition: background 0.3s ease;
}

.etsy-sort-sheet.show .sheet-backdrop {
    background: rgba(0,0,0,0.5);
}

.etsy-sort-sheet .sheet-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    max-height: 80vh;
    overflow-y: auto;
}

.etsy-sort-sheet.show .sheet-content {
    transform: translateY(0);
}

.etsy-sort-sheet .sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.etsy-sort-sheet .sheet-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #222;
}

.etsy-sort-sheet .sheet-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: #f5f5f5;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #666;
}

.etsy-sort-sheet .sheet-options {
    padding: 8px 0;
}

.etsy-sort-sheet .sheet-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    color: #222;
    text-decoration: none;
    font-size: 16px;
}

.etsy-sort-sheet .sheet-option:active {
    background: #f5f5f5;
}

.etsy-sort-sheet .sheet-option.active {
    font-weight: 600;
    color: #1A6355;
}

.etsy-sort-sheet .sheet-option svg {
    color: #1A6355;
}

.etsy-sort-sheet .sheet-info {
    padding: 16px 20px 24px;
    font-size: 13px;
    color: #666;
    background: #f9f9f9;
    border-top: 1px solid #eee;
}

.etsy-sort-sheet .sheet-info strong {
    color: #1A6355;
}

/* =====================================================
   ACTIVE FILTER CHIPS (Etsy Style)
   Shows selected filters with remove button
   ===================================================== */
.filter-chips-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 20px;
    margin-bottom: 16px;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: #e0e0e0;
    border: none;
    border-radius: 24px;
    font-size: 13px;
    font-weight: 500;
    color: #222;
    cursor: pointer;
    transition: all 0.15s ease;
}

.filter-chip:hover {
    background: #d0d0d0;
}

.filter-chip .chip-text {
    white-space: nowrap;
}

.filter-chip .chip-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: rgba(0,0,0,0.15);
    border-radius: 50%;
    transition: background 0.15s ease;
}

.filter-chip .chip-remove:hover {
    background: rgba(0,0,0,0.25);
}

.filter-chip .chip-remove svg {
    width: 10px;
    height: 10px;
    stroke: #222;
    stroke-width: 2.5;
}

/* Result count */
.filter-result-count {
    font-size: 13px;
    color: #595959;
    margin-left: 8px;
}

/* Reset link */
.filter-reset-link {
    font-size: 13px;
    color: #222;
    text-decoration: underline;
    cursor: pointer;
    margin-left: auto;
}

.filter-reset-link:hover {
    color: #000;
}

/* =====================================================
   GREEN SCORE BADGE (Search result pages)
   Note: .sustainability-badge styles moved to product-card-modern.css
   This class renamed to avoid conflicts with product card badges
   ===================================================== */
.green-score-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    z-index: 2;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.badge-green-premium {
    background: #1A6355;
}

.badge-green-verified {
    background: #4CAF50;
}

.badge-green-certified {
    background: #bf833a;
}

.badge-green-standard {
    display: none;
}

/* =====================================================
   FILTER FORM TOGGLE (Show/Hide)
   ===================================================== */
.responsive-filter {
    display: none;
    transition: all 0.3s ease;
}

.responsive-filter.show {
    display: block;
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 750px) {
    .etsy-sort-selector {
        display: none;
    }

    .etsy-sort-mobile-trigger {
        display: inline-flex;
    }

    .grid-header-controls {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        justify-content: space-between;
        padding: 0 12px;
        margin-bottom: 12px;
        gap: 8px;
        width: 100%;
        box-sizing: border-box;
    }

    .grid-header-left {
        flex: 0 0 auto;
        width: auto;
        margin-bottom: 0;
    }

    .grid-header-right {
        flex: 0 0 auto;
        width: auto;
        justify-content: flex-end;
    }

    .filter-toggle-btn {
        padding: 8px 12px;
        font-size: 13px;
        white-space: nowrap;
    }

    .filter-chip {
        padding: 6px 10px;
        font-size: 12px;
    }

    .green-score-badge {
        font-size: 10px;
        padding: 4px 8px;
    }
}

@media (min-width: 751px) {
    .etsy-sort-sheet {
        display: none !important;
    }
}

/* =====================================================
   ETSY-STYLE FILTER PANEL - Left Slide
   Inspired by Etsy's filter panel
   ===================================================== */

/* Filter Panel Overlay */
.filter-panel-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 9998;
    pointer-events: none;
    transition: background 0.3s ease;
}

.filter-panel-overlay.active {
    background: rgba(0, 0, 0, 0.5);
    pointer-events: auto;
}

/* Filter Panel Container */
.filter-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 340px;
    max-width: 90vw;
    height: 100vh;
    background: #fff;
    z-index: 9999;
    transform: translateX(-100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
}

.filter-panel.open {
    transform: translateX(0);
}

/* Filter Panel Header */
.filter-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid #e8e8e8;
    flex-shrink: 0;
}

.filter-panel-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #222;
}

.filter-panel-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: #f5f5f5;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #666;
    transition: all 0.15s ease;
}

.filter-panel-close:hover {
    background: #e8e8e8;
    color: #222;
}

.filter-panel-close svg {
    width: 20px;
    height: 20px;
}

/* Filter Panel Body - Scrollable */
.filter-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* Filter Section */
.filter-section {
    border-bottom: 1px solid #e8e8e8;
}

.filter-section:last-child {
    border-bottom: none;
}

/* Filter Section Header - Collapsible */
.filter-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease;
}

.filter-section-header:hover {
    background: #fafafa;
}

.filter-section-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #222;
}

.filter-section-header .section-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: #1A6355;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    margin-left: 8px;
}

.filter-section-header .chevron {
    width: 16px;
    height: 16px;
    color: #999;
    transition: transform 0.2s ease;
}

.filter-section.collapsed .filter-section-header .chevron {
    transform: rotate(-90deg);
}

/* Filter Section Content */
.filter-section-content {
    padding: 0 20px 18px;
    display: block;
}

.filter-section.collapsed .filter-section-content {
    display: none;
}

/* Filter Options List */
.filter-options {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.filter-option:hover {
    background: #f5f5f5;
}

.filter-option input[type="checkbox"],
.filter-option input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: #1A6355;
    cursor: pointer;
    flex-shrink: 0;
}

.filter-option-label {
    flex: 1;
    font-size: 14px;
    color: #222;
}

.filter-option-count {
    font-size: 12px;
    color: #999;
}

.filter-option.selected {
    background: #e8f4f0;
}

.filter-option.selected .filter-option-label {
    font-weight: 500;
    color: #1A6355;
}

/* Filter options with SVG icons */
.filter-option--with-icon {
    gap: 10px;
}

.filter-option-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    background: linear-gradient(135deg, #1A6355 0%, #2d8a6e 100%);
    border-radius: 50%;
    color: #fff;
}

.filter-option-icon svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
}

.filter-option.selected .filter-option-icon {
    background: linear-gradient(135deg, #1A6355 0%, #0f4a3f 100%);
    box-shadow: 0 2px 6px rgba(26, 99, 85, 0.3);
}

/* Price Range Filter */
.filter-price-range {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: nowrap;
}

.filter-price-input {
    flex: 1;
    min-width: 0;
    position: relative;
}

.filter-price-input input {
    width: 100%;
    padding: 10px 10px 10px 22px;
    border: 1px solid #d4d4d4;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s ease;
    box-sizing: border-box;
}

.filter-price-input input:focus {
    outline: none;
    border-color: #1A6355;
}

.filter-price-input .currency-symbol {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    color: #999;
    pointer-events: none;
}

.filter-price-separator {
    font-size: 14px;
    color: #999;
    flex-shrink: 0;
}

/* Price Apply Button */
.filter-price-apply {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    background: #1A6355;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.filter-price-apply:hover {
    background: #145349;
}

.filter-price-apply svg {
    stroke: #fff;
}

/* Search Within Filter */
.filter-search {
    position: relative;
    margin-bottom: 12px;
}

.filter-search input {
    width: 100%;
    padding: 12px 12px 12px 40px;
    border: 1px solid #d4d4d4;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s ease;
}

.filter-search input:focus {
    outline: none;
    border-color: #1A6355;
}

.filter-search .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: #999;
}

/* Show More Link */
.filter-show-more {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 0;
    font-size: 13px;
    font-weight: 500;
    color: #222;
    text-decoration: underline;
    cursor: pointer;
    background: none;
    border: none;
}

.filter-show-more:hover {
    color: #1A6355;
}

/* Filter Panel Footer */
.filter-panel-footer {
    display: flex;
    gap: 12px;
    padding: 20px;
    border-top: 1px solid #e8e8e8;
    background: #fff;
    flex-shrink: 0;
}

.filter-btn-reset {
    flex: 1;
    padding: 14px 20px;
    background: #fff;
    border: 1px solid #d4d4d4;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    color: #222;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s ease;
}

.filter-btn-reset:hover {
    border-color: #222;
}

.filter-btn-apply {
    flex: 1;
    padding: 14px 20px;
    background: #222;
    border: none;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s ease;
}

.filter-btn-apply:hover {
    background: #000;
}

/* Mobile Filter Bottom Sheet */
@media (max-width: 750px) {
    .filter-panel {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        height: auto;
        max-height: 85vh;
        transform: translateY(100%);
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
    }

    .filter-panel.open {
        transform: translateY(0);
    }

    .filter-panel-header {
        padding: 16px 20px;
    }

    .filter-panel-header::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: #ddd;
        border-radius: 2px;
    }

    .filter-panel-body {
        max-height: calc(85vh - 150px);
    }
}

/* =====================================================
   FILTER APPLIED INDICATOR
   ===================================================== */
.filter-toggle-btn .filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #1A6355;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    margin-left: 4px;
}

/* =====================================================
   LOADING STATE
   ===================================================== */
.filter-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.filter-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 2px solid #e8e8e8;
    border-top-color: #1A6355;
    border-radius: 50%;
    animation: filterSpin 0.8s linear infinite;
}

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