/* =============================================== */
/* == إصلاح شامل للتوافقية على الموبايل == */
/* =============================================== */

/* =============================================== */
/* == الهواتف الصغيرة جداً (أقل من 360px) == */
/* =============================================== */
@media (max-width: 359px) {
    html {
        font-size: 12px;
    }

    body {
        /* تم نقل قواعد body إلى comprehensive-mobile-design.css */
    }

    .header-top {
        flex-direction: column;
        gap: 8px;
        padding: 8px;
    }

    .logo-container {
        width: 100%;
        justify-content: center;
    }

    .logo-icon {
        font-size: 1.5rem;
    }

    .logo-main {
        font-size: 1rem;
    }

    .logo-sub {
        display: none;
    }

    .header-search-container {
        width: 100%;
        max-width: none;
        margin: 0;
        height: 36px;
    }

    .header-search-container select,
    .header-search-container input,
    .header-search-container button {
        height: 36px;
        font-size: 12px;
    }

    .auth-nav {
        width: 100%;
        justify-content: center;
        gap: 4px;
        flex-wrap: wrap;
    }

    .btn-login, .btn-register {
        padding: 6px 8px;
        font-size: 11px;
        min-height: 36px;
        min-width: 36px;
    }


    .products-grid {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 0 4px;
    }

    .product-card {
        border-radius: 8px;
    }

    .product-card img {
        height: 120px;
    }

    .product-info h3 {
        font-size: 0.9rem;
        min-height: 2.2em;
    }

    .product-price {
        font-size: 1rem;
    }

    .container {
        padding: 4px;
        margin: 0 auto;
    }

    .form-container {
        padding: 12px;
        margin: 8px;
        max-width: 100%;
    }

    .form-container h2 {
        font-size: 1.3rem;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 14px;
        min-height: 36px;
        padding: 8px;
    }

    .form-container button {
        min-height: 36px;
        padding: 8px 12px;
        font-size: 0.95rem;
    }

    .category-sidebar {
        width: 95vw;
        padding: 8px;
    }

    .category-sidebar h3 {
        font-size: 1rem;
        margin-top: 2rem;
    }

    .category-sidebar ul li a {
        padding: 8px 10px;
        font-size: 0.85rem;
    }

    .header-bottom {
        min-height: 50px;
        padding: 6px 8px;
    }

    .category-menu-btn {
        padding: 6px 10px;
        font-size: 0.9rem;
    }

    .nav-link {
        padding: 6px 10px;
        font-size: 0.8rem;
        margin: 0 2px;
    }

    .scroll-arrow {
        width: 32px;
        height: 32px;
    }

    .scroll-arrow svg {
        width: 16px;
        height: 16px;
    }
}

