/* =========================================================
   Mobile Specific Fixes - إصلاحات خاصة بالهواتف
   ========================================================= */

/* منع التمرير الأفقي تماماً */
html, body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
    position: relative;
}

/* إصلاح Container على الشاشات الصغيرة */
@media (max-width: 575.98px) {
    .container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
        max-width: 100% !important;
    }
    
    /* إصلاح Row spacing */
    .row {
        margin-left: -0.5rem !important;
        margin-right: -0.5rem !important;
    }
    
    .row > * {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }
    
    .ron-products-grid {
        --bs-gutter-x: 0.75rem;
        --bs-gutter-y: 0.75rem;
    }

    .ron-products-grid > [class*="col-"] {
        flex: 0 0 50% !important;
        max-width: 50% !important;
    }
    
    /* إصلاح Cards spacing */
    .card, .custom-card {
        margin-bottom: 1rem;
    }
    
    /* إصلاح Navbar على الهواتف */
    .navbar-collapse {
        max-height: 80vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* إصلاح Carousel على الهواتف */
    .carousel-item {
        min-height: 350px !important;
    }
    
    .carousel-caption {
        padding: 1rem !important;
    }
    
    /* إصلاح Buttons */
    .btn {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Thumb-friendly: bigger tap targets on product pages */
    .product-card .btn,
    .offcanvas .btn {
        min-height: 48px;
        padding-top: .8rem;
        padding-bottom: .8rem;
    }

    .product-card .btn.btn-sm {
        min-height: 42px;
        padding-top: .6rem;
        padding-bottom: .6rem;
    }

    .product-card .card-body {
        padding: 1rem !important;
    }

    .product-card h5 {
        font-size: 1.05rem;
        line-height: 1.35;
    }

    .product-card .badge {
        font-size: .85rem;
    }

    /* Cart offcanvas: keep actions reachable */
    .offcanvas-body {
        padding-bottom: 120px;
    }

    .offcanvas .ron-cart-actions {
        position: sticky;
        bottom: 0;
        background: #fff;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        z-index: 2;
    }

    /* إصلاح Images */
    img {
        max-width: 100% !important;
        height: auto !important;
    }
    
    /* إصلاح Tables */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
        overflow-x: auto;
    }
    
    .table-responsive > .table {
        min-width: 0 !important;
        width: 100% !important;
    }

    .table-responsive > .table th,
    .table-responsive > .table td {
        white-space: normal !important;
        overflow-wrap: anywhere;
        word-break: break-word;
    }
    
    /* إصلاح Forms */
    .form-control,
    .form-select {
        font-size: 16px !important; /* منع zoom على iOS */
    }
    
    /* إصلاح Modals */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    /* إصلاح Dropdowns */
    .dropdown-menu {
        max-width: calc(100vw - 2rem);
        left: 1rem !important;
        right: 1rem !important;
    }

    .language-switcher {
        padding: 0.5rem 0 !important;
    }

    .language-switcher .lang-info {
        gap: 0.75rem;
        font-size: 0.9rem;
    }

    .language-switcher .lang-actions {
        gap: 0.5rem;
    }

    .language-switcher .ron-social-links {
        display: none;
    }

    .navbar {
        padding-top: 0.4rem;
        padding-bottom: 0.4rem;
    }

    .navbar-brand {
        font-size: 1.05rem;
    }

    #checkout .card-body {
        padding: 1rem !important;
    }

    #checkout h1 {
        font-size: 1.45rem;
    }

    #checkout .form-control,
    #checkout .btn {
        border-radius: 0.9rem;
    }

    .mobile-promo-banner {
        max-width: 100vw;
    }

    .mobile-promo-banner .promo-slider {
        display: inline-flex;
        width: max-content;
        will-change: transform;
    }

    .ron-hero-bg {
        inset: 0 !important;
    }
}

@supports (padding: max(0px)) {
    @media (max-width: 575.98px) {
        .container {
            padding-left: max(1rem, env(safe-area-inset-left)) !important;
            padding-right: max(1rem, env(safe-area-inset-right)) !important;
        }
    }
}

/* إصلاحات خاصة للشاشات الصغيرة جداً (360px) */
@media (max-width: 360px) {
    .container {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    
    .carousel-item {
        min-height: 300px !important;
    }
    
    .display-3 {
        font-size: 1.5rem !important;
    }
    
    .display-5 {
        font-size: 1.25rem !important;
    }
    
    .btn-lg {
        font-size: 0.9rem !important;
        padding: 0.5rem 1rem !important;
    }
}

/* إصلاحات للشاشات المتوسطة (Tablets) */
@media (min-width: 576px) and (max-width: 767.98px) {
    .container {
        max-width: 540px;
    }
    
    .product-img-container {
        height: 220px;
    }
}

/* إصلاحات للشاشات الكبيرة (Tablets Landscape) */
@media (min-width: 768px) and (max-width: 991.98px) {
    .container {
        max-width: 720px;
    }
}

/* Touch Improvements */
@media (hover: none) and (pointer: coarse) {
    /* تحسين اللمس على الأجهزة اللوحية والهواتف */
    .btn,
    .nav-link,
    .card,
    .product-card {
        -webkit-tap-highlight-color: rgba(25, 135, 84, 0.2);
    }
    
    /* زيادة حجم مناطق اللمس */
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .nav-link {
        padding: 1rem !important;
    }
}

/* Landscape Orientation Fixes */
@media (max-width: 767.98px) and (orientation: landscape) {
    .carousel-item {
        min-height: 300px !important;
    }
    
    .navbar {
        padding: 0.5rem 0;
    }
}

/* High DPI Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

@media print {
    .navbar,
    .whatsapp-float,
    .language-switcher,
    footer,
    .btn {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
    
    .container {
        max-width: 100% !important;
        padding: 0 !important;
    }
}
