/**
 * Mobile Responsive Enhancements
 * منصة المدرب العزاوي عبدالرحمان
 * تحسينات شاملة للتوافق مع الجوال
 */

/* ============================================
   تحسينات عامة للجوال
   ============================================ */

/* منع التمرير الأفقي */
html, body {
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* تحسين الصور للجوال */
img {
    max-width: 100%;
    height: auto;
}

/* تحسين اللمس */
button, 
a, 
input, 
textarea, 
select {
    -webkit-tap-highlight-color: transparent;
}

/* تحسين حجم الخط على iOS */
input, 
textarea, 
select {
    font-size: 16px !important;
}

/* Safe Area للأجهزة الحديثة */
.main-content,
.container {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* ============================================
   شاشات صغيرة جداً (أقل من 400px)
   ============================================ */
@media (max-width: 400px) {
    html {
        font-size: 14px;
    }
    
    .container {
        padding: 0 10px;
    }
    
    .main-nav {
        padding: 0.75rem 1rem;
    }
    
    .logo img {
        height: 40px;
    }
    
    .hero h1 {
        font-size: 1.8rem;
    }
    
    .hero p {
        font-size: 1rem;
    }
    
    .feature-card {
        padding: 1.5rem;
    }
    
    .auth-box {
        padding: 1.5rem;
        margin: 0.5rem;
    }
    
    .auth-box h1 {
        font-size: 1.3rem;
    }
    
    .form-group input {
        padding: 0.75rem;
    }
}

/* ============================================
   شاشات الجوال (400px - 576px)
   ============================================ */
@media (max-width: 576px) {
    /* الهيدر */
    .main-nav {
        padding: 0.75rem 1rem;
    }
    
    .logo img {
        height: 45px;
    }
    
    .mobile-menu-toggle {
        font-size: 1.3rem;
        padding: 0.75rem;
    }
    
    /* القائمة الجانبية */
    .sidebar {
        width: 85%;
        max-width: 300px;
    }
    
    .sidebar-links a {
        padding: 1rem;
        font-size: 1rem;
    }
    
    /* Hero Section */
    .hero-slider {
        padding: 2rem 0;
    }
    
    .hero-image {
        width: 120px;
        height: 120px;
    }
    
    .hero-content h1, 
    .hero-content h2 {
        font-size: 1.5rem;
    }
    
    .hero-content p {
        font-size: 1rem;
    }
    
    .hero-btn {
        padding: 0.8rem 1.5rem;
        font-size: 0.9rem;
    }
    
    /* Features Grid */
    .features-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin: 2rem 0;
    }
    
    .feature-card {
        padding: 1.5rem;
    }
    
    .feature-card i {
        font-size: 2rem;
    }
    
    .feature-card h3 {
        font-size: 1.1rem;
    }
    
    .feature-card p {
        font-size: 0.9rem;
    }
    
    /* تطبيق التنزيل */
    .app-download-mini {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 1rem;
    }
    
    .app-info {
        flex-direction: column;
    }
    
    .app-buttons {
        width: 100%;
        justify-content: center;
    }
    
    .app-btn {
        flex: 1;
        justify-content: center;
    }
    
    /* Coach Bio */
    .coach-bio {
        padding: 1.5rem;
        gap: 1.5rem;
    }
    
    .coach-thumbnail {
        max-width: 200px;
    }
    
    .coach-info h2 {
        font-size: 1.4rem;
        text-align: center;
    }
    
    .coach-info h2::after {
        right: 50%;
        transform: translateX(50%);
    }
    
    .coach-stats {
        padding: 1rem;
        gap: 1rem;
    }
    
    .stat-number {
        font-size: 1.8rem;
    }
    
    /* Training Slider */
    .training-slider {
        padding: 2rem 0;
    }
    
    .training-slider h2 {
        font-size: 1.3rem;
        margin-bottom: 1.5rem;
    }
    
    .training-image {
        height: 200px;
    }
    
    /* Partners */
    .partners-section {
        padding: 2rem 0;
    }
    
    .partners-grid {
        gap: 1.5rem;
    }
    
    .partner-logo {
        width: 200px;
        height: 100px;
    }
    
    /* Footer */
    .footer-grid {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .footer-section h3::after {
        left: 50%;
        transform: translateX(-50%);
    }
    
    .social-links {
        justify-content: center;
    }
    
    .footer-bottom {
        flex-direction: column;
        text-align: center;
    }
    
    .app-badges {
        justify-content: center;
    }
    
    /* Auth Pages - Modern Mobile Style */
    .auth-body {
        background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%) !important;
        min-height: 100vh;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 1rem;
    }

    .auth-wrapper {
        background: transparent !important;
        box-shadow: none !important;
        margin: 0 !important;
        width: 100%;
        max-width: 100%;
        display: flex;
        flex-direction: column;
    }
    
    .auth-side {
        display: none;
    }

    .auth-main {
        padding: 0;
        width: 100%;
    }
    
    .auth-box {
        background: #ffffff;
        padding: 2.5rem 1.5rem;
        border-radius: 24px;
        box-shadow: 0 10px 40px rgba(0,0,0,0.2);
        margin: 0 auto;
        width: 100%;
    }

    .auth-logo-mobile {
        display: block !important;
        margin-bottom: 2rem;
        text-align: center;
        width: 100%;
    }

    .auth-logo-mobile img {
        height: 100px;
        width: 100px;
        border-radius: 50%;
        object-fit: cover;
        box-shadow: 0 5px 15px rgba(0,0,0,0.1);
        border: 4px solid #ffffff;
    }
    
    .auth-box h1 {
        font-size: 1.6rem;
        font-weight: 700;
        color: #2c3e50;
        text-align: center;
        margin-bottom: 0.5rem;
    }

    .auth-subtitle {
        text-align: center;
        color: #7f8c8d;
        margin-bottom: 2rem;
        font-size: 0.95rem;
    }
    
    .form-group {
        margin-bottom: 1.5rem;
    }

    .form-group label {
        font-size: 0.9rem;
        font-weight: 600;
        margin-bottom: 0.8rem;
        color: #34495e;
        display: block;
    }
    
    .form-group input {
        padding: 1rem;
        background: #f8f9fa;
        border: 2px solid #edf2f7;
        border-radius: 12px;
        font-size: 1rem;
        transition: all 0.3s ease;
    }

    .form-group input:focus {
        background: #fff;
        border-color: #2ecc71;
        box-shadow: 0 0 0 4px rgba(46, 204, 113, 0.1);
    }
    
    .form-group-flex {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 1.5rem;
    }

    .checkbox-container {
        font-size: 0.9rem;
    }

    .auth-submit {
        background: linear-gradient(135deg, #2ecc71, #27ae60);
        border: none;
        padding: 1rem;
        border-radius: 12px;
        font-size: 1.1rem;
        font-weight: 600;
        box-shadow: 0 4px 15px rgba(46, 204, 113, 0.3);
        margin-top: 1rem;
    }

    .auth-submit:active {
        transform: scale(0.98);
    }

    .auth-links {
        margin-top: 2rem;
        text-align: center;
    }

    .home-link {
        margin-top: 1.5rem;
        text-align: center;
    }

    .home-link a {
        color: #7f8c8d;
        font-size: 0.9rem;
    }
    
    /* Profile */
    .profile-header {
        flex-direction: column;
        text-align: center;
    }
    
    .profile-avatar {
        margin: 0 auto 1rem;
    }
    
    .profile-stats {
        justify-content: center;
    }
    
    /* Cards */
    .card-grid,
    .journey-grid,
    .books-grid,
    .audio-grid {
        grid-template-columns: 1fr;
    }
    
    /* Modals */
    .modal-content {
        width: 95%;
        margin: 1rem auto;
        max-height: 90vh;
    }
    
    /* Buttons */
    .btn, 
    .button,
    .auth-submit,
    .submit-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ============================================
   شاشات متوسطة (576px - 768px)
   ============================================ */
@media (min-width: 576px) and (max-width: 768px) {
    .container {
        padding: 0 1.5rem;
    }
    
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .footer-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .card-grid,
    .journey-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================
   شاشات التابلت (768px - 992px)
   ============================================ */
@media (min-width: 768px) and (max-width: 992px) {
    .main-nav {
        padding: 1rem 2rem;
    }
    
    .nav-links {
        display: none;
    }
    
    .mobile-menu-toggle {
        display: block;
    }
    
    .hero-slider {
        padding: 3rem 0;
    }
    
    .hero-image {
        width: 180px;
        height: 180px;
    }
    
    .coach-bio {
        grid-template-columns: 250px 1fr;
    }
    
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .auth-side {
        display: block;
        padding: 2rem;
    }
    
    .auth-side-content {
        padding-top: 2rem;
    }
    
    .auth-side h2 {
        font-size: 1.5rem;
    }
}

/* ============================================
   تحسينات لوحة التحكم للجوال
   ============================================ */
@media (max-width: 768px) {
    /* Dashboard Layout */
    .dashboard {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        position: fixed;
        bottom: 0;
        top: auto;
        height: auto !important;
        z-index: 1000;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    }
    
    .sidebar-header {
        display: none;
    }
    
    .nav-menu {
        display: flex;
        justify-content: space-around;
        padding: 0.5rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .nav-item {
        flex-direction: column;
        padding: 0.5rem;
        font-size: 0.7rem;
        text-align: center;
        min-width: 60px;
        border-right: none !important;
    }
    
    .nav-item i {
        margin: 0 0 0.25rem 0;
        font-size: 1.2rem;
    }
    
    .main-content {
        margin-bottom: 70px;
        padding: 1rem;
    }
    
    .header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
        text-align: center;
    }
    
    .header h1 {
        font-size: 1.3rem;
    }
    
    .user-menu {
        width: 100%;
        justify-content: center;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-icon {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
    
    .stat-info h3 {
        font-size: 0.9rem;
    }
    
    .stat-info p {
        font-size: 1.5rem;
    }
    
    /* Data Tables */
    .data-table {
        display: block;
        overflow-x: auto;
    }
    
    .data-table th,
    .data-table td {
        min-width: 100px;
        padding: 0.75rem;
        font-size: 0.85rem;
    }
    
    /* Action Buttons in Tables */
    .action-buttons {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .action-buttons .btn {
        width: 100%;
    }
    
    /* Modals in Admin */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    /* Form in Modal */
    .modal-form .form-group {
        margin-bottom: 1rem;
    }
}

/* ============================================
   تحسينات الصوتيات والفيديو
   ============================================ */
@media (max-width: 768px) {
    /* Audio Player */
    .audio-player {
        padding: 1rem;
    }
    
    .audio-controls {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .audio-progress {
        width: 100%;
        order: -1;
        margin-bottom: 0.5rem;
    }
    
    /* Video Player */
    .video-container {
        position: relative;
        padding-bottom: 56.25%; /* 16:9 */
        height: 0;
        overflow: hidden;
    }
    
    .video-container iframe,
    .video-container video {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }
    
    /* Episode Page */
    .episode-header {
        padding: 1.5rem;
    }
    
    .episode-info h1 {
        font-size: 1.5rem;
    }
    
    .episode-meta {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .episode-content {
        padding: 1.5rem;
        font-size: 1rem;
    }
    
    .episode-navigation {
        flex-direction: column;
        padding: 1rem;
    }
    
    .nav-btn {
        width: 100%;
    }
}

/* ============================================
   تحسينات التحديات والمزاج
   ============================================ */
@media (max-width: 768px) {
    /* Challenges */
    .challenges-grid {
        grid-template-columns: 1fr;
    }
    
    .challenge-card {
        padding: 1.5rem;
    }
    
    .challenge-icon {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
    
    /* Mood Tracker */
    .mood-container {
        padding: 1rem;
    }
    
    .mood-tracker h1 {
        font-size: 1.5rem;
    }
    
    .mood-emojis {
        justify-content: space-around;
    }
    
    .emoji {
        font-size: 1.5rem;
    }
    
    .mood-display {
        flex-direction: column;
        gap: 1rem;
    }
    
    .mood-emoji {
        font-size: 3rem;
    }
    
    .mood-details {
        text-align: center;
    }
}

/* ============================================
   تحسينات الكتب والمكتبة
   ============================================ */
@media (max-width: 768px) {
    .books-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .book-card {
        padding: 1rem;
    }
    
    .book-cover {
        height: 150px;
    }
    
    .book-title {
        font-size: 0.9rem;
    }
    
    .book-details {
        padding: 1rem;
    }
}

@media (max-width: 400px) {
    .books-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   تحسينات التعليقات
   ============================================ */
@media (max-width: 768px) {
    .comments-section {
        padding: 1.5rem;
    }
    
    .comments-section h2 {
        font-size: 1.3rem;
    }
    
    .comment-form textarea {
        min-height: 100px;
    }
    
    .comment-card {
        flex-direction: column;
        padding: 1rem;
    }
    
    .comment-avatar {
        width: 50px;
        height: 50px;
    }
    
    .comment-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    
    .comment-text {
        font-size: 0.95rem;
    }
}

/* ============================================
   تحسينات الملف الشخصي
   ============================================ */
@media (max-width: 768px) {
    .profile-page {
        padding: 1rem;
    }
    
    .profile-header {
        flex-direction: column;
        text-align: center;
        padding: 1.5rem;
    }
    
    .profile-avatar {
        width: 100px;
        height: 100px;
        margin: 0 auto 1rem;
    }
    
    .profile-info h1 {
        font-size: 1.5rem;
    }
    
    .profile-stats {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 1rem;
    }
    
    .stat-item {
        min-width: 80px;
    }
    
    .profile-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .profile-tabs .tab {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
        white-space: nowrap;
    }
}

/* ============================================
   تحسينات الأزرار العائمة
   ============================================ */
@media (max-width: 768px) {
    .floating-action-btn {
        bottom: 80px; /* فوق شريط التنقل السفلي */
        right: 1rem;
    }
    
    .scroll-to-top {
        bottom: 80px;
    }
}

/* ============================================
   تحسينات الإشعارات
   ============================================ */
@media (max-width: 576px) {
    .notification-dropdown {
        width: 100vw;
        right: -60px;
        border-radius: 0 0 15px 15px;
    }
    
    .alert {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
    
    .toast {
        width: calc(100% - 2rem);
        margin: 0 1rem;
    }
}

/* ============================================
   Landscape Mode على الجوال
   ============================================ */
@media (max-height: 500px) and (orientation: landscape) {
    .auth-box {
        margin: 0 auto;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .hero-slider {
        padding: 1rem 0;
    }
    
    .hero-image {
        width: 100px;
        height: 100px;
    }
    
    .modal-content {
        max-height: 80vh;
        overflow-y: auto;
    }
}

/* ============================================
   تحسينات للطباعة
   ============================================ */
@media print {
    .sidebar,
    .nav-menu,
    .mobile-menu-toggle,
    .overlay,
    .floating-action-btn,
    .scroll-to-top,
    footer .social-links,
    .app-badges {
        display: none !important;
    }
    
    .main-content {
        margin: 0;
        padding: 0;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.5;
    }
    
    a {
        text-decoration: none;
        color: inherit;
    }
}

/* ============================================
   تحسينات الوضع الداكن (مستقبلي)
   ============================================ */
@media (prefers-color-scheme: dark) {
    :root {
        --background-light: #1a1a2e;
        --card-background: #16213e;
        --text-dark: #eaeaea;
        --text-light: #b0b0b0;
    }
    
    /* يمكن إضافة المزيد من التخصيصات للوضع الداكن */
}

/* ============================================
   تحسين الإمكانية للوصول
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible للوحة المفاتيح */
:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ============================================
   إخفاء شريط التمرير مع الحفاظ على وظيفته
   ============================================ */
.hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.hide-scrollbar::-webkit-scrollbar {
    display: none;
}
