/**
 * HRM / Essentials module — table layout fixes (column overlap, scroll, alignment)
 */

/* HRM sub-nav should not squeeze the content area */
#scrollable-container section.content > .no-print nav.navbar {
    margin-left: 0 !important;
    margin-right: 0 !important;
    border-radius: 12px;
}

#scrollable-container #leave_type_table,
#scrollable-container #holidays_table,
#scrollable-container #leave_type_table {
    width: 100% !important;
    table-layout: fixed !important;
    border-collapse: collapse !important;
}

/* bard-tables.css treats col 1 as checkbox — reset for HRM tables */
#scrollable-container table.hrm-data-table.dataTable thead > tr > th:first-child,
#scrollable-container table.hrm-data-table.dataTable tbody > tr > td:first-child,
#scrollable-container #payrolls_table thead > tr > th:first-child,
#scrollable-container #payrolls_table tbody > tr > td:first-child,
#scrollable-container #payroll_group_table thead > tr > th:first-child,
#scrollable-container #payroll_group_table tbody > tr > td:first-child,
#scrollable-container #ad_pc_table thead > tr > th:first-child,
#scrollable-container #ad_pc_table tbody > tr > td:first-child,
#scrollable-container #leave_table thead > tr > th:first-child,
#scrollable-container #leave_table tbody > tr > td:first-child,
#scrollable-container #attendance_table thead > tr > th:first-child,
#scrollable-container #attendance_table tbody > tr > td:first-child,
#scrollable-container #shift_table thead > tr > th:first-child,
#scrollable-container #shift_table tbody > tr > td:first-child,
#scrollable-container #holidays_table thead > tr > th:first-child,
#scrollable-container #holidays_table tbody > tr > td:first-child,
#scrollable-container #leave_type_table thead > tr > th:first-child,
#scrollable-container #leave_type_table tbody > tr > td:first-child,
#scrollable-container #sales_targets_table thead > tr > th:first-child,
#scrollable-container #sales_targets_table tbody > tr > td:first-child,
#scrollable-container .dataTables_scrollHead table.hrm-data-table thead > tr > th:first-child,
#scrollable-container .dataTables_scrollBody table.hrm-data-table tbody > tr > td:first-child,
#scrollable-container .dataTables_scrollHead #leave_type_table thead > tr > th:first-child,
#scrollable-container .dataTables_scrollBody #leave_type_table tbody > tr > td:first-child,
#scrollable-container .dataTables_scrollHead #holidays_table thead > tr > th:first-child,
#scrollable-container .dataTables_scrollBody #holidays_table tbody > tr > td:first-child {
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    text-align: left !important;
    padding-left: 0.85rem !important;
    padding-right: 0.85rem !important;
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
}

/* Leave type — 3 columns */
#scrollable-container #leave_type_table colgroup col:nth-child(1) {
    width: 55% !important;
}

#scrollable-container #leave_type_table colgroup col:nth-child(2) {
    width: 25% !important;
}

#scrollable-container #leave_type_table colgroup col:nth-child(3) {
    width: 20% !important;
}

#scrollable-container #leave_type_table thead th:nth-child(1),
#scrollable-container #leave_type_table tbody td:nth-child(1) {
    width: 55% !important;
    min-width: 14rem;
}

#scrollable-container #leave_type_table thead th:nth-child(2),
#scrollable-container #leave_type_table tbody td:nth-child(2) {
    width: 25% !important;
    min-width: 9rem;
    text-align: center !important;
    white-space: nowrap !important;
}

#scrollable-container #leave_type_table thead th:nth-child(3),
#scrollable-container #leave_type_table tbody td:nth-child(3) {
    width: 20% !important;
    min-width: 6.5rem;
    text-align: center !important;
    white-space: nowrap !important;
}

#scrollable-container #leave_type_table thead th:nth-child(1) {
    white-space: nowrap !important;
}

#scrollable-container #leave_type_table tbody td:nth-child(1) {
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: anywhere;
}

