/* HRMIS Responsive Styles */
/* Mobile and tablet optimizations */

/* Mobile First Approach */
@media (max-width: 768px) {
    /* Show mobile sidebar toggle */
    .sidebar-toggle {
        display: flex !important;
    }

    /* Adjust app layout for mobile */
    .authenticated .app-container {
        display: flex !important;
        flex-direction: column !important;
        grid-template-areas: none !important;
        grid-template-columns: none !important;
        grid-template-rows: none !important;
    }

    /* Mobile header */
    .app-header {
        position: fixed !important;
        top: 0;
        left: 0;
        right: 0;
        height: 60px;
        z-index: 1000;
        padding: 0 16px !important;
    }

    /* Mobile sidebar */
    .app-sidebar {
        position: fixed !important;
        top: 60px !important;
        left: -280px;
        width: 280px !important;
        height: calc(100vh - 60px) !important;
        z-index: 1001;
        transition: left 0.3s ease;
        box-shadow: none;
        overflow-y: auto;
    }

    .app-sidebar.show {
        left: 0 !important;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    }

    /* Mobile sidebar overlay */
    .sidebar-overlay {
        position: fixed;
        top: 60px;
        left: 0;
        width: 100%;
        height: calc(100vh - 60px);
        background: rgba(0, 0, 0, 0.5);
        z-index: 1000;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }

    .sidebar-overlay.show {
        opacity: 1;
        visibility: visible;
    }

    /* Mobile main content */
    .app-main {
        margin-top: 60px !important;
        min-height: calc(100vh - 60px) !important;
        width: 100% !important;
    }

    /* Mobile header adjustments */
    .header-title h1 {
        font-size: 15px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 160px;
    }

    .header-subtitle {
        display: none;
    }

    .user-info {
        display: none;
    }

    .dropdown-arrow {
        display: none;
    }

    /* Mobile main content */
    .main-content {
        padding: 16px !important;
    }

    /* Mobile dashboard grid */
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .dashboard-card {
        padding: 16px;
    }

    /* Mobile stats grid */
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 12px;
    }

    .stat-number {
        font-size: 20px;
    }

    /* Mobile login adjustments */
    .login-container {
        padding: 16px;
    }

    .login-box {
        max-width: 100%;
    }

    .login-header {
        padding: 24px 24px 16px;
    }

    .login-form {
        padding: 24px;
    }

    .login-footer {
        padding: 16px 24px;
    }

    /* Mobile buttons */
    .btn {
        padding: 10px 16px;
        min-height: 40px;
    }

    /* Mobile tables */
    .table-container,
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table {
        min-width: 600px;
    }

    /* Mobile modals */
    .modal-dialog {
        margin: 10px !important;
        max-width: calc(100vw - 20px) !important;
    }

    .modal-content {
        width: 100% !important;
        max-height: 90vh;
        overflow-y: auto;
    }

    .modal-header {
        padding: 16px 20px;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-footer {
        padding: 16px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .modal-footer .btn {
        flex: 1;
        min-width: 100px;
    }

    /* Mobile forms */
    .form-group {
        margin-bottom: 16px;
    }

    /* Mobile cards */
    .card-body {
        padding: 16px;
    }

    .card-header,
    .card-footer {
        padding: 12px 16px;
    }

    /* Mobile breadcrumb */
    .breadcrumb {
        font-size: 12px;
        flex-wrap: wrap;
    }

    /* Mobile tabs */
    .tab-list {
        flex-wrap: wrap;
    }

    .tab-link {
        padding: 10px 16px;
        font-size: 13px;
    }

    /* Hide sidebar collapse button on mobile */
    .sidebar-collapse-btn {
        display: none;
    }

    /* Bootstrap grid adjustments for mobile */
    .container-fluid {
        padding-left: 12px;
        padding-right: 12px;
    }

    .row {
        margin-left: -6px;
        margin-right: -6px;
    }

    .row > [class*="col-"] {
        padding-left: 6px;
        padding-right: 6px;
    }

    /* Page header stack on mobile */
    .d-flex.justify-content-between {
        flex-direction: column;
        gap: 12px;
    }

    /* Filter row stacking */
    .card .row.g-3 > [class*="col-md"] {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* Tablet Styles */
@media (min-width: 769px) and (max-width: 1024px) {
    /* Tablet sidebar */
    :root {
        --sidebar-width: 240px;
    }

    /* Tablet header */
    .header-title h1 {
        font-size: 17px;
    }

    /* Tablet main content */
    .main-content {
        padding: 20px;
    }

    /* Tablet dashboard */
    .dashboard-grid {
        grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
        gap: 20px;
    }

    /* Tablet login */
    .login-box {
        max-width: 420px;
    }

    /* Tablet modal */
    .modal-content {
        width: 85%;
        max-width: 700px;
    }

    /* Tablet stats */
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    }

    /* Tablet stat tiles wrap */
    .site-stats-grid {
        flex-wrap: wrap;
    }

    .stat-tile {
        min-width: calc(33.333% - 10px);
        flex: 1 1 calc(33.333% - 10px);
    }
}

/* Large Screen Optimizations */
@media (min-width: 1200px) {
    /* Wider sidebar for large screens */
    :root {
        --sidebar-width: 280px;
    }

    /* More spacious content */
    .main-content {
        padding: 32px;
    }

    /* Better dashboard layout */
    .dashboard-grid {
        grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
        gap: 32px;
    }

    .dashboard-card {
        padding: 32px;
    }

    /* Larger modals */
    .modal-content {
        max-width: 800px;
    }

    /* Better table spacing */
    .table th,
    .table td {
        padding: 16px;
    }
}

/* Ultra-wide Screen Optimizations */
@media (min-width: 1440px) {
    /* Constrain content width on very large screens */
    .main-content {
        max-width: 1400px;
        margin: 0 auto;
        padding: 32px 40px;
    }

    /* Dashboard adjustments */
    .dashboard-grid {
        grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    }
}

/* High DPI / Retina Display Optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 2dppx) {
    /* Ensure crisp borders on high DPI displays */
    .app-sidebar,
    .app-header,
    .content-card,
    .dashboard-card {
        border-width: 0.5px;
    }

    /* Better icon rendering */
    .nav-icon,
    .icon-btn .icon {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Print Styles */
@media print {
    /* Hide navigation and interactive elements */
    .app-sidebar,
    .app-header,
    .sidebar-toggle,
    .user-menu,
    .btn,
    .loading-overlay {
        display: none !important;
    }

    /* Adjust layout for printing */
    .authenticated .app-container {
        display: block;
    }

    .app-main {
        margin: 0;
        padding: 0;
    }

    .main-content {
        padding: 0;
    }

    /* Print-friendly colors */
    * {
        color: black !important;
        background: white !important;
        box-shadow: none !important;
    }

    /* Keep essential borders */
    .table,
    .table th,
    .table td,
    .content-card,
    .dashboard-card {
        border: 1px solid #ccc !important;
    }

    /* Page breaks */
    .dashboard-card,
    .content-card {
        page-break-inside: avoid;
        margin-bottom: 20px;
    }

    /* Print typography */
    body {
        font-size: 12px;
        line-height: 1.4;
    }

    h1, h2, h3, h4, h5, h6 {
        font-size: 14px;
        font-weight: bold;
        margin-bottom: 8px;
    }
}

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

    .spinner {
        animation: none;
        border: 4px solid var(--border-color);
    }
}

/* Dark Mode Support (if enabled in future) */
@media (prefers-color-scheme: dark) {
    /* This will be implemented when dark mode is added */
    /* For now, we'll keep the light theme */
}

/* Landscape vs Portrait Optimizations */
@media (max-width: 768px) and (orientation: landscape) {
    /* Landscape mobile adjustments */
    .login-container {
        padding: 12px;
    }

    .login-header {
        padding: 16px 24px 12px;
    }

    .login-header h1 {
        font-size: 20px;
        margin-bottom: 4px;
    }

    .login-header h2 {
        font-size: 16px;
    }

    .modal-content {
        max-height: 90vh;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .btn,
    .nav-link,
    .user-menu-btn,
    .dropdown-toggle {
        min-height: 44px;
        padding: 12px 16px;
    }

    /* Better hover states for touch */
    .btn:hover,
    .nav-link:hover,
    .user-menu-btn:hover {
        transform: none;
        background-color: var(--secondary-light);
    }

    /* Remove hover effects that don't work on touch */
    .table tr:hover {
        background: transparent;
    }

    /* Better focus indicators for keyboard navigation */
    .btn:focus,
    .nav-link:focus,
    input:focus,
    select:focus,
    textarea:focus {
        outline: 2px solid var(--primary);
        outline-offset: 2px;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000;
        --text-secondary: #333;
        --text-hint: #666;
    }

    .btn-outline {
        border-width: 2px;
    }

    .nav-link {
        border-left-width: 4px;
    }
}