/**
 * تنسيقات الفلاتر والبحث - Egypt Projects Map
 * 
 * @package Egypt_Projects_Map
 * @since   1.2.0
 */

/* استيراد خط Tajawal */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700&display=swap');

/* ========================================
   شريط الفلاتر الرئيسي
======================================== */
.filters-bar {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    padding: 20px;
    margin-bottom: 20px;
    direction: rtl;
    transition: all 0.3s ease;
}

.filters-bar.filtering {
    opacity: 0.7;
    pointer-events: none;
}

.filters-bar.has-filters {
    border: 2px solid #667eea;
}

/* ========================================
   رأس الفلاتر
======================================== */
.filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.filters-title {
    font-size: 18px;
    font-weight: 700;
    color: #1e1e1e;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.filters-title-icon {
    font-size: 20px;
}

.filters-toggle-btn {
    display: none;
    background: #667eea;
    color: #ffffff;
    border: none;
    padding: 8px 15px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filters-toggle-btn:hover {
    background: #5568d3;
}

.filters-toggle-btn.active {
    background: #764ba2;
}

/* ========================================
   محتوى الفلاتر
======================================== */
.filters-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-label {
    font-size: 13px;
    font-weight: 600;
    color: #646970;
    display: flex;
    align-items: center;
    gap: 5px;
}

.filter-label-icon {
    font-size: 14px;
}

.filter-select,
.filter-input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Tajawal', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    transition: all 0.3s ease;
    background: #ffffff;
    direction: rtl;
}

.filter-select:focus,
.filter-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.filter-select:hover,
.filter-input:hover {
    border-color: #667eea;
}

/* ========================================
   صندوق البحث
======================================== */
.filter-search-wrapper {
    position: relative;
}

.filter-search {
    padding-right: 40px;
}

.filter-search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: #646970;
    pointer-events: none;
}

.filter-search:focus + .filter-search-icon {
    color: #667eea;
}

/* ========================================
   تذييل الفلاتر
======================================== */
.filters-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

.filters-results-count {
    font-size: 14px;
    font-weight: 600;
    color: #646970;
}

.filters-results-count .count-number {
    font-size: 18px;
    font-weight: 700;
    color: #667eea;
    margin-left: 5px;
}

.filters-results-count .no-results {
    color: #d63638;
}

.filters-results-count .error {
    color: #d63638;
}

/* ========================================
   أزرار التحكم
======================================== */
.filters-actions {
    display: flex;
    gap: 10px;
}

.filters-reset-btn,
.filters-apply-btn {
    padding: 8px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.filters-reset-btn {
    background: #f0f0f1;
    color: #1e1e1e;
}

.filters-reset-btn:hover {
    background: #dcdcde;
}

.filters-reset-btn.success {
    background: #00a32a;
    color: #ffffff;
}

.filters-apply-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
}

.filters-apply-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* ========================================
   حالة التحميل
======================================== */
.filters-loading {
    display: none;
    text-align: center;
    padding: 10px;
    color: #667eea;
    font-size: 14px;
    font-weight: 600;
}

.filters-loading:before {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-left: 8px;
    border: 2px solid #f0f0f1;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ========================================
   رسالة "لا توجد نتائج" المحسنة
======================================== */
.no-projects {
    text-align: center;
    padding: 60px 20px;
}

.no-projects-icon {
    font-size: 60px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.no-projects p {
    color: #646970;
    font-size: 16px;
    margin: 0 0 20px 0;
}

.btn-reset-inline {
    padding: 10px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-reset-inline:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* ========================================
   شارة "فلاتر نشطة"
======================================== */
.filters-active-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: #e7f3ff;
    color: #0071a1;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    margin-right: 10px;
}

.filters-active-badge-icon {
    font-size: 14px;
}

/* ========================================
   Responsive - Tablet
======================================== */
@media screen and (max-width: 1024px) {
    .filters-content {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ========================================
   Responsive - Mobile
======================================== */
@media screen and (max-width: 768px) {
    
    .filters-bar {
        padding: 15px;
    }

    /* عرض زر Toggle */
    .filters-toggle-btn {
        display: block;
    }

    /* إخفاء المحتوى افتراضياً */
    .filters-content {
        display: none;
        grid-template-columns: 1fr;
        margin-top: 15px;
    }

    .filters-content.open {
        display: grid;
    }

    /* تكبير الحقول على الموبايل */
    .filter-select,
    .filter-input {
        padding: 12px 14px;
        font-size: 16px; /* منع التكبير التلقائي على iOS */
    }

    /* تعديل التذييل */
    .filters-footer {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }

    .filters-results-count {
        text-align: center;
        padding: 10px;
        background: #f0f0f1;
        border-radius: 6px;
    }

    .filters-actions {
        width: 100%;
    }

    .filters-reset-btn,
    .filters-apply-btn {
        flex: 1;
        justify-content: center;
    }

    /* تحسين رسالة "لا توجد نتائج" */
    .no-projects {
        padding: 40px 15px;
    }

    .no-projects-icon {
        font-size: 50px;
    }

}

/* ========================================
   Animations
======================================== */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.filters-content.open {
    animation: slideDown 0.3s ease;
}

/* ========================================
   تحسينات إضافية
======================================== */

/* Focus states محسنة */
.filter-select:focus-visible,
.filter-input:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Placeholder محسن */
.filter-input::placeholder {
    color: #999;
    font-weight: 400;
}

/* Select arrow محسن */
.filter-select {
    appearance: none;
    background-image: url('data:image/svg+xml;charset=UTF-8,%3csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23646970" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"%3e%3cpolyline points="6 9 12 15 18 9"%3e%3c/polyline%3e%3c/svg%3e');
    background-repeat: no-repeat;
    background-position: left 12px center;
    background-size: 16px;
    padding-left: 40px;
}

/* Disabled state */
.filter-select:disabled,
.filter-input:disabled {
    background: #f0f0f1;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Active filter indicator */
.filter-group.has-value .filter-label {
    color: #667eea;
}

.filter-group.has-value .filter-select,
.filter-group.has-value .filter-input {
    border-color: #667eea;
    background: #f8f9ff;
}

/* ========================================
   Print styles
======================================== */
@media print {
    .filters-bar {
        display: none;
    }
}

/* ========================================
   High contrast mode
======================================== */
@media (prefers-contrast: high) {
    .filters-bar {
        border: 2px solid #000;
    }

    .filter-select,
    .filter-input {
        border: 2px solid #000;
    }
}

/* ========================================
   Reduced motion
======================================== */
@media (prefers-reduced-motion: reduce) {
    .filters-content,
    .filter-select,
    .filter-input,
    .filters-reset-btn,
    .filters-apply-btn {
        transition: none;
        animation: none;
    }
}
