/* ========================================
   Mobile Fixes - إصلاحات الموبايل
   ======================================== */

/* إخفاء عناصر الموبايل من الديسك توب */
.mobile-menu-search,
.mobile-menu-social,
.mobile-menu-logo,
.mobile-menu-about,
.mobile-menu-close {
    display: none !important;
}

/* ===== Desktop - استعادة الوضع الطبيعي ===== */
@media (min-width: 769px) {
    body.home .container,
    .home-page .container {
        max-width: 1200px !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
        margin: 0 auto !important;
    }
}

/* ===== إصلاح عرض الصفحة الرئيسية على الموبايل ===== */
@media (max-width: 768px) {
    
    /* ===== Container للموبايل - 5px فقط ===== */
    body.home,
    body.home .container,
    .home-page,
    .home-page .container {
        max-width: 100vw !important;
        width: 100% !important;
        padding-left: 5px !important;
        padding-right: 5px !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    .home-section,
    .section-posts,
    .posts-grid,
    .posts-list {
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        width: 100% !important;
    }
    
    /* ===== إخفاء القائمة بشكل افتراضي ===== */
    .main-nav {
        display: none !important;
    }
    
    .main-nav.active {
        display: flex !important;
    }
    
    /* ===== إجبار عرض مقال واحد في الصف - specificity عالية جداً ===== */
    body .home-page .home-sections .home-section .home-section-posts,
    body .home-page .home-sections .home-section .posts-style-grid,
    body .home-page .home-sections .home-section .posts-style-list,
    body .home-page .home-sections .home-section .posts-style-compact,
    body .home-page .home-sections .home-section .posts-style-featured,
    body .home-page .home-sections .home-section .section-posts,
    body .home-page .posts-grid,
    body .home-page .posts-list,
    body .home-page .grid-layout,
    body .home-page .list-layout {
        display: block !important;
        width: 100% !important;
        grid-template-columns: 1fr !important;
        columns: 1 !important;
        gap: 15px !important;
    }
    
    body .home-page .home-sections .home-section .section-post,
    body .home-page .post-item,
    body .home-page .grid-item,
    body .home-page .list-item,
    body .home-page article,
    body .home-page .home-post {
        width: 100% !important;
        max-width: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        margin-bottom: 15px !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        gap: 0 !important;
        background: #fff !important;
        padding: 0 !important;
        border-radius: 12px !important;
        border: 2px solid #f0f0f0 !important;
        overflow: hidden !important;
        box-shadow: 0 3px 12px rgba(0,0,0,0.1) !important;
    }
    
    body .home-page .home-sections .home-section .section-post .post-thumbnail {
        width: 100% !important;
        height: 180px !important;
        aspect-ratio: 16/9 !important;
        position: relative !important;
        border-radius: 0 !important;
        overflow: hidden !important;
    }
    
    body .home-page .home-sections .home-section .section-post .post-thumbnail img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        aspect-ratio: 16/9 !important;
    }
    
    /* القسم على الصورة */
    body .home-page .home-sections .home-section .section-post .post-cat-badge {
        position: absolute !important;
        top: 12px !important;
        right: 12px !important;
        background: var(--primary, #00A859) !important;
        color: #fff !important;
        padding: 6px 15px !important;
        border-radius: 8px !important;
        font-size: 12px !important;
        font-weight: 800 !important;
        box-shadow: 0 3px 10px rgba(0,0,0,0.3) !important;
        z-index: 5 !important;
        text-decoration: none !important;
    }
    
    /* إظهار التاريخ على الصورة - للموبايل فقط */
    body .home-page .home-sections .home-section .section-post .mobile-meta {
        display: block !important;
        position: absolute !important;
        bottom: 12px !important;
        left: 12px !important;
        margin: 0 !important;
        padding: 0 !important;
        background: transparent !important;
        border: none !important;
        z-index: 5 !important;
    }
    
    body .home-page .home-sections .home-section .section-post .mobile-meta .meta-date {
        background: linear-gradient(135deg, rgba(0,0,0,0.9), rgba(0,0,0,0.7)) !important;
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
        color: #fff !important;
        padding: 8px 15px !important;
        border-radius: 8px !important;
        font-size: 12px !important;
        font-weight: 700 !important;
        box-shadow: 0 3px 10px rgba(0,0,0,0.4) !important;
        display: inline-flex !important;
        align-items: center !important;
        gap: 6px !important;
    }
    
    body .home-page .home-sections .home-section .section-post .mobile-meta .meta-date::before {
        content: '🕐' !important;
    }
    
    /* المحتوى أسفل الصورة */
    body .home-page .home-sections .home-section .section-post .post-content {
        padding: 15px !important;
    }
    
    body .home-page .home-sections .home-section .section-post .post-title {
        font-size: 16px !important;
        line-height: 1.5 !important;
        margin: 0 !important;
        color: #1a1a1a !important;
        font-weight: 800 !important;
    }
    
    body .home-page .home-sections .home-section .section-post .post-title a {
        color: #1a1a1a !important;
    }
    
    body .home-page .home-sections .home-section .section-post .post-excerpt {
        display: none !important;
    }
    
    /* إظهار عناصر الموبايل */
    .mobile-menu-search,
    .mobile-menu-social,
    .mobile-menu-logo,
    .mobile-menu-about {
        display: block !important;
    }
    
    .mobile-menu-close {
        display: flex !important;
    }
    
    /* ===== البحث على الموبايل ===== */
    .search-overlay {
        padding: 10px !important;
    }
    
    .search-box {
        padding: 30px 20px !important;
        max-width: 100% !important;
    }
    
    .close-search {
        width: 40px !important;
        height: 40px !important;
        left: 10px !important;
        top: 10px !important;
        font-size: 28px !important;
    }
    
    .search-title {
        font-size: 20px !important;
        margin: 0 0 20px !important;
    }
    
    .search-box input[type="search"] {
        padding: 15px 20px !important;
        font-size: 16px !important;
    }
    
    .search-box button[type="submit"] {
        padding: 15px 25px !important;
        font-size: 16px !important;
    }
    
    /* ===== Container - فراغ 5px من الجوانب ===== */
    .container {
        padding-right: 5px !important;
        padding-left: 5px !important;
    }
    
    /* ===== المقالات - مقال واحد في كل صف ===== */
    .home-section-posts,
    .posts-style-grid,
    .posts-style-list,
    .posts-style-compact,
    .posts-style-featured,
    .posts-grid,
    .category-posts,
    .related-posts-grid,
    .posts-per-row-2,
    .posts-per-row-3,
    .posts-per-row-4,
    .posts-per-row-5,
    .posts-per-row-6 {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
    
    .section-post,
    .post-item,
    .category-post-item {
        width: 100% !important;
        margin: 0 !important;
        display: flex !important;
        flex-direction: row !important;
        gap: 15px !important;
        background: #fff !important;
        padding: 15px !important;
        border-radius: 10px !important;
        border: 2px solid #f0f0f0 !important;
    }
    
    /* الصورة - عرض ثابت */
    .section-post .post-thumbnail,
    .post-item .post-thumbnail {
        width: 120px !important;
        height: 90px !important;
        min-width: 120px !important;
        flex-shrink: 0 !important;
        border-radius: 8px !important;
        overflow: hidden !important;
    }
    
    .section-post .post-thumbnail img,
    .post-item .post-thumbnail img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }
    
    /* المحتوى - بجانب الصورة */
    .section-post .post-content,
    .post-item .post-content {
        flex: 1 !important;
        padding: 0 !important;
    }
    
    .section-post .post-title,
    .post-item .post-title {
        font-size: 16px !important;
        line-height: 1.4 !important;
        margin: 0 0 8px !important;
    }
    
    .section-post .post-meta,
    .post-item .post-meta {
        font-size: 12px !important;
    }
    
    /* ===== جميع المربعات - عرض كامل مع 5px فراغ ===== */
    .category-posts,
    .search-results,
    .author-posts,
    .posts-grid,
    .related-posts-grid,
    .latest-posts-grid,
    .post-content,
    .post-header,
    .entry-header,
    .entry-content,
    .post-meta,
    .post-footer,
    .category-header,
    .archive-header {
        padding-right: 5px !important;
        padding-left: 5px !important;
        width: 100% !important;
    }
    
    .category-post-item,
    .post-card,
    .article-item,
    .related-post,
    .latest-post {
        margin: 0 0 15px 0 !important;
        width: 100% !important;
        padding: 0 !important;
    }
    
    /* ===== الترقيم - واضح وكبير ===== */
    .pagination-wrapper {
        padding: 30px 5px;
        text-align: center;
        margin: 20px 0;
    }
    
    .pagination {
        display: flex !important;
        justify-content: center;
        align-items: center;
        gap: 8px;
        flex-wrap: wrap;
    }
    
    .pagination a,
    .pagination span,
    .pagination .page-numbers {
        display: inline-block !important;
        padding: 12px 16px !important;
        background: #fff !important;
        border: 2px solid #00A859 !important;
        border-radius: 8px !important;
        color: #00A859 !important;
        font-weight: 600 !important;
        font-size: 16px !important;
        text-decoration: none !important;
        min-width: 45px !important;
        text-align: center !important;
        transition: all 0.3s !important;
    }
    
    .pagination span.current,
    .pagination .page-numbers.current {
        background: #00A859 !important;
        color: #fff !important;
    }
    
    .pagination a:hover {
        background: #00A859 !important;
        color: #fff !important;
        transform: scale(1.05);
    }
    
    .pagination .prev,
    .pagination .next {
        font-size: 18px !important;
        font-weight: 700 !important;
    }
    
    /* ===== زر القائمة فقط - الهيدر يبقى زي ما هو ===== */
    .mobile-toggle {
        display: flex !important;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        width: 35px;
        height: 35px;
        background: transparent;
        border: none;
        cursor: pointer;
        gap: 4px;
        padding: 5px;
        transition: all 0.3s;
    }
    
    .mobile-toggle span {
        display: block;
        width: 100%;
        height: 3px;
        background: currentColor;
        border-radius: 2px;
        transition: all 0.3s;
    }
    
    /* زر القائمة نشط (مفتوح) */
    .mobile-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(6px, 6px);
    }
    
    .mobile-toggle.active span:nth-child(2) {
        opacity: 0;
    }
    
    .mobile-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(6px, -6px);
    }
    
    /* ===== إعادة تعريف القائمة للموبايل ===== */
    .main-nav {
        position: fixed !important;
        top: 0 !important;
        left: -100% !important;
        width: 85% !important;
        max-width: 340px !important;
        height: 100vh !important;
        background: var(--mobile-menu-bg, #fff) !important;
        box-shadow: 2px 0 20px rgba(0,0,0,0.3) !important;
        overflow-y: auto !important;
        transition: left 0.3s ease !important;
        z-index: 9998 !important;
        padding: 70px 0 0 !important;
        display: none !important;
        flex-direction: column !important;
        flex: none !important;
    }
    
    .main-nav.active {
        left: 0 !important;
        display: flex !important;
    }
    
    .main-nav .menu {
        display: block !important;
        flex-direction: column !important;
    }
    
    /* زر الإغلاق داخل القائمة - في الوسط في الأعلى */
    .mobile-menu-close {
        display: none;
        position: absolute;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: 45px;
        height: 45px;
        background: var(--mobile-menu-hover, #00A859);
        border: none;
        border-radius: 50%;
        cursor: pointer;
        z-index: 20;
        transition: all 0.3s;
        align-items: center;
        justify-content: center;
        box-shadow: 0 3px 15px rgba(0,0,0,0.2);
    }
    
    .mobile-menu-close svg {
        width: 22px;
        height: 22px;
        color: #fff;
    }
    
    .mobile-menu-close:hover {
        background: #dc3545;
        transform: translateX(-50%) scale(1.1) rotate(90deg);
        box-shadow: 0 5px 20px rgba(220,53,69,0.4);
    }
    
    .mobile-menu-close:active {
        transform: translateX(-50%) scale(0.95);
    }
    
    /* الشعار داخل القائمة */
    .mobile-menu-logo {
        display: none;
        padding: 25px 20px;
        text-align: center;
        border-bottom: 2px solid var(--mobile-menu-border, #eee);
        background: rgba(0,0,0,0.02);
    }
    
    .mobile-menu-logo a {
        display: inline-block;
    }
    
    .mobile-menu-logo img {
        max-height: 60px;
        max-width: 200px;
        height: auto;
        width: auto;
    }
    
    .mobile-menu-logo .logo-text {
        font-size: 24px;
        font-weight: 800;
        color: var(--mobile-menu-hover, #00A859);
        text-decoration: none;
    }
    
    .mobile-menu-logo .custom-logo-link {
        border: none;
    }
    
    /* النبذة أسفل القائمة */
    .mobile-menu-about {
        display: none;
        padding: 25px 20px;
        background: var(--mobile-menu-hover-bg, #f8f9fa);
        border-top: 2px solid var(--mobile-menu-border, #eee);
        margin-top: auto;
    }
    
    .mobile-menu-about p {
        margin: 0;
        font-size: 14px;
        line-height: 1.7;
        color: var(--mobile-menu-link, #666);
        text-align: center;
        opacity: 0.9;
    }
    
    /* البحث داخل القائمة */
    .mobile-menu-search {
        padding: 15px 20px;
        border-bottom: 1px solid var(--mobile-menu-border, #eee);
        margin-bottom: 10px;
    }
    
    .mobile-menu-search input {
        width: 100%;
        padding: 12px 15px;
        border: 2px solid var(--mobile-menu-border, #eee);
        border-radius: 25px;
        font-size: 14px;
        outline: none;
        transition: all 0.3s;
        color: var(--mobile-menu-link, #333);
    }
    
    .mobile-menu-search input::placeholder {
        color: rgba(0,0,0,0.4);
    }
    
    .mobile-menu-search input:focus {
        border-color: var(--mobile-menu-hover, #00A859);
    }
    
    /* السوشيال ميديا داخل القائمة */
    .mobile-menu-social {
        padding: 20px;
        border-top: 1px solid var(--mobile-menu-border, #eee);
        display: flex;
        justify-content: center;
        gap: 15px;
        margin-top: 20px;
    }
    
    .mobile-menu-social a {
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(0,0,0,0.05);
        border-radius: 50%;
        color: var(--mobile-menu-link, #333);
        transition: all 0.3s;
    }
    
    .mobile-menu-social a:hover {
        background: var(--mobile-menu-hover, #00A859);
        color: #fff;
        transform: scale(1.1);
    }
    
    /* القائمة */
    .main-nav .menu {
        list-style: none;
        margin: 0;
        padding: 0;
        flex: 1;
        overflow-y: auto;
    }
    
    .main-nav .menu > li {
        border-bottom: 1px solid var(--mobile-menu-border, #eee);
    }
    
    .main-nav .menu > li > a {
        display: block;
        padding: 15px 20px;
        color: var(--mobile-menu-link, #333) !important;
        font-size: 16px;
        font-weight: 600;
        text-decoration: none;
        transition: all 0.3s;
    }
    
    .main-nav .menu > li > a:hover,
    .main-nav .menu > li.current-menu-item > a {
        background: var(--mobile-menu-hover-bg, #f5f5f5) !important;
        color: var(--mobile-menu-hover, #00A859) !important;
        padding-right: 25px;
    }
    
    /* القوائم الفرعية في الموبايل */
    .main-nav .sub-menu {
        display: none;
        list-style: none;
        margin: 0;
        padding: 0;
        background: rgba(0,0,0,0.03);
    }
    
    .main-nav .menu-item-has-children.active > .sub-menu {
        display: block;
    }
    
    .main-nav .sub-menu li {
        border-bottom: 1px solid var(--mobile-menu-border, #eee);
    }
    
    .main-nav .sub-menu li a {
        display: block;
        padding: 12px 20px 12px 40px;
        color: var(--mobile-menu-link, #333) !important;
        font-size: 14px;
        font-weight: 500;
        text-decoration: none;
    }
    
    .main-nav .sub-menu li a:hover {
        background: var(--mobile-menu-hover-bg, #f5f5f5) !important;
        color: var(--mobile-menu-hover, #00A859) !important;
    }
    
    /* سهم القوائم الفرعية */
    .main-nav .menu-item-has-children > a::after {
        content: '▼';
        float: left;
        font-size: 10px;
        transition: transform 0.3s;
    }
    
    .main-nav .menu-item-has-children.active > a::after {
        transform: rotate(180deg);
    }
    
    /* Overlay عند فتح القائمة */
    body.menu-open::after {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.6);
        z-index: 9997;
        opacity: 1;
        transition: opacity 0.3s ease;
        cursor: pointer;
        pointer-events: auto;
    }
    
    /* إخفاء الـ overlay فوراً عند الإغلاق */
    body::after {
        content: none;
    }
    
    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }
    
    /* منع الـ scroll عند فتح القائمة */
    body.menu-open {
        overflow: hidden !important;
    }
    
    /* إعادة الـ scroll عند الإغلاق */
    body:not(.menu-open) {
        overflow: auto !important;
    }
    
    /* لا نخفي أي حاجة من الهيدر */
    
    /* ===== Load More Button - بعرض الصفحة ===== */
    .load-more-wrapper {
        text-align: center;
        padding: 20px 5px;
        margin: 20px 0;
    }
    
    .load-more-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        padding: 16px 20px;
        background: linear-gradient(135deg, #00A859, #00c46e);
        color: #fff;
        border: none;
        border-radius: 12px;
        font-size: 16px;
        font-weight: 700;
        cursor: pointer;
        transition: all 0.3s;
        box-shadow: 0 4px 15px rgba(0,168,89,0.3);
    }
    
    .load-more-btn svg {
        width: 18px;
        height: 18px;
    }
    
    .load-more-btn:hover {
        background: linear-gradient(135deg, #008a47, #00A859);
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(0,168,89,0.4);
    }
    
    .load-more-btn:disabled {
        background: #ccc;
        cursor: not-allowed;
        box-shadow: none;
    }
    
    .btn-text {
        display: inline;
    }
    
    /* ===== Infinite Scroll Loader ===== */
    .infinite-scroll-loader {
        text-align: center;
        padding: 30px;
        font-size: 16px;
        color: #666;
    }
    
    .loader-icon {
        font-size: 24px;
        animation: spin 1s linear infinite;
    }
    
    @keyframes spin {
        0% { transform: rotate(0deg); }
        100% { transform: rotate(360deg); }
    }
    
    /* ===== أخبار ذات صلة وأحدث الأخبار - بعرض الصفحة ===== */
    .related-posts,
    .latest-posts,
    .related-posts-section,
    .latest-posts-section {
        padding: 0 5px !important;
        margin: 20px 0;
        width: 100% !important;
    }
    
    .related-posts-grid,
    .latest-posts-grid {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 15px !important;
        padding: 0 !important;
    }
    
    .related-post,
    .latest-post,
    .related-posts-grid .post-card,
    .latest-posts-grid .post-card {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* ===== Sidebar في الموبايل ===== */
    .sidebar,
    .widget-area {
        padding: 0 5px !important;
        width: 100% !important;
    }
    
    .widget {
        margin-bottom: 20px;
        padding: 0 !important;
    }
    
    .widget-post {
        width: 100% !important;
    }
    
}

/* ===== Touch Optimization - تحسين النقرات ===== */
@media (max-width: 768px) {
    .touch-optimized a,
    .touch-optimized button,
    .touch-optimized input[type="submit"] {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

/* ===== Dark Mode للموبايل ===== */
@media (max-width: 768px) {
    body.dark-mode .main-nav {
        background: #1a1a1a !important;
    }
    
    body.dark-mode .mobile-menu-close {
        background: var(--mobile-menu-hover, #00A859);
    }
    
    body.dark-mode .mobile-menu-close:hover {
        background: #dc3545;
    }
    
    body.dark-mode .main-nav .menu > li > a {
        color: #fff !important;
    }
    
    body.dark-mode .main-nav .menu > li {
        border-bottom-color: #333;
    }
    
    body.dark-mode .main-nav .menu > li > a:hover,
    body.dark-mode .main-nav .menu > li.current-menu-item > a {
        background: #2a2a2a;
    }
    
    body.dark-mode .mobile-menu-search input {
        background: #2a2a2a;
        border-color: #444;
        color: #fff;
    }
    
    body.dark-mode .mobile-menu-social a {
        background: #2a2a2a;
        color: #fff;
    }
    
    body.dark-mode .mobile-menu-logo {
        border-bottom-color: #333;
    }
    
    body.dark-mode .mobile-menu-logo .logo-text {
        color: #fff;
    }
    
    body.dark-mode .mobile-menu-about {
        background: #2a2a2a;
        border-top-color: #333;
    }
    
    body.dark-mode .mobile-menu-about p {
        color: #ccc;
    }
}