/* =============================================== */
/* == الهواتف الصغيرة (360px - 480px) == */
/* =============================================== */
@media (min-width: 360px) and (max-width: 479px) {
    html {
        font-size: 13px;
    }

    body {
        /* تم نقل قواعد body إلى comprehensive-mobile-design.css */
    }

    .header-top {
        flex-direction: column;
        gap: 10px;
        padding: 10px;
    }

    .logo-container {
        width: 100%;
        justify-content: center;
        order: 1;
    }

    .logo-icon {
        font-size: 1.8rem;
    }

    .logo-main {
        font-size: 1.1rem;
    }

    .logo-sub {
        font-size: 0.7rem;
    }

    .header-search-container {
        width: 100%;
        max-width: none;
        margin: 0;
        order: 2;
        height: 38px;
    }

    .header-search-container select {
        width: 80px;
        font-size: 12px;
        padding: 0 20px 0 8px;
    }

    .header-search-container input {
        font-size: 12px;
        padding: 0 8px;
    }

    .header-search-container button {
        width: 38px;
        font-size: 12px;
    }

    .auth-nav {
        width: 100%;
        justify-content: center;
        gap: 6px;
        order: 3;
        flex-wrap: wrap;
    }

    .btn-login, .btn-register {
        padding: 8px 10px;
        font-size: 12px;
        min-height: 40px;
        min-width: 40px;
    }


    .cart-icon-link {
        min-height: 40px;
        min-width: 40px;
    }

    .lang-switcher-link {
        width: 40px;
        height: 40px;
    }

    .products-grid {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 0 8px;
    }

    .product-card {
        border-radius: 10px;
    }

    .product-card img {
        height: 140px;
    }

    .product-info h3 {
        font-size: 0.95rem;
        min-height: 2.4em;
    }

    .product-price {
        font-size: 1.1rem;
        margin: 8px 0;
    }

    .btn-view-product {
        padding: 8px 12px;
        font-size: 0.9rem;
        min-height: 36px;
    }

    .container {
        padding: 8px;
        margin: 0 auto;
    }

    .form-container {
        padding: 15px;
        margin: 10px;
        max-width: 100%;
        border-radius: 12px;
    }

    .form-container h2 {
        font-size: 1.4rem;
        margin-bottom: 20px;
    }

    .form-group {
        margin-bottom: 15px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 14px;
        min-height: 40px;
        padding: 10px;
        border-radius: 6px;
    }

    .form-container button {
        min-height: 40px;
        padding: 10px 15px;
        font-size: 1rem;
        border-radius: 6px;
    }

    .category-sidebar {
        width: 85vw;
        padding: 10px;
    }

    .category-sidebar h3 {
        font-size: 1.1rem;
        margin-top: 2.5rem;
    }

    .category-sidebar ul li a {
        padding: 10px 12px;
        font-size: 0.9rem;
    }

    .header-bottom {
        min-height: 55px;
        padding: 8px 10px;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .category-menu-btn {
        padding: 8px 12px;
        font-size: 0.95rem;
        min-height: 40px;
    }

    .nav-link {
        padding: 8px 12px;
        font-size: 0.85rem;
        margin: 0 4px;
    }

    .scroll-arrow {
        width: 36px;
        height: 36px;
    }

    .scroll-arrow svg {
        width: 18px;
        height: 18px;
    }

    .section-title {
        font-size: 1.1rem;
        margin-bottom: 20px;
    }

    .shop-by-category-banner .category-item {
        flex: 0 1 100px;
    }

    .shop-by-category-banner .category-item span {
        font-size: 0.8rem;
    }

    .brand-items-wrapper img {
        height: 60px;
        max-width: 100px;
    }

    .brand-name {
        font-size: 0.75rem;
    }

    .announcements-section {
        margin-bottom: 15px;
    }

    .main-page-carousel {
        aspect-ratio: 16/8;
        max-height: 140px;
        min-height: 100px;
        border-radius: 8px;
        margin-bottom: 15px;
    }

    .main-page-carousel .carousel-control {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }

}

/* =============================================== */
/* == الهواتف المتوسطة (480px - 600px) == */
/* =============================================== */
@media (min-width: 480px) and (max-width: 599px) {
    html {
        font-size: 14px;
    }

    .header-top {
        flex-direction: column;
        gap: 12px;
        padding: 12px;
    }

    .logo-container {
        width: 100%;
        justify-content: center;
    }

    .logo-icon {
        font-size: 2rem;
    }

    .logo-main {
        font-size: 1.2rem;
    }

    .header-search-container {
        width: 100%;
        max-width: none;
        margin: 0;
        height: 40px;
    }

    .header-search-container select {
        width: 90px;
        font-size: 13px;
    }

    .auth-nav {
        width: 100%;
        justify-content: center;
        gap: 8px;
        flex-wrap: wrap;
    }

    .btn-login, .btn-register {
        padding: 10px 12px;
        font-size: 13px;
        min-height: 42px;
    }

    .btn-login svg, .btn-register svg {
        width: 20px !important;
        height: 20px !important;
    }

    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        padding: 0 10px;
    }

    .product-card img {
        height: 150px;
    }

    .product-info h3 {
        font-size: 1rem;
    }

    .container {
        padding: 10px;
    }

    .form-container {
        padding: 20px;
        margin: 12px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 14px;
        min-height: 42px;
        padding: 10px;
    }

    .form-container button {
        min-height: 42px;
        padding: 12px 16px;
        font-size: 1.05rem;
    }

    .header-bottom {
        min-height: 60px;
        padding: 10px 12px;
    }

    .category-menu-btn {
        padding: 10px 14px;
        font-size: 1rem;
        min-height: 42px;
    }

    .nav-link {
        padding: 10px 14px;
        font-size: 0.9rem;
    }

    .scroll-arrow {
        width: 40px;
        height: 40px;
    }

    .main-page-carousel {
        aspect-ratio: 16/7;
        max-height: 160px;
        min-height: 120px;
    }

    .main-page-carousel .carousel-control {
        width: 36px;
        height: 36px;
    }
}

