/* Responsive Design Improvements */
/* Mobile-first approach with progressive enhancement */

/* Base mobile styles */
@media (max-width: 768px) {
    /* Header adjustments */
    #main-app .flex.h-screen {
        flex-direction: column;
    }
    
    /* Hide sidebar on mobile by default */
    aside {
        transform: translateX(-100%);
        position: fixed;
        z-index: 50;
        transition: transform 0.3s ease-in-out;
        height: 100vh;
        top: 0;
        left: 0;
    }
    
    aside.mobile-open {
        transform: translateX(0);
    }
    
    /* Mobile overlay */
    .mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 40;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
    }
    
    .mobile-overlay.active {
        opacity: 1;
        visibility: visible;
    }
    
    /* Main content adjustments */
    .flex-1.flex.flex-col {
        width: 100%;
        margin-left: 0;
    }
    
    /* Header mobile adjustments */
    header {
        padding: 0.75rem 1rem;
        border-bottom: 1px solid #e5e7eb;
    }
    
    .header-content {
        justify-content: space-between;
        align-items: center;
    }
    
    /* Mobile hamburger menu */
    .mobile-menu-btn {
        display: block;
        padding: 0.5rem;
        border: none;
        background: none;
        cursor: pointer;
        color: #374151;
        font-size: 1.25rem;
    }
    
    .mobile-menu-btn:hover {
        color: #111827;
        background-color: #f3f4f6;
        border-radius: 0.375rem;
    }
    
    /* Hide desktop search on mobile */
    .desktop-search {
        display: none;
    }
    
    /* Page title adjustments */
    .page-title {
        font-size: 1.25rem;
        line-height: 1.75rem;
    }
    
    .page-subtitle {
        font-size: 0.875rem;
        line-height: 1.25rem;
        display: none; /* Hide subtitle on very small screens */
    }
    
    /* Main content padding */
    main {
        padding: 1rem 0.75rem;
    }
    
    /* Card adjustments */
    .bg-white.rounded-lg.shadow-sm {
        border-radius: 0.5rem;
        margin-bottom: 1rem;
    }
    
    /* Table responsive */
    .overflow-x-auto table {
        min-width: 600px;
    }
    
    /* Hide less important table columns on mobile */
    .mobile-hide {
        display: none;
    }
    
    /* Button adjustments */
    .btn-group {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .btn-group .btn {
        width: 100%;
        justify-content: center;
    }
    
    /* Form adjustments */
    .grid.grid-cols-2 {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .grid.grid-cols-3 {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    /* Modal adjustments */
    .modal-content {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
    }
    
    /* Stats cards on mobile */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .stats-card {
        padding: 1rem;
    }
    
    /* Chart container on mobile */
    .chart-container {
        height: 250px;
        margin-bottom: 1rem;
    }
    
    /* Navigation improvements */
    .nav-item {
        padding: 0.75rem 1rem;
        margin-bottom: 0.25rem;
    }
    
    .nav-item i {
        width: 1.25rem;
        margin-right: 0.75rem;
    }
    
    /* User profile section */
    .sidebar .absolute.bottom-0 {
        position: relative;
        width: 100%;
        border-top: 1px solid #e5e7eb;
        margin-top: 1rem;
        padding-top: 1rem;
    }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    /* Sidebar adjustments for tablet */
    aside {
        width: 240px;
    }
    
    /* Reduce main content padding on tablet */
    main {
        padding: 1.5rem;
    }
    
    /* Grid adjustments for tablet */
    .grid.grid-cols-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Table adjustments */
    .table-container {
        overflow-x: auto;
    }
    
    /* Show subtitle on tablet */
    .page-subtitle {
        display: block;
    }
}

/* Large screens */
@media (min-width: 1025px) {
    /* Ensure sidebar is always visible */
    aside {
        position: relative;
        transform: none;
    }
    
    /* Hide mobile menu button */
    .mobile-menu-btn {
        display: none;
    }
    
    /* Full desktop experience */
    .desktop-search {
        display: block;
    }
    
    .page-subtitle {
        display: block;
    }
    
    /* Restore normal grid layouts */
    .grid.grid-cols-2 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .grid.grid-cols-3 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    /* Normal button layouts */
    .btn-group {
        flex-direction: row;
    }
    
    /* Show all table columns */
    .mobile-hide {
        display: table-cell;
    }
}

/* Dark theme responsive adjustments */
.theme-dark {
    /* Mobile overlay in dark theme */
    .mobile-overlay {
        background-color: rgba(0, 0, 0, 0.7);
    }
    
    /* Sidebar in dark theme */
    aside {
        background-color: #1f2937;
        border-right-color: #374151;
    }
    
    .mobile-menu-btn {
        color: #e5e7eb;
    }
    
    .mobile-menu-btn:hover {
        color: #f9fafb;
        background-color: #374151;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets */
    button, .nav-item, .btn {
        min-height: 44px;
        padding: 0.75rem 1rem;
    }
    
    /* Improve form controls for touch */
    input, select, textarea {
        min-height: 44px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Better spacing for touch interfaces */
    .space-y-2 > * + * {
        margin-top: 0.75rem;
    }
    
    .space-y-4 > * + * {
        margin-top: 1.25rem;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    /* Disable animations for users who prefer reduced motion */
    aside {
        transition: none;
    }
    
    .mobile-overlay {
        transition: none;
    }
    
    .loading-spinner {
        animation: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .border-gray-200 {
        border-color: #000;
    }
    
    .text-gray-500 {
        color: #000;
    }
    
    .bg-gray-50 {
        background-color: #fff;
    }
}

/* Print styles */
@media print {
    /* Hide navigation and non-essential elements */
    aside, .mobile-menu-btn, .mobile-overlay {
        display: none !important;
    }
    
    /* Adjust main content for printing */
    main {
        padding: 0;
        margin: 0;
    }
    
    /* Ensure content fits on page */
    .container {
        max-width: none;
    }
    
    /* Hide interactive elements */
    button, .btn {
        display: none;
    }
    
    /* Optimize colors for printing */
    * {
        color: #000 !important;
        background: #fff !important;
    }
    
    /* Keep essential borders */
    table, th, td {
        border: 1px solid #000 !important;
    }
}