/* ═══════════════════════════════════════════════════════════════════
   TOUCH FEEDBACK - تأثيرات اللمس للموبايل
   ═══════════════════════════════════════════════════════════════════ */

@media (hover: none) and (pointer: coarse) {
    .product-card:active {
        transform: scale(0.98);
    }

    .add-btn:active {
        transform: scale(0.9);
    }

    .category-item:active {
        transform: scale(0.95);
    }

    .qty-btn:active {
        background: var(--primary);
        color: white;
        border-color: var(--primary);
    }

    .floating-cart-btn:active {
        transform: scale(0.96);
    }
}

/* تعطيل hover effects على الموبايل */
@media (hover: none) {
    .product-card:hover {
        transform: none;
        box-shadow: var(--shadow-card);
    }

    .product-card:hover .product-img {
        transform: none;
    }

    .add-btn:hover {
        transform: none;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE - التجاوب
   ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
    .logo h1 {
        font-size: 1.2rem;
    }

    .section-title {
        font-size: 1.3rem;
    }

    .order-types {
        grid-template-columns: 1fr;
    }

    .type-option span {
        padding: 14px;
    }

    .product-card {
        min-height: 95px;
    }

    .product-img-wrapper {
        width: 95px;
        min-width: 95px;
        height: 95px;
    }

    .product-info {
        padding: 10px 12px;
    }

    .product-title {
        font-size: 0.9rem;
    }

    .product-desc {
        font-size: 0.75rem;
        margin-bottom: 4px;
    }

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

    .add-btn {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .floating-cart-bar {
        padding: 12px 16px;
    }

    .floating-cart-btn {
        padding: 12px 24px;
        font-size: 0.95rem;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   PERFORMANCE - تحسينات الأداء
   ═══════════════════════════════════════════════════════════════════ */

.add-btn,
.category-item,
.cart-icon,
.header-install-btn,
.floating-cart-btn {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.product-img {
    contain: layout style paint;
}

/* تحسين الـ Layout Shift */
.products-grid {
    contain: layout style;
}

.product-img-wrapper {
    contain: strict;
    content-visibility: auto;
    contain-intrinsic-size: 110px 110px;
}

/* ═══════════════════════════════════════════════════════════════════
   ACCESSIBILITY - إمكانية الوصول
   ═══════════════════════════════════════════════════════════════════ */

/* Skip Link */
.skip-link {
    position: absolute;
    top: -100%;
    right: 0;
    background: var(--primary);
    color: white;
    padding: 12px 24px;
    z-index: 9999;
    border-radius: 0 0 8px 8px;
    font-weight: 600;
    text-decoration: none;
    transition: top 0.3s ease;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid var(--primary-dark);
    outline-offset: 2px;
}

/* Screen Reader Only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus Styles - تحسين وضوح التركيز */
:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.add-btn:focus-visible,
.category-item:focus-visible,
.floating-cart-btn:focus-visible,
.checkout-btn:focus-visible,
.confirm-btn:focus-visible {
    outline: 3px solid var(--primary-dark);
    outline-offset: 3px;
    box-shadow: 0 0 0 6px var(--primary-glow);
}

/* تحسين النماذج للموبايل */
input,
textarea,
select,
button {
    font-size: 16px;
    /* يمنع zoom على iOS */
}

/* تحسين fieldset */
fieldset.form-group {
    border: none;
    padding: 0;
    margin: 0 0 18px 0;
}

fieldset.form-group legend {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
    padding: 0;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    :root {
        --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
        --shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.2);
    }

    .product-card {
        border: 2px solid var(--text-primary);
    }

    .category-item {
        border: 2px solid var(--text-secondary);
    }

    .category-item.active {
        border-color: var(--primary);
    }
}

/* Reduced Motion - احترام تفضيلات المستخدم */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    html {
        scroll-behavior: auto;
    }

    .product-card {
        opacity: 1;
        transform: none;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   MOBILE OPTIMIZATIONS - تحسينات خاصة للجوال
   ═══════════════════════════════════════════════════════════════════ */

/* Safe Area for notched phones */
@supports (padding: max(0px)) {
    .main-header {
        padding-top: max(16px, env(safe-area-inset-top));
    }

    .floating-cart-bar {
        padding-bottom: max(14px, env(safe-area-inset-bottom));
    }

    body {
        padding-bottom: max(100px, calc(80px + env(safe-area-inset-bottom)));
    }
}

/* PWA Standalone: ضمان تغطية أعلى الشاشة بلون الهيدر */
@media all and (display-mode: standalone) {
    html {
        background-color: var(--primary, #d97706);
    }
}

/* تحسين الأداء على الأجهزة الضعيفة */
@media (max-width: 600px) {
    .product-img-wrapper::after {
        display: none;
    }

    .cart-icon,
    .header-install-btn {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}

/* تحسين touch targets للجوال */
@media (pointer: coarse) {
    .add-btn {
        min-width: 40px;
        min-height: 40px;
    }

    .qty-btn {
        min-width: 44px;
        min-height: 44px;
    }

    .category-item {
        min-height: 44px;
        padding: 12px 20px;
    }

    .close-cart,
    .close-checkout {
        min-width: 44px;
        min-height: 44px;
    }
}

/* Print Styles */
@media print {

    .main-header,
    .categories-nav,
    .floating-cart-bar,
    .cart-modal,
    .checkout-modal,
    .success-modal,
    .toast-container,
    .add-btn,
    .skip-link {
        display: none !important;
    }

    body {
        padding: 0;
        background: white;
    }

    .product-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

