/**
 * Responsive Design - Mobile & Tablet Optimization
 * Breakpoints:
 * - Mobile: < 640px (sm)
 * - Tablet: 640px - 1024px (md)
 * - Desktop: > 1024px (lg)
 */

/* ============================================
   MOBILE FIRST - BASE STYLES
   ============================================ */

/* Touch-friendly buttons and links */
@media (max-width: 1024px) {
    a, button, .btn {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 20px;
    }
    
    /* Better tap targets */
    .card {
        margin-bottom: 1rem;
    }
    
    /* Prevent horizontal scroll */
    body {
        overflow-x: hidden;
    }
    
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* ============================================
   MOBILE PORTRAIT (< 640px)
   ============================================ */
@media (max-width: 640px) {
    /* Typography adjustments */
    h1 {
        font-size: 2rem !important;
        line-height: 1.2;
    }
    
    h2 {
        font-size: 1.5rem !important;
    }
    
    h3 {
        font-size: 1.25rem !important;
    }
    
    /* Navigation - Mobile Menu */
    .nav-desktop {
        display: none !important;
    }
    
    .nav-mobile {
        display: block !important;
    }
    
    /* Hero sections */
    .hero-section {
        padding: 2rem 1rem !important;
        min-height: auto !important;
    }
    
    .hero-title {
        font-size: 1.75rem !important;
    }
    
    .hero-subtitle {
        font-size: 1rem !important;
    }
    
    /* Course cards - Single column */
    .course-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
    
    .card {
        margin: 0 0 1rem 0;
    }
    
    /* Forms - Full width inputs */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    select,
    textarea {
        width: 100% !important;
        font-size: 16px !important; /* Prevents zoom on iOS */
    }
    
    /* Modals - Full screen on mobile */
    .modal-content {
        width: 95vw !important;
        max-height: 90vh !important;
        margin: 5vh auto;
    }
    
    /* Tables - Responsive scroll */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: 600px;
    }
    
    /* Spacing adjustments */
    .py-16 {
        padding-top: 3rem !important;
        padding-bottom: 3rem !important;
    }
    
    .space-x-8 > * + * {
        margin-left: 1rem !important;
    }
    
    /* Hide less important elements on mobile */
    .hide-mobile {
        display: none !important;
    }
    
    /* Dashboard - Stack cards */
    .dashboard-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* Video player - Full width */
    .video-container {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 16/9;
    }
    
    /* Footer - Stack columns */
    .footer-columns {
        flex-direction: column !important;
        text-align: center;
    }
}

/* ============================================
   TABLET PORTRAIT (640px - 768px)
   ============================================ */
@media (min-width: 640px) and (max-width: 768px) {
    /* 2 columns for course grid */
    .course-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1.5rem !important;
    }
    
    /* Navigation adjustments */
    .nav-links {
        gap: 1rem;
    }
    
    h1 {
        font-size: 2.5rem !important;
    }
    
    .container {
        max-width: 100%;
        padding: 0 2rem;
    }
}

/* ============================================
   TABLET LANDSCAPE (768px - 1024px)
   ============================================ */
@media (min-width: 768px) and (max-width: 1024px) {
    /* 3 columns for course grid */
    .course-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 2rem !important;
    }
    
    /* Better use of space */
    .container {
        max-width: 100%;
        padding: 0 3rem;
    }
    
    /* Dashboard - 2 columns */
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    h1 {
        font-size: 3rem !important;
    }
}

/* ============================================
   MOBILE MENU HAMBURGER
   ============================================ */
.mobile-menu-button {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1001;
}

@media (max-width: 768px) {
    .mobile-menu-button {
        display: block;
    }
    
    .mobile-menu {
        position: fixed;
        top: 0;
        left: -100%;
        width: 80%;
        max-width: 300px;
        height: 100vh;
        background: white;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
        transition: left 0.3s ease;
        z-index: 1000;
        overflow-y: auto;
        padding: 80px 20px 20px;
    }
    
    .mobile-menu.active {
        left: 0;
    }
    
    .mobile-menu-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
        z-index: 999;
    }
    
    .mobile-menu-overlay.active {
        opacity: 1;
        visibility: visible;
    }
    
    .mobile-menu nav {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }
    
    .mobile-menu a {
        padding: 1rem;
        border-radius: 8px;
        transition: background 0.2s;
    }
    
    .mobile-menu a:hover {
        background: #f3f4f6;
    }
}

/* ============================================
   TOUCH INTERACTIONS
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .hover\:scale-105:hover {
        transform: none;
    }
    
    /* Better tap feedback */
    button:active,
    .btn:active,
    a:active {
        opacity: 0.7;
        transform: scale(0.98);
    }
    
    /* Disable hover dropdowns */
    .group:hover .group-hover\:visible {
        visibility: hidden;
        opacity: 0;
    }
}

/* ============================================
   ORIENTATION CHANGES
   ============================================ */
@media (orientation: landscape) and (max-height: 500px) {
    /* Reduce padding in landscape mode on short screens */
    .hero-section {
        padding: 1rem !important;
        min-height: auto !important;
    }
    
    header {
        padding: 0.5rem 1rem !important;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .no-print,
    header,
    footer,
    nav,
    .sidebar,
    button,
    .btn {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
    }
    
    .container {
        max-width: 100%;
        padding: 0;
    }
}

/* ============================================
   ACCESSIBILITY - HIGH CONTRAST MODE
   ============================================ */
@media (prefers-contrast: high) {
    * {
        border-color: currentColor !important;
    }
    
    button,
    .btn {
        border: 2px solid currentColor !important;
    }
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   FOOTER RESPONSIVE IMPROVEMENTS
   ============================================ */
@media (max-width: 768px) {
    /* Footer bottom section - Stack links vertically on mobile */
    footer .flex.flex-col.md\:flex-row {
        gap: 1rem !important;
    }
    
    /* Footer links - Prevent overflow */
    footer a {
        word-break: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }
    
    /* Footer link containers - Better spacing */
    footer .space-y-2 {
        gap: 0.75rem !important;
    }
    
    /* Bottom footer links - Stack and center */
    footer .flex.gap-4 {
        flex-direction: column;
        gap: 0.75rem !important;
        align-items: center;
        text-align: center;
    }
    
    /* Dark mode toggle - Ensure visibility */
    #theme-toggle {
        margin-top: 1rem;
        width: 100%;
        max-width: 200px;
    }
    
    /* Footer columns - Better mobile layout */
    footer .grid {
        gap: 2rem !important;
    }
    
    /* Footer text - Better readability */
    footer .text-sm {
        font-size: 0.875rem;
        line-height: 1.5;
    }
    
    /* Social links - Center on mobile */
    footer .flex.space-x-4 {
        justify-content: center;
    }
    
    /* Contact info - Prevent overflow */
    footer .space-y-3 p {
        word-break: break-word;
        max-width: 100%;
    }
}
