/* --- 1. التنسيقات العامة والأساسية --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    min-height: 100vh;
    padding-bottom: 80px; /* احتياطي ممتاز ومريح للقائمة السفلية */
    font-family: 'Cairo', sans-serif;
    background: linear-gradient(145deg, #faf6f0 0%, #f2ebe2 100%);
    color: #2c241a;
    scroll-behavior: smooth;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 16px;
}

/* --- 2. الهيدر والشعار (Top Header) --- */
.top-header {
    background: rgba(255, 248, 240, 0.96);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(139, 89, 49, 0.15);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    gap: 12px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff3e8;
    padding: 5px 10px;
    border-radius: 60px;
}

.logo i {
    font-size: 26px;
    color: #b87b4a;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #b87b4a, #8b5a2e);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.nav-links {
    display: flex;
    gap: 24px;
    background: white;
    padding: 5px 18px;
    border-radius: 60px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

.nav-links a {
    text-decoration: none;
    font-weight: 600;
    color: #4a3627;
    font-size: 0.95rem;
}

.nav-links a.active, .nav-links a:hover {
    color: #b87b4a;
}

.user-area {
    display: flex;
    align-items: center;
    gap: 12px;
    background: white;
    padding: 4px 16px;
    border-radius: 40px;
}

.sudan-clock {
    font-family: monospace;
    font-weight: 600;
    background: #f2e5d8;
    padding: 5px 12px;
    border-radius: 32px;
    color: #9b6a3e;
}

.login-btn {
    background: #b87b4a;
    border: none;
    padding: 6px 16px;
    border-radius: 32px;
    color: white;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-avatar {
    width: 34px;
    height: 34px;
    background: #b87b4a;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

/* --- 3. شريط العمليات المطور (Action Bar) --- */
.action-bar {
    background: white;
    padding: 12px 16px;
    border-radius: 24px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    margin: 15px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.action-bar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
}

.search-wrapper {
    width: 100%;
}

.search-form {
    width: 100%;
}

.search-input-group {
    display: flex;
    align-items: center;
    background: #fefcf9;
    border: 1px solid #e2d4c8;
    border-radius: 10px;
    padding: 3px 4px 3px 8px;
    width: 100%;
}

.search-input-group input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px;
    font-family: 'Cairo';
    outline: none;
    font-size: 0.95rem;
}

.search-btn {
    background: #b87b4a;
    border: none;
    padding: 8px 20px;
    border-radius: 40px;
    font-weight: 700;
    color: white;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    white-space: nowrap;
}

.menu-icon {
    font-size: 20px;
    cursor: pointer;
    background: #f3ece4;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #4a3627;
}

.add-ad-btn {
    background: #b87b4a;
    border: none;
    padding: 20 20px;
    border-radius: 40px;
    font-weight: 700;
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    white-space: nowrap;
    height: 42px;
    flex: 1;
}

/* --- 4. الأقسام والفلاتر (Categories & Filters) --- */
.category-icons {
    display: flex;
    gap: 4px;
    background: white;
    padding: 12px;
    border-radius: 20px;
    margin-bottom: 15px;
    overflow-x: auto;
    white-space: nowrap;
    justify-content: flex-start;
    -webkit-overflow-scrolling: touch;
}

.category-icons::-webkit-scrollbar {
    display: none; /* إخفاء شريط التمرير المزعج لجعلها كالأبلكيشن */
}

.cat-item {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 16px;
    font-weight: 600;
    gap: 4px;
    text-decoration: none;
    color: #4a3627;
    background: #fbf8f5;
    flex-shrink: 0;
}

.cat-item i { font-size: 22px; }

.cat-item.active {
    background: #b87b4a;
    color: white;
    box-shadow: 0 4px 10px rgba(184,123,74,0.2);
}

.filter-panel {
    background: white;
    border-radius: 16px;
    padding: 10px;
    margin-bottom: 15px;
}

.filter-group {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    align-items: center;
    width: 100%;
}

/* --- 5. بطاقات الإعلانات (Ad Cards) --- */
.main-grid {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 20px;
    margin-bottom: 40px;
}

/* ===== إجبار ترتيب بطاقة الإعلان ===== */
.ad-card {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: white;
    border-radius: 28px;
    margin-bottom: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    /* إزالة أي direction من هنا */
}

.ad-img {
    order: 1 !important;
    flex-shrink: 0;
    width: 110px;
    height: 150px;
    display: block;
    background: #f3ece4;
    border-radius: 24px;
    overflow: hidden;
}

.ad-details {
    order: 2 !important;
    flex: 1;
    text-align: right;
    direction: rtl; /* النص يبقى من اليمين لليسار */
}

.favorite-area {
    order: 3 !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 70px;
    cursor: pointer;
    gap: 6px;
    direction: rtl;
}

/* في الجوال، قد تحتاج إلى تقليل الأحجام */
@media (max-width: 768px) {
    .ad-img { width: 85px; height: 85px; }
    .ad-title { font-size: 1rem; }
    .favorite-area { min-width: 50px; }
}



.ad-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: #2c241a;
}

.ad-meta {
    display: flex;
    gap: 10px;
    color: #7c6855;
    font-size: 0.75rem;
    flex-wrap: wrap;
}

.ads-container {
    border-bottom: 10px solid #D4AF37;
}

.favorite-icon { font-size: 22px; color: #d4bb9f; }
.favorite-icon.active { color: #c95a3a; }
.fav-text { font-size: 0.6rem; color: #8b6b4e; }

/* --- 6. القوائم والـ Bottom Nav --- */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255,252,245,0.97);
    backdrop-filter: blur(20px);
    display: flex;
    justify-content: space-around;
    padding: 10px 16px;
    border-top: 1px solid #e9dbcf;
    z-index: 200;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #8b6b4e;
    text-decoration: none;
}

.mobile-nav-item i { font-size: 20px; }
.mobile-nav-item.active { color: #b87b4a; }

.drawer {
    position: fixed;
    top: 0;
    right: -300px;
    width: 280px;
    height: 100%;
    background: white;
    z-index: 1000;
    transition: 0.3s ease;
    padding: 24px 16px;
    box-shadow: -4px 0 20px rgba(0,0,0,0.1);
}
.drawer.open { right: 0; }
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 999;
    display: none;
}

.featured-badge {
    background: #e8f5e9;
    color: #2e7d32;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    margin-top: 4px;
    display: inline-block;
}
/* ===== تنسيق التعليقات والردود ===== */
.comment {
    border-bottom: 1px solid #f1e8df;
    padding: 15px 0;
}
.reply {
    margin-right: 40px;
    padding: 10px 15px;
    background: #f7efe6;
    border-radius: 16px;
    margin-top: 10px;
    border-right: 3px solid #b87b4a;
}
.btn-reply {
    background: transparent;
    border: none;
    color: #b87b4a;
    cursor: pointer;
    font-size: 0.8rem;
    padding: 2px 0;
    margin-top: 5px;
}
.btn-reply:hover {
    text-decoration: underline;
}
.btn-sm {
    padding: 4px 12px;
    font-size: 0.8rem;
}
/* --- 7. استعلامات الجوال الذكية والأكواد المصححة (Media Queries) --- */
@media (max-width: 768px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
    .container {
    width: 100%;
    margin: 0 auto;
    padding: 0 16px;
}
    .nav-links, .banner-right {
        display: none;
    }
    
    /* ضبط هيدر الموقع ليكون متناسقاً */
    .header-row {
        flex-direction: row-reverse;
    }
    .logo { margin-left: auto; margin-right: 0; }
    .user-info span { display: none; }
    
    /* إجبار الفلاتر على سطر واحد بنسبة الثلث بالتساوي */
    .filter-group {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        gap: 6px !important;
    }
    .filter-group select, .filter-group .select2-container {
        flex: 1 1 0% !important;
        width: 33.33% !important;
        max-width: 33.33% !important;
        min-width: 0 !important;
    }
    .filter-group select {
        font-size: 0.8rem !important;
        padding: 6px 4px !important;
    }
    .action-bar {
        padding: 10px;
        border-radius: 6px;
    }
    .search-btn span {
        display: none; /* إخفاء كلمة بحث والابقاء على الايقونة لتوفير مساحة */
    }
    .search-btn {
        padding: 8px 14px;
    }
    .add-ad-btn span {
        font-size: 0.85rem;
    }
    .ad-card {
        gap: 8px;
        padding: 10px;
    }
    .ad-img {
        width: 85px;
        height: 85px;
    }
    .ad-title {
        font-size: 0.95rem;
    }

@media (max-width: 480px) {
    /* شريط البحث المطور كلياً على الهواتف الصغيرة جداً */
    .action-bar {
        padding: 10px;
        border-radius: 6px;
    }
    .search-btn span {
        display: none; /* إخفاء كلمة بحث والابقاء على الايقونة لتوفير مساحة */
    }
    .search-btn {
        padding: 8px 14px;
    }
    .add-ad-btn span {
        font-size: 0.85rem;
    }
    .ad-card {
        gap: 8px;
        padding: 10px;
    }
    .ad-img {
        width: 85px;
        height: 85px;
    }
    .ad-title {
        font-size: 0.95rem;
    }
    
}