/**
 * Mobile Category Layouts
 * @version 6.1
 * تخطيطات الموبايل للأقسام
 */

/* ========================================
   إصلاح: إعادة تعيين للديسك توب
   ======================================== */
@media (min-width: 769px) {
    /* إعادة تعيين جميع تخطيطات الموبايل للديسك توب */
    .category-posts,
    .archive-posts,
    .search-results .posts-grid,
    .search-posts,
    body.has-mobile-layout .category-posts,
    body.category .category-posts,
    body.archive .category-posts,
    body.search .posts-grid,
    body.tax .category-posts {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 20px !important;
        max-width: 100% !important;
        width: 100% !important;
    }
    
    /* إعادة تعيين المقالات للديسك توب */
    .category-posts .category-post-item,
    .archive-posts .category-post-item,
    .search-results .post-card,
    .search-posts .post-item,
    body.has-mobile-layout .category-posts .category-post-item,
    body.category .category-post-item,
    body.archive .category-post-item,
    body.search .post-card,
    body.tax .category-post-item {
        display: flex !important;
        flex-direction: column !important;
        background: #fff;
        border-radius: 10px;
        overflow: hidden;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        border: 1px solid #e0e0e0;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* إعادة تعيين الصور للديسك توب */
    .category-posts .post-thumb,
    .archive-posts .post-thumb,
    .search-results .post-thumb,
    .search-results .post-thumbnail,
    body.has-mobile-layout .category-posts .post-thumb,
    body.category .post-thumb,
    body.archive .post-thumb,
    body.search .post-thumb,
    body.search .post-thumbnail,
    body.tax .post-thumb {
        width: 100% !important;
        height: 200px !important;
        min-height: 200px !important;
        max-height: 200px !important;
        aspect-ratio: 16 / 9 !important;
    }
    
    /* إعادة تعيين المحتوى للديسك توب */
    .category-posts .post-content-wrap,
    .archive-posts .post-content-wrap,
    .search-results .post-content,
    .search-posts .post-content,
    body.has-mobile-layout .category-posts .post-content-wrap,
    body.category .post-content-wrap,
    body.archive .post-content-wrap,
    body.search .post-content,
    body.search .post-content-wrap,
    body.tax .post-content-wrap {
        padding: 15px !important;
        background: #fff;
        width: 100% !important;
    }
    
    /* إعادة تعيين العناوين للديسك توب */
    .category-posts .post-title,
    .archive-posts .post-title,
    .search-results .post-title,
    .search-posts .post-title,
    body.has-mobile-layout .category-posts .post-title,
    body.category .post-title,
    body.archive .post-title,
    body.search .post-title,
    body.tax .post-title {
        font-size: 16px !important;
        line-height: 1.5 !important;
        margin-bottom: 0;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        font-weight: 700;
        color: #1a1a1a;
        min-height: auto !important;
    }
}

/* ========================================
   تطبيق فقط على الموبايل - Mobile Only
   ======================================== */
@media (max-width: 768px) {
    
    /* ========================================
       الإعداد الافتراضي: عمودين (2 مقالات في الصف)
       Default: Two Columns Layout
       يطبق على: الأقسام، الأرشيف، البحث
       ======================================== */
    .category-posts,
    .archive-posts,
    .search-results .posts-grid,
    .search-posts,
    body.has-mobile-layout .category-posts,
    body.category .category-posts,
    body.archive .category-posts,
    body.search .posts-grid,
    body.tax .category-posts {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }
    
    /* ========================================
       استثناء: الصفحة الرئيسية تبقى عمود واحد
       Exception: Home page stays single column
       ======================================== */
    body.home .home-section-posts,
    body.home .posts-grid,
    body.home .section-posts,
    body.front-page .home-section-posts,
    body.front-page .posts-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* تنسيق المقالات الافتراضي - عمودين */
    .category-posts .category-post-item,
    .archive-posts .category-post-item,
    .search-results .post-card,
    .search-posts .post-item,
    body.has-mobile-layout .category-posts .category-post-item,
    body.category .category-post-item,
    body.archive .category-post-item,
    body.search .post-card,
    body.tax .category-post-item {
        display: flex !important;
        flex-direction: column !important;
        background: #fff;
        border-radius: 10px;
        overflow: hidden;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        border: 1px solid #e0e0e0;
    }
    
    .category-posts .post-thumb,
    .archive-posts .post-thumb,
    .search-results .post-thumb,
    .search-results .post-thumbnail,
    body.has-mobile-layout .category-posts .post-thumb,
    body.category .post-thumb,
    body.archive .post-thumb,
    body.search .post-thumb,
    body.search .post-thumbnail,
    body.tax .post-thumb {
        width: 100% !important;
        height: 140px !important;
        min-height: 140px;
        max-height: 140px;
        aspect-ratio: 16 / 9;
        background: linear-gradient(135deg, #f0f0f0 0%, #e0e0e0 100%);
        position: relative;
        overflow: hidden;
    }
    
    .category-posts .post-thumb img,
    .archive-posts .post-thumb img,
    .search-results .post-thumb img,
    .search-results .post-thumbnail img,
    body.has-mobile-layout .category-posts .post-thumb img,
    body.category .post-thumb img,
    body.archive .post-thumb img,
    body.search .post-thumb img,
    body.search .post-thumbnail img,
    body.tax .post-thumb img {
        width: 100%;
        height: 100%;
        object-fit: cover !important;
    }
    
    .category-posts .post-content-wrap,
    .archive-posts .post-content-wrap,
    .search-results .post-content,
    .search-posts .post-content,
    body.has-mobile-layout .category-posts .post-content-wrap,
    body.category .post-content-wrap,
    body.archive .post-content-wrap,
    body.search .post-content,
    body.search .post-content-wrap,
    body.tax .post-content-wrap {
        padding: 12px;
        background: #fff;
    }
    
    .category-posts .post-title,
    .archive-posts .post-title,
    .search-results .post-title,
    .search-posts .post-title,
    body.has-mobile-layout .category-posts .post-title,
    body.category .post-title,
    body.archive .post-title,
    body.search .post-title,
    body.tax .post-title {
        font-size: 13px !important;
        line-height: 1.5 !important;
        margin-bottom: 0;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        font-weight: 700;
        color: #1a1a1a;
        min-height: 40px;
    }
    
    .category-posts .post-cat,
    body.has-mobile-layout .category-posts .post-cat {
        font-size: 9px;
        padding: 4px 8px;
        top: 8px;
        right: 8px;
    }
    
    .category-posts .post-date-badge,
    body.has-mobile-layout .category-posts .post-date-badge {
        position: absolute;
        top: 8px;
        left: 8px;
        background: rgba(0,0,0,0.9);
        color: #fff;
        padding: 5px 10px;
        border-radius: 6px;
        font-size: 10px;
        font-weight: 700;
        z-index: 5;
        box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    }
    
    /* === Style 1: Full Width === */
    body.mobile-layout-style1 .category-posts {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
    
    body.mobile-layout-style1 .category-post-item {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
    }
    
    body.mobile-layout-style1 .post-thumb {
        width: 100% !important;
        height: auto !important;
        min-height: 200px !important;
        aspect-ratio: 16 / 9 !important;
    }
    
    body.mobile-layout-style1 .post-thumb img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }
    
    body.mobile-layout-style1 .post-content-wrap {
        width: 100% !important;
        padding: 15px !important;
    }
    
    body.mobile-layout-style1 .post-title {
        font-size: 17px !important;
    }
    
    /* === Style 2: Horizontal === */
    body.mobile-layout-style2 .category-posts {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
    
    body.mobile-layout-style2 .category-post-item {
        display: flex !important;
        flex-direction: row !important;
        width: 100% !important;
    }
    
    body.mobile-layout-style2 .post-thumb {
        width: 140px !important;
        min-width: 140px !important;
        max-width: 140px !important;
        height: 120px !important;
        min-height: 120px !important;
        max-height: 120px !important;
        flex-shrink: 0 !important;
        aspect-ratio: unset !important;
    }
    
    body.mobile-layout-style2 .post-thumb img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }
    
    body.mobile-layout-style2 .post-content-wrap {
        flex: 1 !important;
        width: auto !important;
        padding: 15px !important;
    }
    
    body.mobile-layout-style2 .post-title {
        font-size: 15px !important;
        -webkit-line-clamp: 2 !important;
    }
    
    body.mobile-layout-style2 .post-date-badge {
        position: static !important;
        background: transparent !important;
        box-shadow: none !important;
        color: #999 !important;
        padding: 0 !important;
        font-size: 12px !important;
    }
    
    body.mobile-layout-style2 .post-cat {
        display: none !important;
    }
    
    /* === Style 3: Two Columns === */
    body.mobile-layout-style3 .category-posts {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }
    
    body.mobile-layout-style3 .category-post-item {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
    }
    
    body.mobile-layout-style3 .post-thumb {
        width: 100% !important;
        height: 140px !important;
        min-height: 140px !important;
        max-height: 140px !important;
        aspect-ratio: 16 / 9 !important;
    }
    
    body.mobile-layout-style3 .post-thumb img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }
    
    body.mobile-layout-style3 .post-content-wrap {
        width: 100% !important;
        padding: 12px !important;
    }
    
    body.mobile-layout-style3 .post-title {
        font-size: 13px !important;
        -webkit-line-clamp: 2 !important;
        min-height: 40px !important;
    }
}

