/* 
 * Mobile Responsiveness Enhancements for Search System
 * Improves UX on mobile devices
 */

/* Fix container width on mobile */
@media (max-width: 768px) {
    /* Force ALL containers to 100% width on mobile */
    .container,
    .container-fluid {
        max-width: 100% !important;
        width: 100% !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    /* Override inline max-width styles specifically */
    [style*="max-width: 60%"] {
        max-width: 100% !important;
        width: 100% !important;
    }
    
    /* Fix navbar container separately */
    .navbar > .container {
        max-width: 100% !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    /* Fix footer container */
    footer > .container,
    .footer > .container {
        max-width: 100% !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    /* Fix content wrapper */
    .content-wrapper {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    
    /* Fix sections with containers */
    section > .container {
        max-width: 100% !important;
        width: 100% !important;
    }
    
    /* Fix navbar and dropdown overflow issues */
    .navbar,
    .navbar-collapse {
        overflow: visible !important;
    }
    
    /* Ensure dropdown menus are visible */
    .dropdown-menu {
        position: absolute !important;
        z-index: 1050 !important;
        max-width: 100% !important;
    }
    
    /* Ensure navbar container doesn't clip dropdowns */
    .navbar > .container {
        overflow: visible !important;
        position: relative !important;
    }
}

/* Mobile-specific search form */
@media (max-width: 768px) {
    /* Stack search filters vertically on mobile */
    #searchForm .row.g-2 {
        margin-bottom: 0.5rem;
    }
    
    #searchForm .col-md-4 {
        margin-bottom: 0.5rem;
    }
    
    /* Make search input and button full width */
    #searchForm .form-control,
    #searchForm .form-select,
    #searchForm .btn {
        width: 100%;
    }
    
    /* Reduce padding on mobile */
    .main-container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    /* Improve card spacing on mobile */
    #cardView .col-md-6 {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    /* Make view toggle buttons smaller on mobile */
    #resultsHeader .btn-group .btn {
        font-size: 0.875rem;
        padding: 0.375rem 0.75rem;
    }
    
    /* Hide some text on mobile view toggle */
    #resultsHeader .btn-group .btn span.d-none {
        display: none !important;
    }
    
    /* Better pagination on mobile */
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .pagination .page-item {
        margin: 0.125rem;
    }
    
    .pagination .page-link {
        padding: 0.375rem 0.75rem;
        font-size: 0.875rem;
    }
    
    /* DataTable responsive improvements */
    #standardsTable {
        font-size: 0.875rem;
    }
    
    #standardsTable th,
    #standardsTable td {
        padding: 0.5rem;
    }
    
    /* Make action buttons stack on very small screens */
    @media (max-width: 576px) {
        .card-footer .btn {
            font-size: 0.75rem;
            padding: 0.375rem 0.5rem;
        }
        
        /* Hide less important badges on very small screens */
        .badge.bg-secondary.bg-opacity-10 {
            font-size: 0.6rem !important;
        }
        
        /* Reduce header stats size */
        .stat-badge {
            padding: 0.5rem 0.75rem !important;
        }
        
        .stat-badge .h3 {
            font-size: 1.25rem;
        }
        
        .stat-badge small {
            font-size: 0.7rem;
        }
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Increase tap target size for touch devices */
    .btn,
    .form-control,
    .form-select {
        min-height: 44px;
    }
    
    /* Better spacing for touch */
    .card-footer .btn {
        margin-bottom: 0.5rem;
    }
    
    /* Larger pagination buttons */
    .pagination .page-link {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Landscape mobile improvements */
@media (max-width: 768px) and (orientation: landscape) {
    /* Reduce hero section height in landscape */
    .bg-gradient.py-5 {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
    
    .display-4,
    .display-5 {
        font-size: 1.5rem;
    }
    
    .lead {
        font-size: 1rem;
    }
}

/* Fix for DataTables on mobile */
.dataTables_wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.dataTables_wrapper .dataTables_filter input {
    width: 100%;
    max-width: 300px;
}

.dataTables_wrapper .dataTables_length select {
    width: auto;
    min-width: 60px;
}

/* Loading spinner improvements */
#loadingSpinner {
    min-height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* No results improvements */
#noResults {
    min-height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Accessibility improvements for keyboard navigation */
.card:focus-within {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
}

.btn:focus-visible {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
}

/* Skip to content link for accessibility */
.skip-to-content {
    position: absolute;
    left: -9999px;
    z-index: 999;
    padding: 1em;
    background-color: var(--bs-primary);
    color: white;
    text-decoration: none;
}

.skip-to-content:focus {
    left: 50%;
    transform: translateX(-50%);
    top: 1rem;
}

