/* Mobile-first responsive design improvements */
@media (max-width: 768px) {
    /* Mobile navigation improvements */
    .navbar-nav {
        padding: 0.5rem 0;
    }
    
    .navbar-nav .nav-link {
        padding: 0.75rem 1rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .navbar-nav .nav-link:last-child {
        border-bottom: none;
    }
    
    /* Mobile table improvements */
    .table-responsive {
        border: none;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table-responsive table {
        min-width: 800px;
    }
    
    /* Mobile card improvements */
    .card {
        margin-bottom: 1rem;
        border-radius: 0.5rem;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    
    .card-header {
        padding: 1rem;
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    }
    
    .card-body {
        padding: 1rem;
    }
    
    /* Mobile form improvements */
    .form-control {
        min-height: 44px; /* Touch-friendly height */
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .btn {
        min-height: 44px;
        padding: 0.75rem 1rem;
        font-size: 16px;
    }
    
    /* Mobile sidebar improvements */
    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 280px;
        height: 100vh;
        background-color: #1f2937;
        z-index: 1050;
        transition: left 0.3s ease;
        overflow-y: auto;
    }
    
    .sidebar.show {
        left: 0;
    }
    
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1040;
    }
    
    .sidebar-overlay.show {
        display: block;
    }
    
    /* Mobile main content */
    .main-content {
        margin-left: 0;
        padding: 1rem;
        min-height: calc(100vh - 60px);
    }
    
    /* Mobile header */
    .navbar-brand {
        font-size: 1.2rem;
    }
    
    .navbar-toggler {
        border: none;
        padding: 0.5rem;
    }
    
    .navbar-toggler:focus {
        box-shadow: none;
    }
    
    /* Mobile search */
    .search-form {
        margin-top: 1rem;
    }
    
    .search-form input {
        border-radius: 0.375rem;
        border: 1px solid #d1d5db;
    }
    
    /* Mobile dropdown menus */
    .dropdown-menu {
        border: none;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
        border-radius: 0.375rem;
    }
    
    .dropdown-item {
        padding: 0.75rem 1rem;
    }
    
    /* Mobile alerts */
    .alert {
        border-radius: 0.375rem;
        margin-bottom: 1rem;
    }
    
    /* Mobile badges */
    .badge {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
    
    /* Mobile pagination */
    .pagination {
        justify-content: center;
        margin-top: 1rem;
    }
    
    .page-link {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Mobile stats cards */
    .stats-card {
        margin-bottom: 1rem;
    }
    
    .stats-card .card-body {
        padding: 1.5rem;
        text-align: center;
    }
    
    .stats-card .stats-number {
        font-size: 2rem;
        font-weight: bold;
        color: #1f2937;
    }
    
    .stats-card .stats-label {
        color: #6b7280;
        font-size: 0.875rem;
        margin-top: 0.5rem;
    }
    
    /* Mobile chart improvements */
    .chart-container {
        position: relative;
        height: 300px;
        margin-bottom: 1rem;
    }
    
    /* Mobile modal improvements */
    .modal-dialog {
        margin: 1rem;
        max-width: calc(100vw - 2rem);
    }
    
    .modal-content {
        border-radius: 0.5rem;
    }
    
    .modal-header {
        padding: 1rem;
        border-bottom: 1px solid #e5e7eb;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .modal-footer {
        padding: 1rem;
        border-top: 1px solid #e5e7eb;
    }
    
    /* Mobile utility classes */
    .text-xs-center {
        text-align: center !important;
    }
    
    .text-xs-left {
        text-align: left !important;
    }
    
    .text-xs-right {
        text-align: right !important;
    }
    
    .d-xs-block {
        display: block !important;
    }
    
    .d-xs-none {
        display: none !important;
    }
    
    .d-xs-inline {
        display: inline !important;
    }
    
    .d-xs-inline-block {
        display: inline-block !important;
    }
    
    .d-xs-flex {
        display: flex !important;
    }
    
    .flex-xs-column {
        flex-direction: column !important;
    }
    
    .flex-xs-row {
        flex-direction: row !important;
    }
    
    .w-xs-100 {
        width: 100% !important;
    }
    
    .w-xs-auto {
        width: auto !important;
    }
    
    .mb-xs-3 {
        margin-bottom: 1rem !important;
    }
    
    .mt-xs-3 {
        margin-top: 1rem !important;
    }
    
    .p-xs-3 {
        padding: 1rem !important;
    }
    
    .px-xs-3 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    .py-xs-3 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }
}

/* Tablet specific improvements */
@media (min-width: 769px) and (max-width: 1024px) {
    .main-content {
        margin-left: 200px;
        padding: 1.5rem;
    }
    
    .sidebar {
        width: 200px;
    }
    
    .card-columns {
        column-count: 2;
    }
    
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .form-row .col-md-6 {
        margin-bottom: 1rem;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .btn:hover,
    .btn:focus {
        transform: none;
        box-shadow: none;
    }
    
    .dropdown-item:hover {
        background-color: #f8f9fa;
    }
    
    .nav-link:hover {
        background-color: rgba(255, 255, 255, 0.1);
    }
    
    .table-hover tbody tr:hover {
        background-color: rgba(0, 0, 0, 0.05);
    }
    
    /* Increase touch targets */
    .btn-sm {
        min-height: 36px;
        padding: 0.5rem 0.75rem;
    }
    
    .btn-lg {
        min-height: 56px;
        padding: 1rem 1.5rem;
    }
    
    .form-control-sm {
        min-height: 36px;
        font-size: 14px;
    }
    
    .form-control-lg {
        min-height: 56px;
        font-size: 18px;
    }
}

/* High DPI screen improvements */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .chart-container canvas {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
    
    .table {
        border-collapse: separate;
        border-spacing: 0;
    }
    
    .table td,
    .table th {
        border-width: 1px;
    }
}

/* Dark mode support preparation */
@media (prefers-color-scheme: dark) {
    .card {
        background-color: #374151;
        border-color: #4b5563;
    }
    
    .card-header {
        background-color: #4b5563;
        border-color: #6b7280;
    }
    
    .table {
        color: #f9fafb;
    }
    
    .table-striped tbody tr:nth-of-type(odd) {
        background-color: rgba(255, 255, 255, 0.05);
    }
    
    .form-control {
        background-color: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }
    
    .form-control:focus {
        background-color: #374151;
        border-color: #10b981;
        color: #f9fafb;
        box-shadow: 0 0 0 0.2rem rgba(16, 185, 129, 0.25);
    }
    
    .btn-primary {
        background-color: #10b981;
        border-color: #10b981;
    }
    
    .btn-primary:hover {
        background-color: #059669;
        border-color: #059669;
    }
    
    .alert-success {
        background-color: #065f46;
        border-color: #10b981;
        color: #d1fae5;
    }
    
    .alert-danger {
        background-color: #7f1d1d;
        border-color: #ef4444;
        color: #fee2e2;
    }
    
    .alert-warning {
        background-color: #78350f;
        border-color: #f59e0b;
        color: #fef3c7;
    }
    
    .alert-info {
        background-color: #1e3a8a;
        border-color: #3b82f6;
        color: #dbeafe;
    }
}

/* Print styles */
@media print {
    .sidebar,
    .navbar,
    .btn,
    .dropdown,
    .modal,
    .alert {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }
    
    .card {
        border: 1px solid #000;
        box-shadow: none;
        page-break-inside: avoid;
    }
    
    .table {
        border-collapse: collapse;
    }
    
    .table th,
    .table td {
        border: 1px solid #000;
        padding: 0.5rem;
    }
    
    .text-primary,
    .text-success,
    .text-info,
    .text-warning,
    .text-danger {
        color: #000 !important;
    }
    
    .bg-primary,
    .bg-success,
    .bg-info,
    .bg-warning,
    .bg-danger {
        background-color: #fff !important;
        color: #000 !important;
    }
}

/* Accessibility improvements */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #000;
    color: #fff;
    padding: 8px;
    text-decoration: none;
    z-index: 100;
}

.skip-link:focus {
    top: 6px;
}

/* Focus styles */
.btn:focus,
.form-control:focus,
.form-select:focus,
.nav-link:focus {
    outline: 2px solid #10b981;
    outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    ::before,
    ::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
