/* Mobile-first responsive design optimizations */

/* Base mobile styles */
@media (max-width: 767px) {
    /* Ensure proper mobile viewport */
    html {
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
    }
    
    /* Mobile navigation improvements */
    .navbar-toggler {
        border: none;
        padding: 0.25rem 0.5rem;
        font-size: 1.25rem;
    }
    
    .navbar-collapse {
        background: #fff;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        margin-top: 0.5rem;
        border-radius: 0.375rem;
    }
    
    /* Mobile-friendly buttons */
    .btn {
        min-height: 44px; /* iOS touch target minimum */
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }
    
    /* Mobile form improvements */
    input, select, textarea {
        min-height: 44px;
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.75rem;
    }
    
    /* Mobile grid adjustments */
    .grid-cols-3 {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    /* Mobile typography */
    .text-3xl {
        font-size: 1.5rem;
        line-height: 1.4;
    }
    
    .text-2xl {
        font-size: 1.25rem;
        line-height: 1.4;
    }
    
    /* Mobile spacing */
    .container {
        padding: 0 0.75rem;
    }
    
    .p-4 {
        padding: 0.75rem;
    }
    
    /* Mobile sidebar */
    #sidebar {
        width: 280px;
        transition: transform 0.3s ease;
    }
    
    .sidebar-open #sidebar {
        transform: translateX(0);
    }
    
    /* Mobile table responsiveness */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: 600px;
    }
    
    /* Mobile card improvements */
    .card {
        margin-bottom: 1rem;
        border-radius: 0.5rem;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }
}

/* Tablet styles */
@media (min-width: 768px) and (max-width: 1023px) {
    .grid-cols-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .container {
        padding: 0 1rem;
    }
}

/* Desktop styles */
@media (min-width: 1024px) {
    .grid-cols-3 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .container {
        max-width: 1200px;
        padding: 0 1.5rem;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets for mobile */
    .nav-link {
        padding: 0.75rem 1rem;
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    .dropdown-item {
        padding: 0.75rem 1rem;
        min-height: 44px;
    }
    
    /* Remove hover effects on touch devices */
    .btn:hover {
        transform: none;
    }
}

/* Performance optimizations */
.lazy-image {
    opacity: 1;
    transition: opacity 0.3s;
}

.lazy-image.loaded {
    opacity: 1;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #1f2937;
        --text-color: #f9fafb;
        --border-color: #374151;
    }
}

/* Mobile Recommendations Fix for Document Preview Page */
@media (max-width: 767px) {
    /* Ensure recommendations container doesn't overflow */
    .border.border-gray-200.p-4.mt-4 {
        overflow-x: hidden;
        padding: 0.75rem;
    }
    
    /* Fix owl-carousel container for mobile */
    .owl-carousel.active_course {
        overflow: hidden;
        margin: 0 -0.5rem;
    }
    
    /* Adjust single course items for mobile */
    .single_course {
        margin: 0 0.5rem;
        max-width: calc(100vw - 2rem);
        overflow: hidden;
    }
    
    /* Fix course content to prevent overflow */
    .single_course .course_content {
        padding: 15px 20px;
        height: auto;
        min-height: 160px;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* Ensure course titles don't overflow */
    .single_course .course_content h4 {
        font-size: 14px;
        line-height: 1.3;
        margin-bottom: 8px;
        word-wrap: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
    }
    
    /* Fix tag display */
    .single_course .course_content .tag {
        font-size: 12px;
        margin-bottom: 8px;
        display: block;
        word-wrap: break-word;
    }
    
    /* Adjust price circle for mobile */
    .single_course .price {
        width: 50px;
        height: 50px;
        line-height: 50px;
        font-size: 14px;
        top: -25px;
        right: 10px;
    }
    
    /* Fix owl-carousel navigation for mobile */
    .owl-carousel .owl-nav {
        margin-top: 10px;
        text-align: center;
    }
    
    .owl-carousel .owl-nav button {
        background: #f0f0f0 !important;
        color: #333 !important;
        border: 1px solid #ddd !important;
        border-radius: 4px !important;
        padding: 8px 12px !important;
        margin: 0 5px !important;
        font-size: 14px !important;
    }
    
    /* Ensure recommendations title is properly styled */
    .border.border-gray-200.p-4.mt-4 h3.title {
        font-size: 18px;
        margin-bottom: 15px;
        padding: 0 0.5rem;
    }
    
    /* Fix any potential horizontal scroll */
    .col-span-full.md\\:col-span-2 {
        overflow-x: hidden;
    }
}

/* Additional fix for very small screens */
@media (max-width: 480px) {
    .single_course .course_content {
        padding: 12px 15px;
        min-height: 140px;
    }
    
    .single_course .course_content h4 {
        font-size: 13px;
    }
    
    .single_course .course_content .tag {
        font-size: 11px;
    }
    
    .single_course .price {
        width: 45px;
        height: 45px;
        line-height: 45px;
        font-size: 12px;
        top: -22px;
    }
}

/* Print styles */
@media print {
    .navbar, .sidebar, .btn, .dropdown {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.4;
    }
}