/* ============================================================
   📱 Mobile-Specific Styles
   تنظیمات خاص برای دستگاه‌های موبایل
   ============================================================ */

/* ============================================================
   🎯 BODY & HTML
   ============================================================ */

html, body {
    scroll-behavior: smooth;
}

/* Fix for mobile iOS viewport issues */
body.menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* ============================================================
   📱 MOBILE-ONLY STYLES (max-width: 479px)
   ============================================================ */

@media (max-width: 479px) {
    /* --- Increase touch target sizes --- */
    button, a.btn, input[type="submit"], input[type="button"] {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* --- Reduce container padding on very small screens --- */
    .container {
        padding: 0 12px;
    }
    
    /* --- Increase form inputs --- */
    input, textarea, select {
        font-size: 16px; /* Prevents auto-zoom on focus */
        padding: 12px 15px;
        min-height: 44px;
    }
    
    /* --- Responsive typography --- */
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.2rem; }
    h3 { font-size: 1rem; }
    
    /* --- Sections padding --- */
    section {
        padding: 30px 0 40px;
    }
    
    /* --- Hero sections --- */
    .hero, .courses-hero, .blog-hero {
        padding: 40px 0 60px;
    }
    
    /* --- Grid responsive --- */
    .features-grid,
    .courses-grid,
    .blog-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    /* --- Flex responsive --- */
    .flex-wrapper {
        flex-direction: column;
    }
}

/* ============================================================
   📱 TABLET STYLES (480px - 767px)
   ============================================================ */

@media (max-width: 767px) {
    /* --- Optimize for tablet landscape --- */
    .hero .container,
    .courses-hero .container {
        flex-direction: column;
        gap: clamp(20px, 3vw, 30px);
    }
    
    /* --- Better spacing on tablet --- */
    section {
        padding: 40px 0 60px;
    }
    
    /* --- Sidebar to bottom on tablet --- */
    .sidebar {
        order: 2;
        width: 100%;
        margin-top: 30px;
    }
    
    .main-content {
        order: 1;
    }
}

/* ============================================================
   📱 SAFE AREA FOR NOTCHED DEVICES
   ============================================================ */

@supports (padding: max(0px)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
        padding-top: env(safe-area-inset-top);
    }
    
    .header {
        padding-top: calc(15px + env(safe-area-inset-top));
    }
    
    .navbar-fixed {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* ============================================================
   📱 TOUCH-FRIENDLY INTERACTIONS
   ============================================================ */

/* Add ripple effect on touch */
.btn, a.btn {
    position: relative;
    overflow: hidden;
}

.btn:active::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    animation: ripple 0.6s ease-out;
}

@keyframes ripple {
    0% {
        width: 0;
        height: 0;
    }
    100% {
        width: 300px;
        height: 300px;
    }
}

/* ============================================================
   📱 FORMS
   ============================================================ */

@media (max-width: 767px) {
    .form-row {
        flex-direction: column;
        gap: 15px;
    }
    
    .form-group {
        width: 100%;
    }
    
    /* Prevent iOS auto-zoom on input focus */
    input, textarea, select {
        font-size: 16px !important;
    }
    
    /* Better select styling */
    select {
        appearance: none;
        -webkit-appearance: none;
        -moz-appearance: none;
        background-image: url('data:image/svg+xml;utf8,<svg fill="black" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>');
        background-repeat: no-repeat;
        background-position-x: 100%;
        background-position-y: 5px;
        padding-right: 30px;
    }
}

/* ============================================================
   📱 TABLES
   ============================================================ */

@media (max-width: 767px) {
    table {
        display: block;
        overflow: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }
    
    table thead {
        display: none;
    }
    
    /* Transform table to card layout */
    table.responsive tbody,
    table.responsive tr,
    table.responsive td {
        display: block;
        width: 100%;
    }
    
    table.responsive tr {
        margin-bottom: 15px;
        border: 1px solid #ddd;
        border-radius: 8px;
        overflow: hidden;
    }
    
    table.responsive td {
        padding: 10px;
        text-align: right;
    }
    
    table.responsive td:before {
        content: attr(data-label);
        float: left;
        font-weight: bold;
        width: 40%;
    }
}

/* ============================================================
   📱 IMAGES & VIDEOS
   ============================================================ */

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

/* Responsive video embeds */
.video-wrapper, .embed-responsive {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
    overflow: hidden;
}

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

/* ============================================================
   📱 MODALS & DIALOGS
   ============================================================ */

@media (max-width: 767px) {
    .modal {
        width: 95vw;
        max-height: 90vh;
    }
    
    .modal-header {
        padding: 15px;
    }
    
    .modal-body {
        padding: 15px;
        max-height: calc(90vh - 100px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .modal-footer {
        flex-direction: column;
        gap: 10px;
    }
    
    .modal-footer button {
        width: 100%;
    }
}

/* ============================================================
   📱 NAVIGATION
   ============================================================ */

@media (max-width: 767px) {
    /* Hamburger menu */
    .menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        padding: 0;
    }
    
    /* Better nav styling for mobile */
    .nav {
        position: fixed;
        top: 60px;
        right: -100%;
        width: 100%;
        max-width: 100%;
        height: calc(100vh - 60px);
        background: var(--bg-header);
        z-index: 999;
        transition: right 0.3s ease-out;
    }
    
    .nav.active {
        right: 0;
    }
    
    /* Mobile menu list */
    .nav-list {
        flex-direction: column;
        gap: 0;
    }
    
    .nav-list li a {
        display: block;
        padding: 15px 20px;
        border-bottom: 1px solid var(--border-color);
    }
}

/* ============================================================
   📱 BREADCRUMB
   ============================================================ */

@media (max-width: 479px) {
    .breadcrumb {
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
}

/* ============================================================
   📱 PAGINATION
   ============================================================ */

@media (max-width: 767px) {
    .pagination {
        justify-content: center;
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .pagination li {
        margin: 5px;
    }
    
    .pagination a, .pagination span {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
}

/* ============================================================
   📱 VISIBILITY HELPERS
   ============================================================ */

/* Show/hide based on device */
.mobile-only {
    display: none;
}

.desktop-only {
    display: block;
}

.tablet-only {
    display: none;
}

@media (max-width: 767px) {
    .mobile-only {
        display: block;
    }
    
    .desktop-only {
        display: none;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .tablet-only {
        display: block;
    }
    
    .mobile-only {
        display: none;
    }
}

/* ============================================================
   📱 SCROLLBAR STYLING
   ============================================================ */

/* iOS - hide scrollbar */
@media (max-width: 767px) {
    ::-webkit-scrollbar {
        width: 6px;
        height: 6px;
    }
    
    ::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.3);
        border-radius: 3px;
    }
}

/* ============================================================
   📱 PERFORMANCE - REDUCE ANIMATIONS ON MOBILE
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============================================================
   📱 HIGH CONTRAST MODE (برای کاربران دارای معلولیت)
   ============================================================ */

@media (prefers-contrast: more) {
    button, a.btn {
        border-width: 2px;
    }
    
    input, textarea, select {
        border-width: 2px;
    }
}

/* ============================================================
   📱 DARK MODE SUPPORT
   ============================================================ */

@media (prefers-color-scheme: dark) {
    /* Automatically apply dark theme */
    body {
        background: var(--bg-body);
        color: var(--text-primary);
    }
}