/* =============================================== */
/* == الهواتف الكبيرة والأجهزة اللوحية الصغيرة (600px - 768px) == */
/* =============================================== */
@media (min-width: 600px) and (max-width: 767px) {
    html {
        font-size: 15px;
    }

    .header-top {
        flex-direction: row;
        gap: 15px;
        padding: 12px;
        flex-wrap: wrap;
    }

    .logo-container {
        order: 1;
        flex: 0 0 auto;
    }

    .header-search-container {
        order: 2;
        flex: 1;
        min-width: 200px;
        max-width: 400px;
        margin: 0;
        height: 42px;
    }

    .auth-nav {
        order: 3;
        flex: 0 0 auto;
        gap: 10px;
    }

    .btn-login, .btn-register {
        padding: 10px 14px;
        font-size: 14px;
        min-height: 42px;
    }

    .btn-login svg, .btn-register svg {
        width: 20px !important;
        height: 20px !important;
    }

    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
        padding: 0 12px;
    }

    .product-card img {
        height: 160px;
    }

    .container {
        padding: 12px;
    }

    .form-container {
        padding: 25px;
        margin: 15px auto;
        max-width: 500px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 14px;
        min-height: 42px;
        padding: 10px;
    }

    .form-container button {
        min-height: 44px;
        padding: 12px 20px;
        font-size: 1.1rem;
    }

    .header-bottom {
        min-height: 60px;
        padding: 10px 15px;
    }

    .category-menu-btn {
        padding: 10px 16px;
        font-size: 1rem;
        min-height: 44px;
    }

    .nav-link {
        padding: 10px 16px;
        font-size: 0.95rem;
    }

    .scroll-arrow {
        width: 42px;
        height: 42px;
    }

    .main-page-carousel {
        aspect-ratio: 16/6;
        max-height: 180px;
        min-height: 140px;
    }

    .main-page-carousel .carousel-control {
        width: 40px;
        height: 40px;
    }

    .shop-by-category-banner .category-item {
        flex: 0 1 120px;
    }

    .brand-items-wrapper img {
        height: 70px;
        max-width: 120px;
    }
}

/* =============================================== */
/* == الأجهزة اللوحية (768px - 1024px) == */
/* =============================================== */
@media (min-width: 768px) and (max-width: 1024px) {
    .header-top {
        flex-direction: row;
        gap: 15px;
        padding: 12px;
    }

    .logo-container {
        flex: 0 0 auto;
    }

    .header-search-container {
        flex: 1;
        max-width: 400px;
        margin: 0;
    }

    .auth-nav {
        flex: 0 0 auto;
        gap: 12px;
    }

    .products-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
        padding: 0 15px;
    }

    .product-card img {
        height: 180px;
    }

    .container {
        padding: 15px;
    }

    .form-container {
        padding: 30px;
        margin: 20px auto;
        max-width: 600px;
    }

    .header-bottom {
        min-height: 60px;
        padding: 12px 15px;
    }

    .category-menu-btn {
        padding: 10px 18px;
        font-size: 1.05rem;
        min-height: 44px;
    }

    .nav-link {
        padding: 10px 18px;
        font-size: 1rem;
    }

    .scroll-arrow {
        width: 44px;
        height: 44px;
    }

    .main-page-carousel {
        aspect-ratio: 16/6;
        max-height: 200px;
        min-height: 160px;
    }

    .main-page-carousel .carousel-control {
        width: 44px;
        height: 44px;
    }

    .shop-by-category-banner .category-item {
        flex: 0 1 140px;
    }

    .brand-items-wrapper img {
        height: 80px;
        max-width: 140px;
    }
}

/* =============================================== */
/* == الشاشات الكبيرة (أكثر من 1024px) == */
/* =============================================== */
@media (min-width: 1025px) {
    .header-top {
        flex-direction: row;
        gap: 20px;
        padding: 15px;
    }

    .logo-container {
        flex: 0 0 auto;
    }

    .header-search-container {
        flex: 1;
        max-width: 600px;
        margin: 0 20px;
    }

    .auth-nav {
        flex: 0 0 auto;
        gap: 15px;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
        gap: 30px;
        padding: 0 20px;
    }

    .product-card img {
        height: 200px;
    }

    .container {
        padding: 20px;
    }

    .form-container {
        padding: 40px;
        margin: 50px auto;
        max-width: 600px;
    }

    .header-bottom {
        min-height: 60px;
        padding: 15px 20px;
    }

    .category-menu-btn {
        padding: 12px 20px;
        font-size: 1.1rem;
        min-height: 44px;
    }

    .nav-link {
        padding: 12px 20px;
        font-size: 1.05rem;
    }

    .scroll-arrow {
        width: 48px;
        height: 48px;
    }

    .main-page-carousel {
        aspect-ratio: 16/6;
        max-height: 240px;
        min-height: 180px;
    }

    .main-page-carousel .carousel-control {
        width: 48px;
        height: 48px;
    }

    .shop-by-category-banner .category-item {
        flex: 0 1 160px;
    }

    .brand-items-wrapper img {
        height: 100px;
        max-width: 160px;
    }
}

/* =============================================== */
/* == إصلاحات عامة لجميع الأجهزة == */
/* =============================================== */

/* ضمان عدم إخفاء الهيدر الفرعي */
.header-bottom {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    overflow: visible !important;
    z-index: 99 !important;
}

/* ضمان ظهور الأزرار بشكل صحيح */
.btn-login, .btn-register, .login-button, .register-button {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    white-space: nowrap !important;
}

/* ضمان ظهور الأيقونات بشكل صحيح */
.btn-login svg, .btn-register svg,
.login-button svg, .register-button svg {
    flex-shrink: 0 !important;
    display: block !important;
}