/* Holidays */
#scrollable-container #holidays_table thead th:nth-child(1),
#scrollable-container #holidays_table tbody td:nth-child(1) {
    width: 28% !important;
    min-width: 10rem;
}

#scrollable-container #holidays_table thead th:nth-child(2),
#scrollable-container #holidays_table tbody td:nth-child(2) {
    width: 22% !important;
    min-width: 9rem;
    white-space: nowrap !important;
}

#scrollable-container #holidays_table thead th:nth-child(3),
#scrollable-container #holidays_table tbody td:nth-child(3) {
    width: 22% !important;
    min-width: 8rem;
}

#scrollable-container #holidays_table thead th:nth-child(4),
#scrollable-container #holidays_table tbody td:nth-child(4) {
    width: 18% !important;
}

#scrollable-container #holidays_table thead th:nth-child(5),
#scrollable-container #holidays_table tbody td:nth-child(5) {
    width: 10% !important;
    min-width: 6.5rem;
    text-align: center !important;
    white-space: nowrap !important;
}

/* Known HRM DataTables (wide tables use auto layout + optional scroll) */
#scrollable-container #payrolls_table,
#scrollable-container #payroll_group_table,
#scrollable-container #ad_pc_table,
#scrollable-container #leave_table,
#scrollable-container #attendance_table,
#scrollable-container #shift_table,
#scrollable-container #sales_targets_table {
    width: 100% !important;
    table-layout: auto !important;
    border-collapse: collapse !important;
}

#scrollable-container #holidays_table {
    width: 100% !important;
    table-layout: fixed !important;
    border-collapse: collapse !important;
}

#scrollable-container #payrolls_table_wrapper,
#scrollable-container #payroll_group_table_wrapper,
#scrollable-container #ad_pc_table_wrapper,
#scrollable-container #leave_table_wrapper,
#scrollable-container #attendance_table_wrapper,
#scrollable-container #shift_table_wrapper,
#scrollable-container #holidays_table_wrapper,
#scrollable-container #leave_type_table_wrapper,
#scrollable-container #sales_targets_table_wrapper {
    width: 100% !important;
    max-width: 100% !important;
    overflow: visible;
}

#scrollable-container #payrolls_table_wrapper .dataTables_scroll,
#scrollable-container #payroll_group_table_wrapper .dataTables_scroll,
#scrollable-container #ad_pc_table_wrapper .dataTables_scroll,
#scrollable-container #leave_table_wrapper .dataTables_scroll,
#scrollable-container #attendance_table_wrapper .dataTables_scroll,
#scrollable-container #shift_table_wrapper .dataTables_scroll,
#scrollable-container #holidays_table_wrapper .dataTables_scroll,
#scrollable-container #leave_type_table_wrapper .dataTables_scroll,
#scrollable-container #sales_targets_table_wrapper .dataTables_scroll {
    width: 100% !important;
    clear: both;
}

#scrollable-container #payrolls_table_wrapper .dataTables_scrollHead,
#scrollable-container #payroll_group_table_wrapper .dataTables_scrollHead,
#scrollable-container #ad_pc_table_wrapper .dataTables_scrollHead,
#scrollable-container #leave_table_wrapper .dataTables_scrollHead,
#scrollable-container #attendance_table_wrapper .dataTables_scrollHead,
#scrollable-container #shift_table_wrapper .dataTables_scrollHead,
#scrollable-container #holidays_table_wrapper .dataTables_scrollHead,
#scrollable-container #leave_type_table_wrapper .dataTables_scrollHead,
#scrollable-container #sales_targets_table_wrapper .dataTables_scrollHead {
    overflow: hidden !important;
}

