/* ============================================================================
   HRM RESPONSIVE FIXES - Complete Mobile, Tablet & Desktop Optimization
   Ensures forms, icons, tables, and all UI elements are fully responsive
   ============================================================================ */

/* ============================================================================
   FORM INPUT ICON FIXES - Proper Spacing & Alignment
   ============================================================================ */

/* Form groups with icons */
.hrm-form-group {
    position: relative;
    margin-bottom: 20px;
    width: 100%;
}

/* Input fields with left icons */
.hrm-input-with-icon,
.hrm-input[data-icon],
.hrm-form-group .hrm-input:not([type="checkbox"]):not([type="radio"]) {
    padding-left: 44px !important;
    padding-right: 16px !important;
    width: 100%;
    min-height: 44px;
    box-sizing: border-box;
}

/* Icon positioning for input fields */
.hrm-form-group .dashicons,
.hrm-input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    width: 18px;
    height: 18px;
    color: var(--hrm-text-secondary, #6B7280);
    pointer-events: none;
    z-index: 2;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Adjust for label positioning */
.hrm-form-group .hrm-form-label+.hrm-input-icon,
.hrm-form-group .hrm-form-label~.dashicons {
    top: calc(50% + 12px);
}

/* Select fields with icons */
.hrm-form-group select.hrm-input,
.hrm-form-group .hrm-select {
    padding-left: 44px !important;
    padding-right: 36px !important;
    background-position: right 12px center;
}

/* Date inputs with icons */
.hrm-form-group input[type="date"].hrm-input,
.hrm-form-group input[type="month"].hrm-input {
    padding-left: 44px !important;
    padding-right: 16px !important;
}

/* Number inputs with icons */
.hrm-form-group input[type="number"].hrm-input {
    padding-left: 44px !important;
    padding-right: 16px !important;
}

/* Email inputs with icons */
.hrm-form-group input[type="email"].hrm-input {
    padding-left: 44px !important;
    padding-right: 16px !important;
}

/* ============================================================================
   ACTION ICON BUTTONS - Touch-Friendly & Properly Spaced
   ============================================================================ */

/* Action button containers */
.hrm-actions,
.hrm-actions-flex,
.hrm-table-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Individual action buttons */
.hrm-btn-icon,
.hrm-action-btn,
button.btn-sm {
    min-width: 36px;
    min-height: 36px;
    padding: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
    cursor: pointer;
    border: 1px solid transparent;
}

/* Icon sizing within buttons */
.hrm-btn-icon .dashicons,
.hrm-action-btn .dashicons,
button.btn-sm .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    line-height: 1;
}

/* Touch-friendly spacing for mobile */
@media (max-width: 768px) {

    .hrm-btn-icon,
    .hrm-action-btn,
    button.btn-sm {
        min-width: 44px;
        min-height: 44px;
        padding: 12px;
    }

    .hrm-actions,
    .hrm-actions-flex,
    .hrm-table-actions {
        gap: 12px;
    }
}

/* ============================================================================
   TABLE RESPONSIVENESS - Horizontal Scroll & Mobile Optimization
   ============================================================================ */

/* Table wrapper for horizontal scrolling */
.hrm-table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 24px;
    border-radius: 12px;
    border: 1px solid var(--hrm-border-default, #E5E7EB);
}

/* Table base styles */
.hrm-table {
    width: 100%;
    min-width: 800px;
    border-collapse: collapse;
    background: white;
}

.hrm-table th,
.hrm-table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--hrm-border-light, #F3F4F6);
    white-space: nowrap;
}

