/*
 * MR Saeid - Mobile Responsive Fixes
 * ملف إصلاحات التجاوب للموبايل
 * يُضاف بعد جميع ملفات CSS الأخرى
 * لا يؤثر على تصميم الويب (Desktop)
 */

/* ===== إصلاحات للشاشات الصغيرة (موبايل) ===== */
@media (max-width: 768px) {
    
    /* --- الـ Navbar --- */
    nav,
    .navbar,
    nav.fixed {
        padding: 0.75rem 0.5rem !important;
    }
    
    nav .container {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    
    /* تصغير الشعار */
    nav a.text-2xl,
    nav .text-2xl {
        font-size: 1.25rem !important;
    }
    
    nav a.text-2xl i,
    nav .text-2xl i {
        font-size: 1.5rem !important;
    }
    
    /* أزرار الـ Header */
    nav .flex.gap-3,
    nav .flex.gap-2 {
        gap: 0.5rem !important;
    }
    
    nav .neu-btn,
    nav a.neu-btn {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.75rem !important;
    }
    
    /* إخفاء نص "دخول" و"حساب جديد" وإظهار الأيقونات فقط على الموبايل الصغير */
    @media (max-width: 400px) {
        nav .neu-btn-default,
        nav .neu-btn-primary {
            padding: 0.5rem !important;
            min-width: auto !important;
        }
    }
    
    /* حقل البحث */
    nav input[type="text"],
    nav .search-input {
        width: 120px !important;
        font-size: 0.875rem !important;
        padding: 0.5rem 0.75rem !important;
    }
    
    nav input[type="text"]:focus {
        width: 150px !important;
    }
    
    /* زر البحث */
    nav button.bg-primary,
    nav .search-btn {
        padding: 0.5rem 0.75rem !important;
    }
    
    /* --- Hero Section --- */
    .hero-section,
    section.pt-32,
    main > section:first-child {
        padding-top: 6rem !important;
        padding-bottom: 2rem !important;
    }
    
    /* العنوان الرئيسي */
    h1.text-4xl,
    h1.text-5xl,
    .hero-title {
        font-size: 1.75rem !important;
        line-height: 1.3 !important;
        padding: 0 0.5rem !important;
    }
    
    h1.text-3xl {
        font-size: 1.5rem !important;
    }
    
    /* العنوان الفرعي */
    .hero-subtitle,
    h2.text-xl,
    h2.text-2xl {
        font-size: 1rem !important;
        padding: 0 0.5rem !important;
    }
    
    /* الوصف */
    .hero-description,
    p.text-lg,
    p.text-xl {
        font-size: 0.9rem !important;
        padding: 0 1rem !important;
        line-height: 1.6 !important;
    }
    
    /* أزرار Hero */
    .hero-buttons,
    .flex.gap-4.justify-center {
        flex-direction: column !important;
        gap: 0.75rem !important;
        padding: 0 1rem !important;
    }
    
    .hero-buttons a,
    .hero-buttons button {
        width: 100% !important;
        justify-content: center !important;
    }
    
    /* --- قسم الصفوف الدراسية --- */
    .grades-section,
    section h2 + .grid {
        padding: 0 0.75rem !important;
    }
    
    /* شبكة الصفوف */
    .grid.grid-cols-2,
    .grid.grid-cols-3,
    .grid.md\\:grid-cols-2,
    .grid.md\\:grid-cols-3,
    .grid.lg\\:grid-cols-3 {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    /* بطاقات الصفوف */
    .grade-card,
    .subject-card,
    .neu-card {
        margin: 0 !important;
        padding: 1.25rem !important;
    }
    
    /* --- قسم المميزات --- */
    .features-grid,
    .grid.grid-cols-4 {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem !important;
    }
    
    .feature-card {
        padding: 1rem !important;
    }
    
    .feature-card i,
    .feature-icon {
        font-size: 2rem !important;
    }
    
    .feature-card h3 {
        font-size: 0.9rem !important;
    }
    
    .feature-card p {
        font-size: 0.8rem !important;
    }
    
    /* --- نموذج التواصل --- */
    .contact-form,
    form.space-y-4 {
        padding: 1rem !important;
    }
    
    .contact-form input,
    .contact-form textarea {
        font-size: 16px !important; /* يمنع التكبير التلقائي على iOS */
    }
    
    /* --- Footer --- */
    footer {
        padding: 2rem 1rem !important;
    }
    
    footer .grid {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
        text-align: center !important;
    }
    
    footer .flex.gap-4 {
        justify-content: center !important;
    }
    
    footer ul {
        padding: 0 !important;
    }
    
    footer p.text-center {
        font-size: 0.8rem !important;
    }
    
    /* --- صفحة المواد --- */
    .subjects-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* تبويبات الترم */
    .term-tabs,
    .semester-tabs {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
    }
    
    .term-tab,
    .semester-tab {
        flex: 1 1 45% !important;
        text-align: center !important;
        padding: 0.75rem !important;
        font-size: 0.9rem !important;
    }
    
    /* --- صفحة الدروس --- */
    .lessons-list {
        padding: 0 !important;
    }
    
    .lesson-card {
        flex-direction: column !important;
        text-align: center !important;
    }
    
    .lesson-card img,
    .lesson-thumbnail {
        width: 100% !important;
        height: auto !important;
        margin-bottom: 1rem !important;
    }
    
    /* --- صفحة حول المنصة --- */
    .about-hero {
        padding: 1.5rem !important;
    }
    
    .founder-section {
        flex-direction: column !important;
        text-align: center !important;
    }
    
    .founder-image {
        width: 200px !important;
        height: 200px !important;
        margin: 0 auto 1.5rem !important;
    }
    
    /* --- صفحة الأسئلة الشائعة --- */
    .faq-item,
    details {
        margin: 0.75rem 0 !important;
    }
    
    .faq-item summary,
    details summary {
        padding: 1rem !important;
        font-size: 0.95rem !important;
    }
    
    .faq-item .content,
    details p {
        padding: 1rem !important;
        font-size: 0.9rem !important;
    }
    
    /* --- الأزرار العامة --- */
    .btn,
    .neu-btn,
    button {
        padding: 0.75rem 1.25rem !important;
        font-size: 0.9rem !important;
    }
    
    /* --- Container --- */
    .container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    /* --- إخفاء عناصر غير ضرورية على الموبايل --- */
    .hidden-mobile,
    .desktop-only {
        display: none !important;
    }
    
    /* --- تحسين المسافات --- */
    .py-20 {
        padding-top: 3rem !important;
        padding-bottom: 3rem !important;
    }
    
    .py-16 {
        padding-top: 2.5rem !important;
        padding-bottom: 2.5rem !important;
    }
    
    .mb-12 {
        margin-bottom: 2rem !important;
    }
    
    .mb-8 {
        margin-bottom: 1.5rem !important;
    }
    
    .gap-8 {
        gap: 1.5rem !important;
    }
    
    .gap-6 {
        gap: 1rem !important;
    }
}

/* ===== إصلاحات للشاشات الصغيرة جداً (أقل من 400px) ===== */
@media (max-width: 400px) {
    
    /* العنوان الرئيسي */
    h1.text-4xl,
    h1.text-5xl {
        font-size: 1.5rem !important;
    }
    
    /* أزرار الـ Header */
    nav .neu-btn {
        padding: 0.4rem 0.6rem !important;
        font-size: 0.7rem !important;
    }
    
    /* حقل البحث */
    nav input[type="text"] {
        width: 100px !important;
    }
    
    /* شبكة المميزات */
    .features-grid,
    .grid.grid-cols-4 {
        grid-template-columns: 1fr !important;
    }
    
    /* أزرار Hero */
    .hero-buttons a,
    .hero-buttons button {
        font-size: 0.85rem !important;
        padding: 0.75rem 1rem !important;
    }
}

/* ===== إصلاحات للتابلت (768px - 1024px) ===== */
@media (min-width: 769px) and (max-width: 1024px) {
    
    /* شبكة الصفوف */
    .grid.grid-cols-3,
    .grid.lg\\:grid-cols-3 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* شبكة المميزات */
    .features-grid,
    .grid.grid-cols-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Footer */
    footer .grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ===== تحسينات عامة للتجاوب ===== */

/* منع التكبير التلقائي على iOS عند التركيز على الحقول */
@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px !important;
    }
}

/* تحسين الصور */
img {
    max-width: 100%;
    height: auto;
}

/* تحسين الجداول */
@media (max-width: 768px) {
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

/* تحسين الفيديوهات */
.video-container,
.video-wrapper {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
    overflow: hidden;
}

.video-container iframe,
.video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* إصلاح مشكلة الـ overflow الأفقي */
html, body {
    overflow-x: hidden;
}

/* تحسين التمرير */
* {
    -webkit-overflow-scrolling: touch;
}
