/* ============================================
   FILTER & SORT STYLES
   Filter section, filter groups, sort controls,
   section headers
   ============================================ */

/* ---- Filter Section ---- */
.filter-section {
    background: linear-gradient(135deg, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0.85) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 25px;
    margin-bottom: 30px;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(139, 0, 0, 0.06), 0 1px 3px rgba(0,0,0,0.04);
    border: 1px solid rgba(139, 0, 0, 0.08);
    position: relative;
    z-index: 1;
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toggle-button {
    display: none;
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
}

.toggle-button:hover {
    background-color: var(--primary-dark);
    box-shadow: var(--shadow-sm);
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 20px;
    transition: var(--transition);
    max-height: 1000px;
    overflow: hidden;
}

.filter-group {
    flex: 1 1 200px;
    text-align: left;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--primary-color);
    font-size: 15px;
}

select, input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.2s ease;
    background-color: rgba(255, 255, 255, 0.9);
}

select:focus, input:focus {
    outline: none;
    border-color: #8B0000;
    box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.1), 0 2px 8px rgba(139, 0, 0, 0.1);
    background-color: #fff;
}

select:hover, input:hover {
    border-color: #bbb;
}

.filter-button {
    background: linear-gradient(135deg, #8B0000 0%, #a01020 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 12px rgba(139, 0, 0, 0.25);
}

.filter-button:hover {
    background: linear-gradient(135deg, #a01020 0%, #c01530 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(139, 0, 0, 0.35);
}

.filter-button:active {
    transform: translateY(0);
}

.filter-button-secondary {
    background-color: #666;
}

.filter-button-secondary:hover {
    background-color: #555;
}

/* ---- Sort Controls ---- */
.section-header-with-sort {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.section-header-with-sort h2 {
    margin: 0;
}

.sort-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sort-controls label {
    font-size: 14px;
    color: #666;
    font-weight: 500;
    white-space: nowrap;
}

.sort-controls select {
    padding: 8px 32px 8px 12px;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
    color: #333;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    min-width: 150px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.sort-controls select:hover {
    border-color: #8B0000;
}

.sort-controls select:focus {
    outline: none;
    border-color: #8B0000;
    box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.1);
}

/* ---- Emoji Legend ---- */
.emoji-legend {
    padding: 16px 24px;
    margin-bottom: 20px;
    text-align: center;
}

.emoji-legend .legend-title {
    font-size: 14px;
    font-weight: 600;
    color: #666;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.emoji-legend .legend-items {
    display: flex;
    justify-content: center;
    gap: 32px;
    flex-wrap: wrap;
}

.emoji-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.2s ease;
}

.emoji-legend .legend-item:hover {
    transform: scale(1.05);
}

.emoji-legend .legend-emoji {
    font-size: 20px;
}

.emoji-legend .legend-label {
    font-size: 14px;
    color: #555;
    font-weight: 500;
}

/* ---- Mobile Responsive ---- */
@media (max-width: 768px) {
    .filter-section {
        padding: 20px 15px;
        margin-bottom: 20px;
    }
    
    .toggle-button {
        display: block;
    }
    
    .filters {
        max-height: 0;
        opacity: 0;
        margin-top: 0;
        overflow: hidden;
        transition: all 0.3s ease;
    }
    
    .filters.active {
        max-height: 1000px;
        opacity: 1;
        margin-top: 15px;
    }
    
    .filter-group {
        margin-bottom: 15px;
        width: 100%;
    }
    
    .filter-group label {
        font-size: 14px;
        margin-bottom: 6px;
    }
    
    .filter-group select,
    .filter-group input {
        padding: 10px 12px;
        font-size: 14px;
    }
    
    .filter-button {
        width: 100%;
        padding: 14px;
        font-size: 16px;
    }
}

@media (max-width: 600px) {
    .section-header-with-sort {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .sort-controls {
        width: auto;
    }
    
    .sort-controls select {
        min-width: 140px;
    }

    .emoji-legend {
        padding: 12px 16px;
    }
    
    .emoji-legend .legend-items {
        gap: 16px;
    }
    
    .emoji-legend .legend-emoji {
        font-size: 18px;
    }
    
    .emoji-legend .legend-label {
        font-size: 12px;
    }
}

/* ---- Dark Theme ---- */
body.dark-theme .filter-section {
    background: #2d2d2d !important;
}

body.dark-theme .filter-section.section-box {
    background: #2d2d2d !important;
}

body.dark-theme label {
    color: #e0e0e0 !important;
}

body.dark-theme .filter-group label {
    color: #cccccc !important;
}

body.dark-theme .toggle-button {
    color: #e0e0e0 !important;
    background: #404040 !important;
    border-color: #555 !important;
}

body.dark-theme input, 
body.dark-theme select, 
body.dark-theme textarea {
    background-color: #404040 !important;
    color: #e0e0e0 !important;
    border: 1px solid #555555 !important;
}

body.dark-theme input::placeholder,
body.dark-theme select::placeholder,
body.dark-theme textarea::placeholder {
    color: #aaa !important;
}

body.dark-theme .sort-controls label {
    color: #aaa;
}

body.dark-theme .sort-controls select {
    background-color: #2a2a2a;
    border-color: #444;
    color: #eee;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23aaa' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

body.dark-theme .sort-controls select:hover,
body.dark-theme .sort-controls select:focus {
    border-color: #a50000;
}

body.dark-theme .emoji-legend .legend-label {
    color: #ccc;
}

/* ---- RTL Support ---- */
body.rtl .filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

body.rtl .filter-header h2 {
    order: 2;
    margin-left: auto;
    margin-right: 0;
}

body.rtl .filter-header .toggle-button {
    order: 1;
    margin-right: auto;
    margin-left: 0;
}

body.rtl .filter-group {
    text-align: left;
}

body.rtl input,
body.rtl select,
body.rtl textarea {
    text-align: left;
}
