/* ========================================
   Mobile-First Responsive Fixes
   ملف إصلاحات خاصة بالموبايل
   ======================================== */

/* Base Mobile Styles - Default for all screens */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    min-width: 320px;
    overflow-x: hidden;
}

img {
    max-width: 100%;
    height: auto;
}

/* Container Responsive */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

/* ========================================
   Mobile Specific (< 768px)
   ======================================== */
@media (max-width: 767px) {
    /* Typography */
    html {
        font-size: 14px;
    }
    
    body {
        font-size: 14px;
        line-height: 1.5;
    }
    
    h1 {
        font-size: 1.75rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    h3 {
        font-size: 1.25rem;
    }
    
    /* Container */
    .container {
        padding: 0 10px;
    }
    
    /* Header */
    .header-top {
        padding: 8px 0;
        font-size: 12px;
    }
    
    .header-top .container {
        flex-direction: column;
        gap: 5px;
        text-align: center;
    }
    
    .header-info {
        gap: 12px;
    }
    
    .header-info-item {
        font-size: 0.75rem;
        gap: 4px;
    }
    
    .header-info-item i {
        font-size: 0.8rem;
    }
    
    .contact-info {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
        font-size: 11px;
    }
    
    .header-main {
        padding: 10px 0;
    }
    
    .logo {
        font-size: 1.25rem;
    }
    
    /* Navigation */
    .nav-menu {
        position: fixed;
        top: 0;
        right: -100%;
        width: 280px;
        max-width: 85vw;
        height: 100vh;
        background: var(--bg-color);
        padding: 80px 20px 20px;
        box-shadow: -2px 0 10px rgba(0,0,0,0.1);
        transition: right 0.3s ease;
        z-index: 9999;
        overflow-y: auto;
    }
    
    body[dir="rtl"] .nav-menu {
        right: auto;
        left: -100%;
        transition: left 0.3s ease;
    }
    
    .nav-menu.active {
        right: 0;
    }
    
    body[dir="rtl"] .nav-menu.active {
        left: 0;
    }
    
    .nav-menu ul {
        flex-direction: column;
        gap: 15px;
    }
    
    .nav-menu li a {
        font-size: 16px;
        padding: 10px 15px;
        display: block;
        border-bottom: 1px solid var(--border-color);
    }
    
    /* Mobile Menu Button */
    .mobile-menu-toggle {
        display: flex;
        flex-direction: column;
        gap: 4px;
        width: 30px;
        height: 24px;
        cursor: pointer;
        z-index: 10000;
    }
    
    .mobile-menu-toggle span {
        display: block;
        width: 100%;
        height: 3px;
        background: var(--primary-color);
        transition: all 0.3s ease;
        border-radius: 2px;
    }
    
    .mobile-menu-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(7px, 7px);
    }
    
    .mobile-menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }
    
    .mobile-menu-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -7px);
    }
    
    /* Hero Section */
    .hero {
        min-height: 50vh;
        padding: 40px 0;
    }
    
    .hero-title {
        font-size: 1.5rem !important;
        line-height: 1.3;
        margin-bottom: 10px;
    }
    
    .hero-subtitle {
        font-size: 0.9rem !important;
        margin-bottom: 20px;
    }
    
    .hero-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .hero-buttons .btn {
        width: 100%;
        justify-content: center;
    }
    
    /* Sections */
    section {
        padding: 30px 0;
    }
    
    .section-title {
        font-size: 1.5rem !important;
        margin-bottom: 10px;
    }
    
    .section-subtitle {
        font-size: 0.9rem !important;
    }
    
    /* Grids */
    .categories-grid,
    .products-grid,
    .features-grid,
    .grid,
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
    
    /* Category Cards */
    .category-card {
        margin-bottom: 15px;
    }
    
    .category-image {
        height: 180px !important;
    }
    
    .category-content {
        padding: 15px;
    }
    
    .category-title {
        font-size: 1.1rem;
    }
    
    /* Product Cards */
    .product-card,
    .card {
        margin-bottom: 15px;
    }
    
    .product-image,
    .card-image {
        height: 200px !important;
        padding-top: 0 !important;
    }
    
    .product-image img,
    .card-image img {
        position: static !important;
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    
    .product-info,
    .card-body {
        padding: 15px;
    }
    
    .product-title,
    .card-title {
        font-size: 1rem;
        margin-bottom: 8px;
    }
    
    .product-description,
    .card-text {
        font-size: 0.85rem;
        line-height: 1.4;
    }
    
    .product-footer,
    .card-footer {
        padding: 12px 15px;
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .product-price,
    .card-price {
        font-size: 1.1rem;
    }
    
    .product-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    /* Buttons */
    .btn {
        font-size: 14px !important;
        padding: 10px 20px !important;
    }
    
    .btn-lg {
        font-size: 15px !important;
        padding: 12px 24px !important;
    }
    
    .btn-sm {
        font-size: 12px !important;
        padding: 8px 16px !important;
    }
    
    /* Footer */
    .footer-main {
        padding: 30px 0;
    }
    
    .footer-content {
        grid-template-columns: 1fr !important;
        gap: 25px;
        text-align: center;
    }
    
    .footer-section {
        padding: 0;
    }
    
    .footer-section h3 {
        font-size: 1.1rem;
        margin-bottom: 15px;
    }
    
    .footer-links {
        flex-direction: column;
        gap: 8px;
    }
    
    .footer-bottom {
        padding: 15px 0;
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    /* Social Media */
    .social-media {
        justify-content: center;
        gap: 10px;
    }
    
    .social-link {
        width: 32px;
        height: 32px;
        font-size: 14px;
        padding: 6px;
    }
    
    /* Forms */
    input,
    textarea,
    select {
        font-size: 16px !important; /* Prevents zoom on iOS */
        padding: 12px;
    }
    
    .form-group {
        margin-bottom: 15px;
    }
    
    /* Tables */
    table {
        font-size: 12px;
    }
    
    table th,
    table td {
        padding: 8px 5px;
    }
    
    /* Modal */
    .modal-content {
        max-width: 95%;
        margin: 10px;
    }
    
    /* Utility Classes */
    .d-sm-none {
        display: none !important;
    }
    
    .d-sm-block {
        display: block !important;
    }
    
    /* Touch Improvements */
    button,
    a,
    .clickable {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Scroll to Top Button - HIDDEN (مخفي - نستخدم scroll-top من footer.php) */
    .scroll-to-top {
        display: none !important;
    }
}

/* ========================================
   Small Mobile (< 480px)
   ======================================== */
@media (max-width: 479px) {
    html {
        font-size: 13px;
    }
    
    .container {
        padding: 0 8px;
    }
    
    .hero-title {
        font-size: 1.3rem !important;
    }
    
    .hero-subtitle {
        font-size: 0.85rem !important;
    }
    
    .section-title {
        font-size: 1.3rem !important;
    }
    
    .category-image,
    .product-image {
        height: 160px !important;
    }
    
    .btn {
        font-size: 13px !important;
        padding: 9px 18px !important;
    }
}

/* ========================================
   Tablet Portrait (768px - 1023px)
   ======================================== */
@media (min-width: 768px) and (max-width: 1023px) {
    .container {
        padding: 0 20px;
    }
    
    .categories-grid,
    .products-grid,
    .grid-3,
    .grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 20px;
    }
    
    .hero-title {
        font-size: 2rem !important;
    }
    
    .hero-subtitle {
        font-size: 1rem !important;
    }
    
    .section-title {
        font-size: 1.8rem !important;
    }
}

/* ========================================
   Landscape Mobile (max-height: 500px)
   ======================================== */
@media (max-height: 500px) and (orientation: landscape) {
    .hero {
        min-height: auto;
        padding: 30px 0;
    }
    
    .nav-menu {
        padding-top: 60px;
    }
    
    section {
        padding: 20px 0;
    }
}

/* ========================================
   Fix Overflow Issues
   ======================================== */
body,
html {
    overflow-x: hidden;
    width: 100%;
}

.container {
    overflow-x: hidden;
}

/* Fix Image Overflow */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Fix Grid Overflow */
.grid,
.grid-2,
.grid-3,
.grid-4,
.categories-grid,
.products-grid {
    width: 100%;
    overflow: hidden;
}

/* ========================================
   Page Header Section - Mobile Optimization
   تحسين عرض الهيدر العلوي للصفحات على الموبايل
   ======================================== */
@media (max-width: 768px) {
    .page-header-section {
        padding: 100px 0 40px !important;
        margin-top: 0 !important;
        min-height: auto !important;
    }
    
    .page-header-content {
        padding: 0 15px !important;
    }
    
    .page-header-content h1 {
        font-size: 1.75rem !important;
        line-height: 1.3 !important;
        margin-bottom: 12px !important;
        padding: 0 !important;
    }
    
    .page-header-content p {
        font-size: 0.95rem !important;
        line-height: 1.5 !important;
        margin-bottom: 20px !important;
        opacity: 0.95 !important;
    }
    
    .breadcrumb {
        font-size: 0.85rem !important;
        padding: 8px 20px !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 8px !important;
    }
    
    .breadcrumb a,
    .breadcrumb span {
        white-space: nowrap !important;
    }
    
    .breadcrumb i {
        font-size: 0.7rem !important;
    }
    
    /* Header Icon */
    .header-icon,
    .header-icon-animated {
        font-size: 2.5rem !important;
        margin-bottom: 15px !important;
    }
    
    .header-icon i,
    .header-icon-animated i {
        font-size: 2.5rem !important;
    }
}

@media (max-width: 480px) {
    .page-header-section {
        padding: 90px 0 35px !important;
    }
    
    .page-header-content h1 {
        font-size: 1.5rem !important;
    }
    
    .page-header-content p {
        font-size: 0.9rem !important;
    }
    
    .breadcrumb {
        font-size: 0.8rem !important;
        padding: 6px 15px !important;
    }
    
    .header-icon,
    .header-icon-animated {
        font-size: 2rem !important;
    }
    
    .header-icon i,
    .header-icon-animated i {
        font-size: 2rem !important;
    }
    
    /* إخفاء جميع أزرار العودة للأعلى الزائدة */
    .scroll-to-top,
    .back-to-top {
        display: none !important;
    }
    
    /* إظهار زر footer.php فقط */
    .scroll-top {
        display: block !important;
    }
    
    /* تثبيت زر العودة للأعلى في اليسار فقط */
    .scroll-top,
    body[dir="rtl"] .scroll-top,
    body[dir="ltr"] .scroll-top {
        left: 20px !important;
        right: auto !important;
    }
    
    /* تعديل موقع زر واتساب للموبايل */
    .whatsapp-float {
        bottom: 20px !important;
        right: 20px !important;
        width: 55px !important;
        height: 55px !important;
        font-size: 1.6rem !important;
    }
    
    body[dir="rtl"] .whatsapp-float {
        right: auto !important;
        left: 20px !important;
    }
}