#scrollable-container #payrolls_table_wrapper .dataTables_scrollBody,
#scrollable-container #payroll_group_table_wrapper .dataTables_scrollBody,
#scrollable-container #ad_pc_table_wrapper .dataTables_scrollBody,
#scrollable-container #leave_table_wrapper .dataTables_scrollBody,
#scrollable-container #attendance_table_wrapper .dataTables_scrollBody,
#scrollable-container #shift_table_wrapper .dataTables_scrollBody,
#scrollable-container #holidays_table_wrapper .dataTables_scrollBody,
#scrollable-container #leave_type_table_wrapper .dataTables_scrollBody,
#scrollable-container #sales_targets_table_wrapper .dataTables_scrollBody {
    overflow-x: auto !important;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch;
}

#scrollable-container #payrolls_table thead th,
#scrollable-container #payroll_group_table thead th,
#scrollable-container #ad_pc_table thead th,
#scrollable-container #leave_table thead th,
#scrollable-container #attendance_table thead th,
#scrollable-container #shift_table thead th,
#scrollable-container #holidays_table thead th,
#scrollable-container #leave_type_table thead th,
#scrollable-container #sales_targets_table thead th,
#scrollable-container #payrolls_table tbody td,
#scrollable-container #payroll_group_table tbody td,
#scrollable-container #ad_pc_table tbody td,
#scrollable-container #leave_table tbody td,
#scrollable-container #attendance_table tbody td,
#scrollable-container #shift_table tbody td,
#scrollable-container #holidays_table tbody td,
#scrollable-container #leave_type_table tbody td,
#scrollable-container #sales_targets_table tbody td,
#scrollable-container .dataTables_scrollHead #payrolls_table thead th,
#scrollable-container .dataTables_scrollHead #payroll_group_table thead th,
#scrollable-container .dataTables_scrollHead #ad_pc_table thead th,
#scrollable-container .dataTables_scrollHead #leave_table thead th,
#scrollable-container .dataTables_scrollHead #attendance_table thead th,
#scrollable-container .dataTables_scrollHead #shift_table thead th,
#scrollable-container .dataTables_scrollHead #holidays_table thead th,
#scrollable-container .dataTables_scrollHead #leave_type_table thead th,
#scrollable-container .dataTables_scrollHead #sales_targets_table thead th,
#scrollable-container .dataTables_scrollBody #payrolls_table tbody td,
#scrollable-container .dataTables_scrollBody #payroll_group_table tbody td,
#scrollable-container .dataTables_scrollBody #ad_pc_table tbody td,
#scrollable-container .dataTables_scrollBody #leave_table tbody td,
#scrollable-container .dataTables_scrollBody #attendance_table tbody td,
#scrollable-container .dataTables_scrollBody #shift_table tbody td,
#scrollable-container .dataTables_scrollBody #holidays_table tbody td,
#scrollable-container .dataTables_scrollBody #leave_type_table tbody td,
#scrollable-container .dataTables_scrollBody #sales_targets_table tbody td {
    display: table-cell !important;
    position: static !important;
    vertical-align: middle !important;
    box-sizing: border-box !important;
    white-space: normal !important;
    word-break: normal;
    overflow-wrap: normal;
}

/* Action columns need room for buttons */
#scrollable-container #payrolls_table tbody td:last-child,
#scrollable-container #payroll_group_table tbody td:last-child,
#scrollable-container #ad_pc_table tbody td:last-child,
#scrollable-container #leave_table tbody td:last-child,
#scrollable-container #attendance_table tbody td:last-child,
#scrollable-container #shift_table tbody td:last-child,
#scrollable-container #holidays_table tbody td:last-child,
#scrollable-container #leave_type_table tbody td:last-child,
#scrollable-container .dataTables_scrollBody #payrolls_table tbody td:last-child,
#scrollable-container .dataTables_scrollBody #payroll_group_table tbody td:last-child,
#scrollable-container .dataTables_scrollBody #ad_pc_table tbody td:last-child,
#scrollable-container .dataTables_scrollBody #leave_table tbody td:last-child,
#scrollable-container .dataTables_scrollBody #attendance_table tbody td:last-child,
#scrollable-container .dataTables_scrollBody #shift_table tbody td:last-child,
#scrollable-container .dataTables_scrollBody #holidays_table tbody td:last-child,
#scrollable-container .dataTables_scrollBody #leave_type_table tbody td:last-child {
    min-width: 8.5rem;
    width: auto !important;
    max-width: none !important;
    white-space: nowrap !important;
    word-break: normal;
}