/* إصلاح شريط البحث */
.header-search-container {
    display: flex !important;
    align-items: stretch !important;
    border-radius: 6px !important;
    overflow: hidden !important;
}

.header-search-container select,
.header-search-container input,
.header-search-container button {
    border: none !important;
    outline: none !important;
    font-family: inherit !important;
}

/* إصلاح القائمة الجانبية */
.category-sidebar {
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
}

.category-list {
    flex: 1 !important;
    overflow-y: auto !important;
}

/* إصلاح الحاويات */
.container {
    box-sizing: border-box !important;
    width: 100% !important;
}

/* إصلاح النماذج */
.form-container {
    box-sizing: border-box !important;
    width: 100% !important;
}

.form-group {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
}

.form-group input,
.form-group select,
.form-group textarea {
    box-sizing: border-box !important;
    width: 100% !important;
    border-radius: 6px !important;
    border: 2px solid #ddd !important;
    transition: border-color 0.3s ease !important;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #3f51b5 !important;
    box-shadow: 0 0 0 3px rgba(63, 81, 181, 0.2) !important;
}

/* إصلاح الشبكات */
.products-grid {
    display: grid !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.product-card {
    display: flex !important;
    flex-direction: column !important;
    box-sizing: border-box !important;
}

/* إصلاح الصور */
img {
    max-width: 100% !important;
    height: auto !important;
    display: block !important;
}

/* إصلاح الأزرار */
button, a.btn {
    box-sizing: border-box !important;
    cursor: pointer !important;
    border: none !important;
    font-family: inherit !important;
    transition: all 0.3s ease !important;
}

button:active, a.btn:active {
    transform: scale(0.98) !important;
}

/* إصلاح النصوص */
body {
    font-family: 'Tajawal', 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
}

/* إصلاح الفوتر */
footer {
    width: 100% !important;
    box-sizing: border-box !important;
}

/* إصلاح الإعلانات */
.announcements-section {
    width: 100% !important;
    box-sizing: border-box !important;
}

.main-page-carousel {
    width: 100% !important;
    box-sizing: border-box !important;
}

/* إصلاح العلامات التجارية */
.shop-by-brand-section {
    width: 100% !important;
    box-sizing: border-box !important;
}

.brand-items-wrapper {
    display: flex !important;
    gap: 20px !important;
    padding: 15px !important;
}

/* إصلاح الفئات */
.shop-by-category-banner {
    width: 100% !important;
    box-sizing: border-box !important;
}

.category-items-wrapper {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    gap: 15px !important;
    padding: 15px !important;
}

/* =============================================== */
/* == دعم الأجهزة ذات الشاشات العريضة جداً == */
/* =============================================== */
@media (min-width: 1440px) {
    .container {
        max-width: 1400px !important;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)) !important;
        gap: 35px !important;
    }
}

@media (min-width: 1920px) {
    .container {
        max-width: 1600px !important;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)) !important;
        gap: 40px !important;
    }
}

/* =============================================== */
/* == دعم الأجهزة ذات الشاشات الطويلة == */
/* =============================================== */
@media (min-height: 1000px) {
    body {
        display: flex !important;
        flex-direction: column !important;
    }

    main {
        flex: 1 !important;
    }

    footer {
        margin-top: auto !important;
    }
}

/* =============================================== */
/* == دعم الأجهزة ذات الشاشات القصيرة == */
/* =============================================== */
@media (max-height: 600px) {
    header {
        padding: 8px !important;
    }

    .form-container {
        margin: 10px auto !important;
        padding: 15px !important;
    }

    .header-bottom {
        min-height: 50px !important;
    }
}

/* =============================================== */
/* == دعم الأجهزة عالية الدقة (High DPI) == */
/* =============================================== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    body {
        -webkit-font-smoothing: antialiased !important;
        -moz-osx-font-smoothing: grayscale !important;
    }

    img {
        image-rendering: -webkit-optimize-contrast !important;
    }

    .login-button svg, .register-button svg {
        width: 22px !important;
        height: 22px !important;
    }
}

/* =============================================== */
/* == دعم الأجهزة منخفضة الدقة (Low DPI) == */
/* =============================================== */
@media (-webkit-max-device-pixel-ratio: 1), (max-resolution: 96dpi) {
    * {
        will-change: auto !important;
    }
}

/* =============================================== */
/* == دعم الأجهزة ذات الاتصال البطيء == */
/* =============================================== */
@media (prefers-reduced-data: reduce) {
    img {
        loading: lazy !important;
    }

    video {
        loading: lazy !important;
    }

    * {
        animation: none !important;
        transition: none !important;
    }
}

/* =============================================== */
/* == دعم تقليل الحركات == */
/* =============================================== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