.hrm-table th {
    background: var(--hrm-gray-50, #F9FAFB);
    font-weight: 600;
    color: var(--hrm-text-primary, #111827);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Mobile table optimization */
@media (max-width: 768px) {
    .hrm-table {
        min-width: 600px;
    }

    .hrm-table th,
    .hrm-table td {
        padding: 12px 8px;
        font-size: 13px;
    }

    /* Hide less important columns on mobile */
    .hrm-table th.hide-mobile,
    .hrm-table td.hide-mobile {
        display: none;
    }
}

@media (max-width: 480px) {
    .hrm-table {
        min-width: 500px;
    }

    .hrm-table th,
    .hrm-table td {
        padding: 10px 6px;
        font-size: 12px;
    }
}

/* ============================================================================
   FORM GRID LAYOUTS - Responsive Column Adjustments
   ============================================================================ */

/* Two-column form grids */
.hrm-form-grid,
.hrm-form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

/* Three-column form grids */
.hrm-form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

/* Tablet: 2 columns become 1 */
@media (max-width: 1024px) {
    .hrm-form-grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile: All columns become 1 */
@media (max-width: 768px) {

    .hrm-form-grid,
    .hrm-form-row,
    .hrm-form-grid-3 {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

/* ============================================================================
   MODAL RESPONSIVENESS - Full-Width on Mobile
   ============================================================================ */

.hrm-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}

.hrm-modal-content,
.hrm-premium-modal {
    background: white;
    border-radius: 16px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

/* Large modals */
.hrm-modal-content.large,
.hrm-premium-modal.large {
    max-width: 900px;
}

/* Mobile modal adjustments */
@media (max-width: 768px) {
    .hrm-modal {
        padding: 10px;
    }

    .hrm-modal-content,
    .hrm-premium-modal {
        max-width: 100%;
        max-height: 95vh;
        border-radius: 12px;
    }

    .hrm-modal-header-premium,
    .hrm-modal-body,
    .hrm-modal-footer-premium {
        padding: 20px !important;
    }
}

@media (max-width: 480px) {
    .hrm-modal {
        padding: 0;
    }

    .hrm-modal-content,
    .hrm-premium-modal {
        max-height: 100vh;
        border-radius: 0;
    }

    .hrm-modal-header-premium,
    .hrm-modal-body,
    .hrm-modal-footer-premium {
        padding: 16px !important;
    }
}

/* ============================================================================
   BUTTON RESPONSIVENESS - Stack on Mobile
   ============================================================================ */

/* Button groups */
.hrm-button-group,
.hrm-header-right,
.hrm-filter-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* Mobile button stacking */
@media (max-width: 768px) {

    .hrm-button-group,
    .hrm-header-right,
    .hrm-filter-actions {
        width: 100%;
    }

    .hrm-button-group .hrm-btn,
    .hrm-header-right .hrm-btn,
    .hrm-filter-actions .hrm-btn {
        flex: 1;
        min-width: 120px;
    }
}

@media (max-width: 480px) {

    .hrm-button-group,
    .hrm-header-right,
    .hrm-filter-actions {
        flex-direction: column;
        gap: 10px;
    }

    .hrm-button-group .hrm-btn,
    .hrm-header-right .hrm-btn,
    .hrm-filter-actions .hrm-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ============================================================================
   CARD & STAT GRID RESPONSIVENESS
   ============================================================================ */

/* Stats row - 4 columns */
.hrm-stats-row,
.hrm-payroll-stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

/* Tablet: 2 columns */
@media (max-width: 1024px) {

    .hrm-stats-row,
    .hrm-payroll-stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile: 1 column */
@media (max-width: 768px) {

    .hrm-stats-row,
    .hrm-payroll-stats-row {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

/* Quick actions grid - 3 columns */
.hrm-payroll-quick-actions,
.hrm-quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

/* Tablet: 2 columns */
@media (max-width: 1024px) {

    .hrm-payroll-quick-actions,
    .hrm-quick-actions-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile: 1 column */
@media (max-width: 768px) {

    .hrm-payroll-quick-actions,
    .hrm-quick-actions-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================================
   HEADER SECTION RESPONSIVENESS
   ============================================================================ */

.hrm-header-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 24px;
    background: white;
    border-radius: 12px;
    margin-bottom: 24px;
    border: 1px solid var(--hrm-border-default, #E5E7EB);
}

.hrm-header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* Mobile header stacking */
@media (max-width: 768px) {
    .hrm-header-section {
        flex-direction: column;
        align-items: flex-start;
        padding: 20px;
    }

    .hrm-header-left {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        width: 100%;
    }

    .hrm-header-right {
        width: 100%;
        justify-content: flex-start;
    }
}

/* ============================================================================
   NAVIGATION TABS RESPONSIVENESS
   ============================================================================ */

.hrm-nav-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--hrm-border-light, #F3F4F6);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.hrm-nav-link {
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--hrm-text-secondary, #6B7280);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    transition: all 0.2s ease;
    margin-bottom: -2px;
}

.hrm-nav-link:hover {
    color: var(--hrm-text-primary, #111827);
    background: var(--hrm-gray-50, #F9FAFB);
    border-radius: 8px 8px 0 0;
}

.hrm-nav-link.active {
    color: var(--hrm-primary, #0C8776);
    border-bottom-color: var(--hrm-primary, #0C8776);
    font-weight: 600;
}

/* Mobile tabs */
@media (max-width: 768px) {
    .hrm-nav-tabs {
        gap: 4px;
    }

    .hrm-nav-link {
        padding: 10px 16px;
        font-size: 13px;
    }
}

/* ============================================================================
   FILTER BAR RESPONSIVENESS
   ============================================================================ */

.hrm-filter-bar,
.hrm-filter-bar-enhanced {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px;
    background: white;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid var(--hrm-border-default, #E5E7EB);
    flex-wrap: wrap;
}

.hrm-filter-group {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.hrm-search-input {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.hrm-search-input input {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid var(--hrm-border-default, #E5E7EB);
    border-radius: 8px;
    font-size: 14px;
}

/* Mobile filter bar */
@media (max-width: 768px) {

    .hrm-filter-bar,
    .hrm-filter-bar-enhanced {
        flex-direction: column;
        align-items: stretch;
        padding: 16px;
    }

    .hrm-filter-group {
        width: 100%;
        flex-direction: column;
        gap: 10px;
    }

    .hrm-search-input {
        width: 100%;
        min-width: auto;
    }

    .hrm-filter-group .hrm-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ============================================================================
   PAYROLL SPECIFIC FIXES
   ============================================================================ */

/* Payroll stat cards */
.hrm-payroll-stat-card-enhanced {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: white;
    border-radius: 12px;
    border: 1px solid var(--hrm-border-default, #E5E7EB);
    transition: all 0.2s ease;
}

.hrm-payroll-stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.hrm-payroll-stat-info {
    flex: 1;
    min-width: 0;
}

.hrm-payroll-stat-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--hrm-text-secondary, #6B7280);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.hrm-payroll-stat-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: var(--hrm-text-primary, #111827);
}

/* Mobile payroll stats */
@media (max-width: 768px) {
    .hrm-payroll-stat-card-enhanced {
        padding: 16px;
    }

    .hrm-payroll-stat-icon {
        width: 40px;
        height: 40px;
    }

    .hrm-payroll-stat-value {
        font-size: 20px;
    }
}

/* Payroll action cards */
.hrm-payroll-action-card {
    display: block;
    padding: 20px;
    background: white;
    border: 1px solid var(--hrm-border-default, #E5E7EB);
    border-radius: 12px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.hrm-payroll-action-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    border-color: var(--hrm-primary, #0C8776);
}

.hrm-payroll-action-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.hrm-payroll-action-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--hrm-gray-50, #F9FAFB);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--hrm-primary, #0C8776);
}

.hrm-payroll-action-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--hrm-text-primary, #111827);
}

.hrm-payroll-action-desc {
    margin: 0;
    font-size: 13px;
    color: var(--hrm-text-secondary, #6B7280);
    line-height: 1.5;
}

/* ============================================================================
   STRUCTURE SECTIONS GRID - Allowances & Deductions
   ============================================================================ */

.hrm-structure-sections-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    padding-top: 24px;
    border-top: 1px solid var(--hrm-border-light, #F3F4F6);
}

@media (max-width: 768px) {
    .hrm-structure-sections-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

/* Slab rows for tax configuration */
.slab-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 42px;
    gap: 12px;
    margin-bottom: 12px;
    align-items: center;
}

@media (max-width: 768px) {
    .slab-row {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .slab-row input:nth-child(3) {
        grid-column: 1 / 2;
    }

    .slab-row button {
        grid-column: 2 / 3;
        height: 42px;
    }
}

@media (max-width: 480px) {
    .slab-row {
        grid-template-columns: 1fr;
    }

    .slab-row input,
    .slab-row button {
        grid-column: 1 / -1;
    }
}

/* ============================================================================
   BADGE & STATUS INDICATORS
   ============================================================================ */

.hrm-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.hrm-badge-primary {
    background: #DBEAFE;
    color: #1E40AF;
}

.hrm-badge-success {
    background: #D1FAE5;
    color: #065F46;
}

.hrm-badge-warning {
    background: #FEF3C7;
    color: #92400E;
}

.hrm-badge-danger {
    background: #FEE2E2;
    color: #991B1B;
}

.hrm-badge-info {
    background: #E0E7FF;
    color: #3730A3;
}

.hrm-badge-neutral {
    background: #F3F4F6;
    color: #6B7280;
}

/* Mobile badge sizing */
@media (max-width: 480px) {
    .hrm-badge {
        font-size: 11px;
        padding: 3px 8px;
    }
}

/* ============================================================================
   LOADING & SPINNER STATES
   ============================================================================ */

.hrm-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--hrm-gray-200, #E5E7EB);
    border-top-color: var(--hrm-primary, #0C8776);
    border-radius: 50%;
    animation: hrm-spin 0.8s linear infinite;
}

@keyframes hrm-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================================================
   PRINT STYLES - Optimize for Payslips
   ============================================================================ */

@media print {

    .no-print,
    .hrm-modal-header-premium,
    .hrm-nav-tabs,
    .hrm-filter-bar,
    .hrm-header-section,
    .hrm-btn,
    button {
        display: none !important;
    }

    .hrm-modal-content,
    .printable-area {
        max-width: 100%;
        box-shadow: none;
        border: none;
    }

    body {
        background: white;
    }
}

/* ============================================================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================================================ */

/* Focus states for keyboard navigation */
.hrm-btn:focus-visible,
.hrm-input:focus-visible,
.hrm-select:focus-visible,
.hrm-nav-link:focus-visible {
    outline: 2px solid var(--hrm-primary, #0C8776);
    outline-offset: 2px;
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================================================
   UTILITY CLASSES FOR RESPONSIVE VISIBILITY
   ============================================================================ */

/* Hide on mobile */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Hide on tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    .hide-tablet {
        display: none !important;
    }
}

/* Hide on desktop */
@media (min-width: 1025px) {
    .hide-desktop {
        display: none !important;
    }
}

/* Show only on mobile */
.show-mobile {
    display: none !important;
}

@media (max-width: 768px) {
    .show-mobile {
        display: block !important;
    }
}

/* ============================================================================
   WORDPRESS ADMIN BAR COMPATIBILITY
   ============================================================================ */

@media screen and (max-width: 782px) {
    .hrm-wrap {
        margin-top: 46px;
    }
}

@media screen and (max-width: 600px) {
    .hrm-wrap {
        margin: 10px 10px 0 0;
    }
}

/* ============================================================================
   ENHANCED MOBILE-FIRST RESPONSIVE IMPROVEMENTS
   ============================================================================ */

/* Viewport and Container Optimization */
@media (max-width: 1440px) {
    .hrm-wrap {
        max-width: 100%;
        padding: 0 20px;
    }
}

@media (max-width: 1200px) {
    .hrm-wrap {
        padding: 0 16px;
    }

    /* Adjust main grid layouts */
    .hrm-main-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }
}

/* ============================================================================
   ENHANCED FORM RESPONSIVENESS
   ============================================================================ */

/* Better form field sizing on tablets */
@media (max-width: 1024px) {

    .hrm-input,
    .hrm-select,
    .hrm-textarea {
        font-size: 16px;
        /* Prevents zoom on iOS */
        min-height: 48px;
    }

    .hrm-form-group label {
        font-size: 14px;
        margin-bottom: 8px;
    }
}

/* Mobile form optimization */
@media (max-width: 768px) {

    .hrm-input,
    .hrm-select,
    .hrm-textarea {
        padding: 14px 16px;
        border-radius: 8px;
    }

    /* Input with icons - better spacing */
    .hrm-input-with-icon,
    .hrm-input[data-icon] {
        padding-left: 48px !important;
    }

    .hrm-form-group .dashicons,
    .hrm-input-icon {
        left: 16px;
        font-size: 20px;
        width: 20px;
        height: 20px;
    }
}

/* ============================================================================
   ENHANCED TABLE RESPONSIVENESS
   ============================================================================ */

/* Better table scrolling on all devices */
.hrm-table-wrapper {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #CBD5E1 transparent;
}

/* Table optimization for tablets */
@media (max-width: 1024px) {
    .hrm-table {
        min-width: 700px;
    }

    .hrm-table th,
    .hrm-table td {
        padding: 14px 12px;
        font-size: 13px;
    }
}

/* Mobile table with better touch targets */
@media (max-width: 768px) {
    .hrm-table-wrapper {
        margin: 0 -16px;
        width: calc(100% + 32px);
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .hrm-table {
        min-width: 600px;
    }

    .hrm-table th,
    .hrm-table td {
        padding: 12px 10px;
        font-size: 12px;
    }

    /* Stack action buttons vertically */
    .hrm-actions-flex,
    .hrm-table-actions {
        flex-direction: column;
        gap: 6px;
        align-items: stretch;
    }

    .hrm-actions-flex .hrm-btn,
    .hrm-table-actions .hrm-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ============================================================================
   ENHANCED DASHBOARD & STATS RESPONSIVENESS
   ============================================================================ */

/* Laptop screens */
@media (max-width: 1366px) {

    .hrm-stats-row,
    .hrm-payroll-stats-row {
        grid-template-columns: repeat(3, 1fr);
        gap: 18px;
    }
}

/* Tablet landscape */
@media (max-width: 1024px) {

    .hrm-stats-row,
    .hrm-payroll-stats-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .hrm-stat-card,
    .hrm-payroll-stat-card-enhanced {
        padding: 20px;
        min-height: 140px;
    }

    .stat-number,
    .hrm-payroll-stat-value {
        font-size: 28px;
    }
}

/* Tablet portrait */
@media (max-width: 768px) {

    .hrm-stats-row,
    .hrm-payroll-stats-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .hrm-stat-card,
    .hrm-payroll-stat-card-enhanced {
        padding: 16px;
        min-height: 120px;
    }

    .stat-number,
    .hrm-payroll-stat-value {
        font-size: 24px;
    }

    .stat-header .label,
    .hrm-payroll-stat-label {
        font-size: 10px;
    }
}

/* Mobile - single column */
@media (max-width: 480px) {

    .hrm-stats-row,
    .hrm-payroll-stats-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

/* ============================================================================
   ENHANCED MODAL RESPONSIVENESS
   ============================================================================ */

/* Tablet modals */
@media (max-width: 1024px) {

    .hrm-modal-content,
    .hrm-premium-modal {
        max-width: 90%;
        margin: 20px;
    }
}

/* Mobile modals - full screen */
@media (max-width: 768px) {
    .hrm-modal {
        padding: 0;
        align-items: flex-end;
    }

    .hrm-modal-content,
    .hrm-premium-modal {
        max-width: 100%;
        max-height: 95vh;
        margin: 0;
        border-radius: 16px 16px 0 0;
        animation: slideUpModal 0.3s ease-out;
    }

    @keyframes slideUpModal {
        from {
            transform: translateY(100%);
        }

        to {
            transform: translateY(0);
        }
    }

    .hrm-modal-header-premium,
    .hrm-modal-body,
    .hrm-modal-footer-premium {
        padding: 20px !important;
    }

    /* Modal form grids */
    .hrm-modal .hrm-form-grid,
    .hrm-modal .hrm-form-grid-3 {
        grid-template-columns: 1fr !important;
    }
}

/* Small mobile - full screen modals */
@media (max-width: 480px) {

    .hrm-modal-content,
    .hrm-premium-modal {
        max-height: 100vh;
        border-radius: 0;
    }

    .hrm-modal-header-premium,
    .hrm-modal-body,
    .hrm-modal-footer-premium {
        padding: 16px !important;
    }
}

/* ============================================================================
   ENHANCED BUTTON RESPONSIVENESS
   ============================================================================ */

/* Touch-friendly buttons on mobile */
@media (max-width: 768px) {

    .hrm-btn,
    .hrm-btn-primary,
    .hrm-btn-outline,
    .hrm-btn-danger,
    .hrm-payroll-btn {
        min-height: 48px;
        padding: 12px 20px;
        font-size: 15px;
    }

    .btn-sm {
        min-height: 44px;
        padding: 10px 16px;
        font-size: 14px;
    }

    /* Button groups stack on mobile */
    .hrm-button-group,
    .hrm-header-right {
        width: 100%;
        gap: 10px;
    }

    .hrm-button-group .hrm-btn,
    .hrm-header-right .hrm-btn {
        flex: 1;
        min-width: 0;
    }
}

@media (max-width: 480px) {

    .hrm-button-group,
    .hrm-header-right {
        flex-direction: column;
    }

    .hrm-button-group .hrm-btn,
    .hrm-header-right .hrm-btn {
        width: 100%;
    }
}

/* ============================================================================
   ENHANCED PAYROLL MODULE RESPONSIVENESS
   ============================================================================ */

/* Payroll navigation tabs */
@media (max-width: 768px) {
    .hrm-payroll-module .hrm-nav-tabs {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .hrm-payroll-module .hrm-nav-tabs::-webkit-scrollbar {
        display: none;
    }

    .hrm-payroll-module .hrm-nav-link {
        padding: 10px 16px;
        font-size: 13px;
        white-space: nowrap;
    }
}

/* Payroll quick actions */
@media (max-width: 1024px) {
    .hrm-payroll-quick-actions {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
}

@media (max-width: 640px) {
    .hrm-payroll-quick-actions {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .hrm-payroll-action-card {
        padding: 20px;
    }

    .hrm-payroll-action-card::after {
        bottom: 20px;
        right: 20px;
        font-size: 18px;
    }
}

/* Payroll filter bar */
@media (max-width: 768px) {
    .hrm-payroll-module .hrm-filter-bar-enhanced {
        flex-direction: column;
        align-items: stretch;
        padding: 16px;
    }

    .hrm-payroll-module .hrm-filter-group {
        width: 100%;
        flex-direction: column;
    }

    .hrm-payroll-module .hrm-filter-bar-enhanced .hrm-input,
    .hrm-payroll-module .hrm-filter-bar-enhanced .hrm-select {
        width: 100%;
        min-width: auto;
    }
}

/* ============================================================================
   ENHANCED EMPLOYEE PORTAL RESPONSIVENESS
   ============================================================================ */

/* Portal layout for tablets */
@media (max-width: 1024px) {
    .hrm-portal-wrap {
        flex-direction: column;
        padding: 16px;
        gap: 20px;
    }

    .hrm-sidebar {
        width: 100%;
        position: static;
        height: auto;
        border-radius: 16px;
        padding: 20px;
    }

    .hrm-nav-scroll {
        overflow-y: visible;
    }

    .hrm-nav-menu {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }

    .hrm-tab-btn {
        flex: 1;
        min-width: calc(50% - 4px);
    }
}

/* Portal for mobile */
@media (max-width: 768px) {
    .hrm-portal-wrap {
        padding: 12px;
        gap: 16px;
    }

    .hrm-sidebar {
        padding: 16px;
    }

    .hrm-sidebar-header {
        margin-bottom: 20px;
        padding-bottom: 16px;
    }

    .hrm-nav-section {
        margin-bottom: 16px;
    }

    .hrm-tab-btn {
        padding: 12px 14px;
        font-size: 13px;
    }

    /* Portal stats */
    .hrm-stats-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .hrm-mini-stat {
        padding: 20px;
        min-height: 100px;
    }

    /* Attendance timer */
    .hrm-timer-wrapper {
        width: 220px;
        height: 220px;
        margin-bottom: 30px;
    }

    .hrm-timer-bg {
        font-size: 42px;
    }

    .hrm-attendance-hero {
        padding: 32px 20px;
    }

    .hrm-history-section {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .hrm-nav-menu {
        flex-direction: column;
    }

    .hrm-tab-btn {
        width: 100%;
        min-width: auto;
    }

    .hrm-timer-wrapper {
        width: 200px;
        height: 200px;
    }

    .hrm-timer-bg {
        font-size: 36px;
    }

    .hrm-btn-checkin,
    .hrm-btn-red {
        width: 100%;
        min-width: auto;
    }
}

/* ============================================================================
   ENHANCED FILTER BAR RESPONSIVENESS
   ============================================================================ */

@media (max-width: 768px) {

    .hrm-filter-bar,
    .hrm-filter-bar-enhanced {
        padding: 16px;
        gap: 12px;
    }

    .hrm-filter-group {
        width: 100%;
    }

    .hrm-search-input {
        width: 100%;
        min-width: auto;
    }

    .hrm-filter-group .hrm-btn {
        width: 100%;
    }
}

/* ============================================================================
   ENHANCED CARD RESPONSIVENESS
   ============================================================================ */

@media (max-width: 768px) {

    .hrm-card,
    .hrm-card-enhanced {
        padding: 16px;
        border-radius: 12px;
        margin-bottom: 16px;
    }

    .card-header,
    .hrm-card-header-enhanced {
        padding: 16px;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .hrm-card-body-enhanced {
        padding: 16px;
    }
}

/* ============================================================================
   ENHANCED TYPOGRAPHY RESPONSIVENESS
   ============================================================================ */

@media (max-width: 768px) {
    .hrm-header-left h1 {
        font-size: 22px;
    }

    .hrm-header-left p {
        font-size: 13px;
    }

    .card-header h3,
    .hrm-card-header-enhanced h3 {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .hrm-header-left h1 {
        font-size: 20px;
    }

    .hrm-header-left p {
        font-size: 12px;
    }
}

/* ============================================================================
   ENHANCED SPACING & LAYOUT RESPONSIVENESS
   ============================================================================ */

@media (max-width: 768px) {
    .hrm-header-section {
        padding: 16px;
        margin-bottom: 16px;
        border-radius: 12px;
    }

    .hrm-content-area {
        padding: 0;
    }

    /* Reduce gaps and spacing */
    .hrm-payroll-dashboard-enhanced,
    .hrm-main-content {
        gap: 20px;
    }
}

@media (max-width: 480px) {
    .hrm-header-section {
        padding: 12px;
        gap: 12px;
    }
}

/* ============================================================================
   ENHANCED ICON RESPONSIVENESS
   ============================================================================ */

@media (max-width: 768px) {

    .hrm-payroll-stat-icon,
    .hrm-payroll-action-icon {
        width: 48px;
        height: 48px;
    }

    .hrm-payroll-stat-icon .dashicons,
    .hrm-payroll-action-icon .dashicons {
        font-size: 22px;
        width: 22px;
        height: 22px;
    }
}

/* ============================================================================
   LANDSCAPE ORIENTATION OPTIMIZATIONS
   ============================================================================ */

@media (max-width: 896px) and (orientation: landscape) {

    .hrm-modal-content,
    .hrm-premium-modal {
        max-height: 90vh;
        overflow-y: auto;
    }

    .hrm-sidebar {
        height: auto;
        position: static;
    }

    .hrm-attendance-hero {
        padding: 24px;
    }

    .hrm-timer-wrapper {
        width: 180px;
        height: 180px;
        margin-bottom: 20px;
    }
}

/* ============================================================================
   PRINT OPTIMIZATIONS
   ============================================================================ */

@media print {

    .hrm-sidebar,
    .hrm-top-bar,
    .hrm-header-section,
    .hrm-filter-bar,
    .hrm-filter-bar-enhanced,
    .hrm-nav-tabs,
    .hrm-btn,
    button,
    .no-print {
        display: none !important;
    }

    .hrm-portal-wrap,
    .hrm-wrap {
        padding: 0;
        max-width: 100%;
    }

    .hrm-table-wrapper {
        border: 1px solid #ddd;
        overflow: visible;
    }

    .hrm-table {
        min-width: auto;
    }

    .hrm-card,
    .hrm-modal-content {
        box-shadow: none;
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }
}

/* ============================================================================
   ACCESSIBILITY - FOCUS STATES
   ============================================================================ */

@media (max-width: 768px) {

    /* Larger focus indicators for touch devices */
    .hrm-btn:focus-visible,
    .hrm-input:focus-visible,
    .hrm-select:focus-visible {
        outline: 3px solid var(--hrm-primary, #0C8776);
        outline-offset: 3px;
    }
}

/* ============================================================================
   PERFORMANCE OPTIMIZATIONS
   ============================================================================ */

/* Reduce animations on low-end devices */
@media (max-width: 768px) {
    * {
        animation-duration: 0.2s !important;
        transition-duration: 0.2s !important;
    }
}

/* ============================================================================
   SAFE AREA INSETS FOR NOTCHED DEVICES
   ============================================================================ */

@supports (padding: max(0px)) {

    .hrm-portal-wrap,
    .hrm-wrap {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }

    .hrm-modal {
        padding-bottom: max(0px, env(safe-area-inset-bottom));
    }
}