/* 
===========================================
تحسينات الاستجابة للهواتف النقالة - متجر ألعاب ريمي
===========================================
*/

/* Small Mobile Devices (Max 480px) */
@media screen and (max-width: 480px) {
    
    /* Product Image Container - Ultra Responsive */
    .product-image-container {
        height: 180px !important;
        border-radius: 8px;
        margin-bottom: 0.8rem;
    }
    
    .product-card .card-img-top {
        padding: 6px;
        transition: transform 0.3s ease;
    }
    
    .product-card:hover .card-img-top {
        transform: scale(1.03);
    }
    
    /* Product Card Mobile Optimization */
    .product-card {
        margin-bottom: 1rem;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }
    
    .product-card .card-body {
        padding: 0.7rem 0.6rem;
    }
    
    .product-card .card-title {
        font-size: 0.9rem;
        line-height: 1.2;
        margin-bottom: 0.4rem;
        font-weight: 600;
        color: #2c3e50;
    }
    
    .product-card .card-text {
        font-size: 0.75rem;
        line-height: 1.3;
        color: #6c757d;
        margin-bottom: 0.5rem;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        line-clamp: 2;
        overflow: hidden;
        height: 2.6rem;
    }
    
    /* Price Display Mobile */
    .price {
        font-size: 1.1rem;
        font-weight: 700;
        color: #e74c3c;
    }
    
    .old-price {
        font-size: 0.8rem;
        text-decoration: line-through;
        color: #95a5a6;
    }
    
    /* Button Adjustments */
    .btn-sm {
        font-size: 0.75rem;
        padding: 0.4rem 0.8rem;
        border-radius: 6px;
    }
    
    /* Quality Badge Mobile */
    .quality-badge {
        top: 6px;
        right: 6px;
        padding: 3px 6px;
        font-size: 0.6rem;
        border-radius: 8px;
    }
    
    /* Image Description Mobile */
    .image-description {
        font-size: 0.65rem;
        padding: 0.5rem 0.3rem 0.3rem;
    }
    
    /* Grid Layout Mobile */
    .row {
        margin-left: -8px;
        margin-right: -8px;
    }
    
    .row > * {
        padding-left: 8px;
        padding-right: 8px;
    }
    
    /* Hero Section Mobile */
    .hero-section {
        padding: 2rem 0;
    }
    
    .hero-section h1 {
        font-size: 1.8rem;
        margin-bottom: 0.8rem;
    }
    
    .hero-section p {
        font-size: 1rem;
        margin-bottom: 1rem;
    }
    
    /* Container Mobile */
    .container {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    /* Category Cards Mobile */
    .card h5 {
        font-size: 1rem;
    }
    
    .card p {
        font-size: 0.85rem;
        line-height: 1.4;
    }
    
    /* Flash Messages Mobile */
    .alert {
        font-size: 0.85rem;
        padding: 0.7rem;
        margin-bottom: 0.8rem;
    }
    
    /* Search Form Mobile */
    .form-control {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.7rem 0.8rem;
    }
    
    .form-select {
        font-size: 0.9rem;
        padding: 0.7rem;
    }
}

/* Medium Mobile Devices (481px - 576px) */
@media screen and (min-width: 481px) and (max-width: 576px) {
    
    .product-image-container {
        height: 200px;
        border-radius: 10px;
    }
    
    .product-card .card-img-top {
        padding: 8px;
    }
    
    .product-card .card-title {
        font-size: 0.95rem;
    }
    
    .product-card .card-text {
        font-size: 0.8rem;
    }
    
    .price {
        font-size: 1.2rem;
    }
}

/* Touch Optimization */
@media (hover: none) and (pointer: coarse) {
    
    /* Remove hover effects on touch devices */
    .product-card:hover {
        transform: none;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    }
    
    .product-card:hover .card-img-top {
        transform: none;
    }
    
    /* Make buttons more touch-friendly */
    .btn {
        min-height: 44px;
        min-width: 44px;
        padding: 0.75rem 1rem;
    }
    
    .btn-sm {
        min-height: 40px;
        padding: 0.6rem 0.9rem;
    }
    
    /* Larger touch targets for links */
    .nav-link {
        padding: 0.8rem 1rem;
    }
    
    /* Image taps */
    .product-image-container {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
        cursor: pointer;
    }
}

/* Landscape Mobile Optimization */
@media screen and (max-height: 480px) and (orientation: landscape) {
    
    .hero-section {
        padding: 1.5rem 0;
    }
    
    .hero-section h1 {
        font-size: 1.5rem;
    }
    
    .product-image-container {
        height: 160px;
    }
    
    .section-title {
        margin-bottom: 2rem;
        font-size: 1.5rem;
    }
}

/* Loading Performance on Mobile */
@media screen and (max-width: 768px) {
    
    /* Lazy loading images */
    .product-card img {
        content-visibility: auto;
        contain-intrinsic-size: 200px;
    }
    
    /* Reduce animation complexity on low-end devices */
    @media (prefers-reduced-motion: reduce) {
        .product-card,
        .product-card img,
        .floating-social a {
            transition: none;
            animation: none;
        }
    }
    
    /* Performance hint for images */
    .product-card img {
        image-rendering: optimizeSpeed;
    }
}

/* High DPI Displays (Retina) */
@media (-webkit-min-device-pixel-ratio: 2),
       (min-resolution: 192dpi) {
    
    .product-card img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
    
    .quality-badge {
        box-shadow: 0 1px 4px rgba(40, 167, 69, 0.4);
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    
    .image-placeholder {
        background: linear-gradient(145deg, #2c3e50, #34495e);
        color: #bdc3c7;
    }
    
    .product-image-container {
        background: linear-gradient(145deg, #2c3e50, #34495e);
    }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
    
    .product-card,
    .product-card img,
    .floating-social a,
    .btn {
        transition: none;
        animation: none;
    }
}

/* Focus styles for keyboard navigation */
.product-card:focus-within {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.btn:focus {
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

/* Image Error Handling */
.product-card img[src=""],
.product-card img:not([src]) {
    opacity: 0;
    display: none;
}

/* Progressive Image Loading */
.product-card img {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

.product-card img[loading="lazy"] {
    transition: opacity 0.3s ease;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Faster taps on mobile */
.btn, .nav-link, .product-card {
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

/* Better contrast for readability */
@media screen and (max-width: 576px) {
    .card-text {
        color: #495057;
        font-weight: 500;
    }
    
    .price {
        color: #dc3545;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    }
}
