/* ==================== */
/* TABLET (992px)       */
/* ==================== */

@media (max-width: 992px) {
    .stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .form-row-3 {
        grid-template-columns: 1fr 1fr;
    }
    
    .detail-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-lg .modal-content,
    .modal-xl .modal-content {
        max-width: 90%;
    }
    
    .main-content {
        padding: 24px;
    }
    
    .header h1 {
        font-size: 24px;
    }
}

/* ==================== */
/* MOBILE (768px)       */
/* ==================== */

@media (max-width: 768px) {
    /* Sidebar */
    .menu-toggle {
        display: flex;
    }
    
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    .main-content {
        margin-left: 0;
        padding: 80px 16px 24px;
    }
    
    /* Header */
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .header h1 {
        font-size: 20px;
    }
    
    .header-actions {
        width: 100%;
    }
    
    .header-actions .btn {
        flex: 1;
    }
    
    /* Stats */
    .stats {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    
    .stat-card {
        padding: 16px;
    }
    
    .stat-card .value {
        font-size: 24px;
    }
    
    .stat-card h3 {
        font-size: 11px;
    }
    
    .stat-card-icon {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    /* Cards */
    .card {
        padding: 16px;
        border-radius: var(--radius-md);
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .card-header .btn {
        width: 100%;
    }
    
    /* Tables - Hide table, show mobile cards */
    .table-responsive {
        display: none;
    }
    
    .mobile-cards {
        display: block;
    }
    
    /* Filters */
    .filters {
        flex-direction: column;
        gap: 12px;
    }
    
    .filters .form-control,
    .search-box {
        width: 100%;
        min-width: auto;
    }
    
    /* Forms */
    .form-row,
    .form-row-3 {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .form-group {
        margin-bottom: 16px;
    }
    
    /* Modal */
    .modal {
        padding: 12px;
    }
    
    .modal-content {
        padding: 24px;
        border-radius: var(--radius-md);
    }
    
    .modal-header h2 {
        font-size: 16px;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
    }
    
    /* Detail View */
    .detail-row {
        flex-direction: column;
        gap: 4px;
    }
    
    .detail-label,
    .detail-value {
        width: 100%;
    }
    
    .detail-section {
        padding: 16px;
    }
    
    .detail-section h3 {
        font-size: 13px;
    }
    
    /* Login */
    .login-box {
        padding: 32px 24px;
    }
    
    .login-header h1 {
        font-size: 20px;
    }
    
    .login-logo {
        width: 56px;
        height: 56px;
        font-size: 24px;
    }
    
    /* Tabs */
    .tabs {
        overflow-x: auto;
        padding: 4px;
    }
    
    .tab {
        padding: 10px 16px;
        white-space: nowrap;
        font-size: 13px;
    }
    
    .login-tabs {
        flex-direction: column;
        gap: 2px;
    }
    
    .login-tab {
        padding: 12px;
        border-radius: var(--radius-sm);
    }
    
    /* Toast */
    .toast-container {
        left: 12px;
        right: 12px;
        top: 12px;
    }
    
    .toast {
        min-width: auto;
        width: 100%;
    }
    
    /* Pagination */
    .pagination {
        gap: 4px;
    }
    
    .pagination .btn {
        padding: 8px 12px;
        min-width: 36px;
        font-size: 12px;
    }
    
    /* Timeline */
    .timeline {
        padding-left: 24px;
    }
    
    .timeline::before {
        left: 7px;
    }
    
    .timeline-item::before {
        left: -20px;
        width: 8px;
        height: 8px;
    }
    
    /* Button Group */
    .btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-group .btn {
        width: 100%;
    }
    
    /* Badges */
    .badge {
        font-size: 10px;
        padding: 4px 10px;
    }
}

/* ==================== */
/* SMALL MOBILE (480px) */
/* ==================== */

@media (max-width: 480px) {
    /* Stats */
    .stats {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .stat-card {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 14px 16px;
    }
    
    .stat-card h3 {
        margin-bottom: 0;
    }
    
    .stat-card .value {
        font-size: 22px;
    }
    
    .stat-card-header {
        flex-direction: row-reverse;
        gap: 12px;
    }
    
    /* Header */
    .header h1 {
        font-size: 18px;
    }
    
    /* Card */
    .card-title {
        font-size: 15px;
    }
    
    /* Modal */
    .modal-content {
        padding: 20px;
    }
    
    .modal-header {
        margin-bottom: 20px;
        padding-bottom: 16px;
    }
    
    /* Mobile Card */
    .mobile-card {
        padding: 16px;
    }
    
    .mobile-card-title {
        font-size: 14px;
    }
    
    .mobile-card-label {
        font-size: 11px;
    }
    
    .mobile-card-value {
        font-size: 13px;
    }
    
    .mobile-card-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    /* Buttons */
    .btn {
        padding: 10px 18px;
        font-size: 13px;
    }
    
    .btn-sm {
        padding: 6px 12px;
        font-size: 11px;
    }
    
    /* Form */
    .form-control {
        padding: 10px 14px;
        font-size: 14px;
    }
    
    .form-group label {
        font-size: 12px;
    }
    
    /* Login */
    .login-box {
        padding: 24px 20px;
    }
    
    .login-header {
        margin-bottom: 32px;
    }
    
    .login-logo {
        width: 48px;
        height: 48px;
        font-size: 20px;
        margin-bottom: 16px;
    }
    
    .login-header h1 {
        font-size: 18px;
    }
    
    /* Sidebar */
    .sidebar-header h2 {
        font-size: 16px;
    }
    
    .sidebar-menu a {
        padding: 10px 14px;
        font-size: 13px;
    }
    
    /* Empty State */
    .empty-state {
        padding: 48px 16px;
    }
    
    .empty-state-icon {
        font-size: 40px;
    }
    
    .empty-state h3 {
        font-size: 16px;
    }
    
    /* Notes */
    .note-item {
        padding: 12px;
    }
    
    .note-content {
        font-size: 13px;
    }
}

/* ==================== */
/* LANDSCAPE PHONE      */
/* ==================== */

@media (max-height: 500px) and (orientation: landscape) {
    .login-container {
        padding: 12px;
        align-items: flex-start;
        overflow-y: auto;
    }
    
    .login-box {
        padding: 20px 24px;
        margin: 12px 0;
    }
    
    .login-header {
        margin-bottom: 20px;
    }
    
    .login-header h1 {
        font-size: 18px;
        margin-bottom: 4px;
    }
    
    .login-logo {
        width: 40px;
        height: 40px;
        font-size: 18px;
        margin-bottom: 12px;
    }
    
    .form-group {
        margin-bottom: 12px;
    }
    
    .login-tabs {
        margin-bottom: 20px;
    }
    
    .modal-content {
        max-height: 95vh;
    }
}

/* ==================== */
/* PRINT                */
/* ==================== */

@media print {
    .sidebar,
    .menu-toggle,
    .sidebar-overlay,
    .header-actions,
    .btn,
    .filters,
    .pagination,
    .modal,
    .toast-container {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0;
        padding: 0;
        background: white;
    }
    
    body {
        background: white;
        color: black;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
        break-inside: avoid;
    }
    
    .table-responsive {
        display: block !important;
        overflow: visible;
    }
    
    .mobile-cards {
        display: none !important;
    }
    
    .table {
        min-width: auto;
    }
    
    .table th,
    .table td {
        padding: 8px;
        font-size: 12px;
    }
    
    .badge {
        border: 1px solid currentColor;
        background: transparent !important;
    }
}

/* ==================== */
/* HIGH CONTRAST        */
/* ==================== */

@media (prefers-contrast: high) {
    :root {
        --border-color: #444;
        --border-light: #555;
        --text-muted: #888;
    }
    
    .btn-primary {
        border-width: 2px;
    }
    
    .form-control {
        border-width: 2px;
    }
    
    .form-control:focus {
        outline: 2px solid var(--text-primary);
        outline-offset: 2px;
    }
}

/* ==================== */
/* REDUCED MOTION       */
/* ==================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .spinner {
        animation: none;
        border-top-color: transparent;
        border-right-color: var(--text-primary);
    }
}