/* =============================================== */
/* == تحسينات إضافية للتصميم المتجاوب == */
/* =============================================== */

/* تحسين الخطوط للأجهزة عالية الدقة */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* تحسينات للأجهزة اللوحية في الوضع العمودي */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
    .header-top {
        padding: 1rem;
    }
    
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .product-card {
        min-height: 20rem;
    }
}

/* تحسينات خاصة للهواتف في الوضع الأفقي */
@media (max-width: 767px) and (orientation: landscape) {
    .header-top {
        padding: 0.5rem;
    }
    
    .logo-icon {
        font-size: 1.5rem;
    }
    
    .logo-main {
        font-size: 1rem;
    }
    
    .logo-sub {
        font-size: 0.7rem;
    }
    
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.75rem;
    }
}

/* تحسين القائمة الجانبية للأجهزة المختلفة */
@media (max-width: 479px) {
    .category-sidebar {
        width: 90vw;
        height: 100vh;
        padding: 0.75rem;
    }
    
    .category-sidebar h3 {
        font-size: 1.1rem;
        margin-top: 2.5rem;
    }
    
    .category-sidebar ul li a {
        padding: 0.75rem;
        font-size: 0.9rem;
    }
}

/* =============================================== */
/* == تحسينات شاملة للهيدر على الأجهزة اللوحية والمحمولة == */
/* =============================================== */
@media (max-width: 992px) {
    /* إلغاء التكديس العمودي القادم من style.css */
    .header-top {
        flex-direction: row; /* الحفاظ على التخطيط الأفقي */
        flex-wrap: wrap;     /* السماح بالتفاف العناصر */
        row-gap: 1rem;       /* إضافة مسافة عند الالتفاف */
    }

    /* ترتيب العناصر في الهيدر */
    .logo-container {
        order: 1;
    }

    .auth-nav {
        order: 2;
        margin-left: auto; /* دفع الأزرار إلى اليمين */
        margin-top: 0; /* إلغاء الهامش العلوي */
    }

    html[dir="rtl"] .auth-nav {
        margin-left: 0;
        margin-right: auto; /* دفع الأزرار إلى اليسار في RTL */
    }

    .header-search-container {
        order: 3; /* وضع شريط البحث في السطر الثاني */
        flex-basis: 100%; /* جعله يأخذ عرض كامل */
        margin: 0;
        max-width: none;
    }

    /* إخفاء شريط الأقسام القابل للتمرير لتوفير المساحة */
    .sections-wrapper { display: none; }
}

/* تحسين النماذج للأجهزة المحمولة */
@media (max-width: 767px) {
    .form-container {
        margin: 1rem auto;
        padding: 1.5rem;
        max-width: 95%;
    }
    
    .form-group input[type="text"],
    .form-group input[type="email"],
    .form-group input[type="password"] {
        padding: 0.75rem;
        font-size: 1rem;
        min-height: 2.75rem;
    }
    
    .form-container button {
        padding: 0.875rem 1.25rem;
        font-size: 1.1rem;
        min-height: 3rem;
    }
}

/* تحسين الجداول للأجهزة المحمولة */
@media (max-width: 767px) {
    .cart-table {
        font-size: 0.875rem;
    }
    
    .cart-table th,
    .cart-table td {
        padding: 0.5rem;
    }
    
    .cart-product-image img {
        width: 3.75rem;
        height: 3.75rem;
    }
    
    .quantity-input {
        width: 3rem;
        padding: 0.25rem;
    }
}

/* تحسين الأزرار العائمة والثابتة */
.floating-action-button {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    width: 3.5rem;
    height: 3.5rem;
    background-color: #3f51b5;
    color: white;
    border: none;
    border-radius: 50%;
    box-shadow: 0 0.25rem 0.5rem rgba(0,0,0,0.3);
    cursor: pointer;
    z-index: 1000;
    display: none;
}

@media (max-width: 767px) {
    .floating-action-button {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* تحسين التمرير السلس */
html {
    scroll-behavior: smooth;
}

/* تحسين التركيز للوصولية */
*:focus {
    outline: 0.125rem solid #3f51b5;
    outline-offset: 0.125rem;
}

/* إخفاء العناصر غير المهمة على الشاشات الصغيرة */
@media (max-width: 479px) {
    .logo-sub {
        display: none;
    }
    
    .sections-wrapper {
        display: none; /* إخفاء الأقسام على الهواتف الصغيرة */
    }
}

/* تحسين الصور المتجاوبة */
img {
    max-width: 100%;
    height: auto;
}

.product-card img {
    width: 100%;
    height: 12.5rem;
    object-fit: cover;
    transition: transform 0.3s ease;
}

@media (max-width: 479px) {
    .product-card img {
        height: 10rem;
    }
}

/* تحسين النصوص للقراءة */
@media (max-width: 767px) {
    .product-info h3 {
        font-size: 1rem;
        line-height: 1.4;
        height: auto;
        min-height: 2.5rem;
    }
    
    .product-price {
        font-size: 1.2rem;
        margin: 0.5rem 0;
    }
    
    .section-title {
        font-size: 1.1rem;
        margin-bottom: 1.5rem;
    }
}

/* تحسين الحاويات */
@media (max-width: 767px) {
    .container {
        max-width: 100%;
        margin: 1rem auto;
        padding: 0 0.75rem;
    }
}

/* تحسين الفوتر */
@media (max-width: 767px) {
    footer {
        padding: 1.5rem 1rem;
        font-size: 0.9rem;
        text-align: center;
    }
    
    .social-icons {
        gap: 1rem;
        margin-bottom: 1rem;
        justify-content: center;
    }
    
    .social-icons a img {
        width: 2.25rem; /* تكبير الأيقونات قليلاً */
        height: 2.25rem;
        transition: transform 0.2s ease;
    }

    .social-icons a:hover img {
        transform: scale(1.15);
    }
}

/* تحسين الإعلانات */
@media (max-width: 767px) {
    .announcements-container {
        height: 2.5rem;
    }
    
    .announcement-carousel .announcement-image {
        object-fit: contain;
    }
}

/* تحسين العلامات التجارية */
@media (max-width: 767px) {
    .brand-items-wrapper img {
        height: 4rem;
        max-width: 6rem;
        margin: 0 0.5rem;
    }
}

/* تحسين الفئات */
@media (max-width: 767px) {
    .category-items-wrapper {
        gap: 1rem !important;
    }
    
    .shop-by-category-banner .category-item {
        flex: 0 1 5rem !important;
    }
    
    .shop-by-category-banner .category-item span {
        font-size: 0.75rem;
    }
}