/**
 * Mobile Optimization CSS
 * 
 * This file contains mobile-specific optimizations
 * for better performance and user experience on mobile devices.
 */

/* Mobile-first responsive design */
@media (max-width: 768px) {
    /* Typography optimization */
    body {
        font-size: 16px; /* Prevent zoom on iOS */
        line-height: 1.6;
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
    }
    
    /* Touch-friendly buttons */
    .btn, button, input[type="button"], input[type="submit"] {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 16px;
        font-size: 16px;
        touch-action: manipulation;
    }
    
    /* Form optimization */
    input, textarea, select {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 12px;
        border-radius: 8px;
        border: 1px solid #ddd;
        width: 100%;
        box-sizing: border-box;
    }
    
    /* Table responsiveness */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table {
        font-size: 14px;
        min-width: 600px;
    }
    
    /* Card optimization */
    .card {
        margin-bottom: 1rem;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    .card-body {
        padding: 1rem;
    }
    
    /* Navigation optimization */
    .navbar {
        padding: 0.5rem 1rem;
    }
    
    .navbar-brand {
        font-size: 1.2rem;
    }
    
    .navbar-nav .nav-link {
        padding: 0.75rem 1rem;
        font-size: 16px;
    }
    
    /* Sidebar optimization */
    .sidebar {
        position: fixed;
        top: 0;
        left: -250px;
        width: 250px;
        height: 100vh;
        background: #fff;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 2px 0 8px rgba(0,0,0,0.1);
    }
    
    .sidebar.show {
        left: 0;
    }
    
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 999;
        display: none;
    }
    
    .sidebar-overlay.show {
        display: block;
    }
    
    /* Main content optimization */
    .main-content {
        margin-left: 0;
        padding: 1rem;
    }
    
    /* Grid optimization */
    .row {
        margin: 0 -0.5rem;
    }
    
    .col-md-6, .col-md-4, .col-md-3 {
        padding: 0 0.5rem;
        margin-bottom: 1rem;
    }
    
    /* Modal optimization */
    .modal-dialog {
        margin: 1rem;
        max-width: calc(100% - 2rem);
    }
    
    .modal-content {
        border-radius: 12px;
    }
    
    /* Alert optimization */
    .alert {
        margin: 1rem 0;
        padding: 1rem;
        border-radius: 8px;
        font-size: 14px;
    }
    
    /* Button group optimization */
    .btn-group {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .btn-group .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    /* Form group optimization */
    .form-group {
        margin-bottom: 1rem;
    }
    
    .form-label {
        font-weight: 600;
        margin-bottom: 0.5rem;
        display: block;
    }
    
    /* Table of Contents mobile optimization */
    .table-of-contents {
        position: static;
        float: none;
        width: 100%;
        margin: 2rem 0;
        padding: 1rem;
        background: #f8f9fa;
        border-radius: 8px;
    }
    
    .table-of-contents h2 {
        font-size: 1.1rem;
        margin-bottom: 0.75rem;
    }
    
    .table-of-contents ul {
        padding-left: 1rem;
    }
    
    .table-of-contents li {
        margin-bottom: 0.25rem;
    }
    
    /* CTA box mobile optimization */
    .cta-box {
        padding: 1.5rem;
        margin: 2rem 0;
        text-align: center;
    }
    
    .cta-box h3 {
        font-size: 1.4rem;
        margin-bottom: 0.75rem;
    }
    
    .cta-box p {
        font-size: 1rem;
        margin-bottom: 1rem;
    }
    
    .cta-button {
        display: block;
        width: 100%;
        padding: 1rem;
        font-size: 16px;
        text-align: center;
    }
    
    /* FAQ mobile optimization */
    .faq-item {
        margin-bottom: 1rem;
    }
    
    .faq-question {
        padding: 0.75rem;
        font-size: 1rem;
        line-height: 1.4;
    }
    
    .faq-answer {
        padding: 0.75rem;
        font-size: 0.95rem;
        line-height: 1.5;
    }
    
    /* Related posts mobile optimization */
    .related-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .related-card {
        margin-bottom: 1rem;
    }
    
    .related-card img {
        height: 150px;
    }
    
    .related-card-content {
        padding: 1rem;
    }
    
    .related-card h3 {
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
    }
    
    .related-card p {
        font-size: 0.9rem;
    }
}

/* Tablet optimization */
@media (min-width: 769px) and (max-width: 1024px) {
    .main-content {
        padding: 1.5rem;
    }
    
    .table-of-contents {
        width: 300px;
        margin-left: 2rem;
    }
    
    .related-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Large mobile devices */
@media (max-width: 480px) {
    .container {
        padding: 0.5rem;
    }
    
    .card-body {
        padding: 0.75rem;
    }
    
    .btn {
        font-size: 14px;
        padding: 10px 14px;
    }
    
    .table {
        font-size: 12px;
    }
    
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .btn:hover, .nav-link:hover, .card:hover {
        transform: none;
        box-shadow: none;
    }
    
    /* Increase touch targets */
    .btn, .nav-link, .form-control {
        min-height: 48px;
    }
    
    /* Optimize for touch scrolling */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
}

/* High DPI display optimization */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Optimize images for retina displays */
    img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .card {
        background-color: #2d3748;
        color: #e2e8f0;
        border-color: #4a5568;
    }
    
    .table {
        color: #e2e8f0;
    }
    
    .table th {
        background-color: #4a5568;
        color: #e2e8f0;
    }
    
    .table td {
        border-color: #4a5568;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print optimization */
@media print {
    .sidebar, .navbar, .btn, .modal {
        display: none !important;
    }
    
    .main-content {
        margin: 0;
        padding: 0;
    }
    
    .card {
        border: 1px solid #000;
        box-shadow: none;
    }
    
    .table {
        font-size: 12px;
    }
}