#scrollable-container #payrolls_table thead th:last-child,
#scrollable-container #payroll_group_table thead th:last-child,
#scrollable-container #ad_pc_table thead th:last-child,
#scrollable-container #leave_table thead th:last-child,
#scrollable-container #attendance_table thead th:last-child,
#scrollable-container #shift_table thead th:last-child,
#scrollable-container #holidays_table thead th:last-child,
#scrollable-container #leave_type_table thead th:last-child,
#scrollable-container .dataTables_scrollHead #payrolls_table thead th:last-child,
#scrollable-container .dataTables_scrollHead #payroll_group_table thead th:last-child,
#scrollable-container .dataTables_scrollHead #ad_pc_table thead th:last-child,
#scrollable-container .dataTables_scrollHead #leave_table thead th:last-child,
#scrollable-container .dataTables_scrollHead #attendance_table thead th:last-child,
#scrollable-container .dataTables_scrollHead #shift_table thead th:last-child,
#scrollable-container .dataTables_scrollHead #holidays_table thead th:last-child,
#scrollable-container .dataTables_scrollHead #leave_type_table thead th:last-child {
    min-width: 8.5rem;
    white-space: nowrap !important;
}

/* Tab panels — horizontal scroll wrapper */
#scrollable-container .nav-tabs-custom .tab-pane .table-responsive {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Leave summary widget (static HTML table) */
#scrollable-container #user_leave_summary .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

#scrollable-container #user_leave_summary table.table {
    width: 100% !important;
    min-width: 640px;
    table-layout: auto !important;
    border-collapse: collapse !important;
}

#scrollable-container #user_leave_summary table.table th,
#scrollable-container #user_leave_summary table.table td {
    display: table-cell !important;
    vertical-align: middle !important;
    padding: 0.55rem 0.75rem !important;
    white-space: normal !important;
    word-break: break-word;
}

#scrollable-container #user_leave_summary table.table thead th {
    white-space: nowrap !important;
    text-align: center;
}

#scrollable-container #user_leave_summary table.table tbody th {
    white-space: nowrap !important;
    font-weight: 600;
    background: #f8fafc;
}

#scrollable-container #user_leave_summary table.table tbody td {
    text-align: center;
}

/* HRM dashboard static tables */
#scrollable-container .row-custom .table.no-margin,
#scrollable-container .row-custom .table {
    width: 100% !important;
    table-layout: auto !important;
}

#scrollable-container .row-custom .table.no-margin th,
#scrollable-container .row-custom .table.no-margin td,
#scrollable-container .row-custom .table th,
#scrollable-container .row-custom .table td {
    display: table-cell !important;
    vertical-align: top !important;
    padding: 0.5rem 0.65rem !important;
    white-space: normal !important;
}

/* HRM dashboard role sections */
#scrollable-container .hrm-dashboard-section-header {
    margin: 0.25rem 0 0.5rem;
    padding-bottom: 0.35rem;
    border-bottom: 2px solid #e8ecf1;
}

#scrollable-container .hrm-dashboard-section-header h4 {
    margin: 0;
    font-weight: 600;
    letter-spacing: 0.02em;
}

#scrollable-container .hrm-dashboard-section-header h4 i {
    margin-right: 0.4rem;
    color: #3c8dbc;
}

#scrollable-container #pending_leaves_table .btn-xs {
    margin-bottom: 2px;
}

@media (max-width: 767px) {
    #scrollable-container #payrolls_table_wrapper .dataTables_scrollBody,
    #scrollable-container #leave_table_wrapper .dataTables_scrollBody,
    #scrollable-container #attendance_table_wrapper .dataTables_scrollBody {
        max-width: 100%;
    }
}
