/* ==========================================================================
   RKD Manpower Custom Theme & Dark Mode Optimization
   ========================================================================== */

/* Light Mode Polish */
:root {
    --rkd-primary: #6b0818;
    --rkd-gold: #daa520;
}

/* ==========================================================================
   DARK MODE ENHANCEMENTS & CONTRAST FIXES
   ========================================================================== */
[data-bs-theme="dark"] {
    --bs-body-bg: #141820;
    --bs-body-color: #e2e8f0;
}

/* 1. Table Headers & Tables Text Wrapping */
.table,
table.dataTable {
    width: 100% !important;
}

.table th,
.table td,
table.dataTable th,
table.dataTable td {
    white-space: normal !important;
    word-wrap: break-word !important;
    word-break: normal !important;
    vertical-align: middle !important;
}

/* Ensure action column and action button groups stay clean and together */
.table th:last-child,
.table td:last-child,
.table td.text-center,
.table .btn-group {
    white-space: nowrap !important;
}

[data-bs-theme="dark"] .table {
    color: #e2e8f0 !important;
    border-color: #2e3846 !important;
}

[data-bs-theme="dark"] .table thead th,
[data-bs-theme="dark"] .table-light,
[data-bs-theme="dark"] .table-light th,
[data-bs-theme="dark"] .table-light td {
    background-color: #222b36 !important;
    color: #ffffff !important;
    border-color: #334155 !important;
    font-weight: 700 !important;
    letter-spacing: 0.3px;
}

[data-bs-theme="dark"] .table > :not(caption) > * > * {
    background-color: transparent;
    border-bottom-color: #2a3441;
}

[data-bs-theme="dark"] .table-hover > tbody > tr:hover > * {
    background-color: #232c38 !important;
    color: #ffffff !important;
}

/* 2. Text Overrides in Dark Mode */
[data-bs-theme="dark"] .text-dark {
    color: #f8fafc !important;
}

[data-bs-theme="dark"] .text-muted {
    color: #94a3b8 !important;
}

[data-bs-theme="dark"] .text-secondary {
    color: #cbd5e1 !important;
}

/* 3. DataTables Controls (Search, Pagination, Length) */
[data-bs-theme="dark"] .dataTables_wrapper .dataTables_length label,
[data-bs-theme="dark"] .dataTables_wrapper .dataTables_filter label,
[data-bs-theme="dark"] .dataTables_wrapper .dataTables_info {
    color: #cbd5e1 !important;
}

[data-bs-theme="dark"] .dataTables_wrapper .dataTables_filter input,
[data-bs-theme="dark"] .dataTables_wrapper .dataTables_length select {
    background-color: #1e2631 !important;
    border: 1px solid #3b4858 !important;
    color: #f8fafc !important;
    border-radius: 6px;
    padding: 4px 10px;
}

[data-bs-theme="dark"] .dataTables_wrapper .dataTables_filter input:focus,
[data-bs-theme="dark"] .dataTables_wrapper .dataTables_length select:focus {
    border-color: #60a5fa !important;
    box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.25) !important;
    outline: none;
}

[data-bs-theme="dark"] .page-link {
    background-color: #1e2631 !important;
    border-color: #334155 !important;
    color: #cbd5e1 !important;
}

[data-bs-theme="dark"] .page-item.active .page-link {
    background-color: #3b82f6 !important;
    border-color: #3b82f6 !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .page-item.disabled .page-link {
    background-color: #141820 !important;
    border-color: #2a3441 !important;
    color: #64748b !important;
}

/* 4. Action Buttons & Button Groups in Dark Mode */
[data-bs-theme="dark"] .btn-outline-dark {
    color: #f8fafc !important;
    border-color: #64748b !important;
}

[data-bs-theme="dark"] .btn-outline-dark:hover {
    background-color: #334155 !important;
    border-color: #94a3b8 !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .btn-outline-info {
    color: #38bdf8 !important;
    border-color: #0284c7 !important;
}

[data-bs-theme="dark"] .btn-outline-info:hover {
    background-color: #0284c7 !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .btn-outline-primary {
    color: #60a5fa !important;
    border-color: #2563eb !important;
}

[data-bs-theme="dark"] .btn-outline-primary:hover {
    background-color: #2563eb !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .btn-outline-success {
    color: #34d399 !important;
    border-color: #059669 !important;
}

[data-bs-theme="dark"] .btn-outline-success:hover {
    background-color: #059669 !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .btn-outline-danger {
    color: #f87171 !important;
    border-color: #dc2626 !important;
}

[data-bs-theme="dark"] .btn-outline-danger:hover {
    background-color: #dc2626 !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .btn-group .btn {
    border-width: 1px;
}

/* 5. Modals & Forms in Dark Mode */
[data-bs-theme="dark"] .modal-content {
    background-color: #1a202a !important;
    border: 1px solid #334155 !important;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5) !important;
}

[data-bs-theme="dark"] .modal-header.bg-primary,
[data-bs-theme="dark"] .modal-header.bg-dark,
[data-bs-theme="dark"] .modal-header.bg-danger,
[data-bs-theme="dark"] .modal-header.bg-success {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
}

[data-bs-theme="dark"] .modal-footer {
    background-color: #151a22 !important;
    border-top: 1px solid #2e3846 !important;
}

[data-bs-theme="dark"] .modal-body .bg-light {
    background-color: #202733 !important;
    border: 1px solid #2e3846 !important;
}

[data-bs-theme="dark"] .form-label {
    color: #e2e8f0 !important;
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: #141820 !important;
    border: 1px solid #3b4858 !important;
    color: #f8fafc !important;
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    background-color: #141820 !important;
    border-color: #60a5fa !important;
    color: #ffffff !important;
    box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.25) !important;
}

[data-bs-theme="dark"] .form-control::placeholder {
    color: #64748b !important;
}

[data-bs-theme="dark"] .form-control[readonly] {
    background-color: #1e2631 !important;
    color: #93c5fd !important;
}

[data-bs-theme="dark"] .input-group-text {
    background-color: #222b36 !important;
    border-color: #3b4858 !important;
    color: #cbd5e1 !important;
}

/* 6. Badges & Cards */
[data-bs-theme="dark"] .badge.bg-light {
    background-color: #334155 !important;
    color: #f8fafc !important;
    border-color: #475569 !important;
}

[data-bs-theme="dark"] .card {
    background-color: #1a202a !important;
    border: 1px solid #2e3846 !important;
}

/* 8. DataTables Export Buttons */
.dt-buttons .btn {
    font-size: 12px;
    padding: 5px 12px;
    border-radius: 6px;
    font-weight: 600;
}
.dt-buttons .btn-success {
    background-color: #059669 !important;
    border-color: #047857 !important;
    color: #ffffff !important;
}
.dt-buttons .btn-success:hover {
    background-color: #047857 !important;
}
[data-bs-theme="dark"] .dt-buttons .btn-success {
    background-color: #10b981 !important;
    border-color: #059669 !important;
    color: #0f172a !important;
    font-weight: 700;
}
[data-bs-theme="dark"] .dt-buttons .btn-success:hover {
    background-color: #34d399 !important;
}

/* 9. Modal Scrollable Fix (Forms & Large Modals) */
.modal-dialog-scrollable {
    max-height: calc(100% - 3.5rem);
}
.modal-dialog-scrollable .modal-content {
    max-height: calc(100vh - 3.5rem) !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.modal-dialog-scrollable form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    overflow: hidden;
    min-height: 0;
}
.modal-dialog-scrollable .modal-body {
    overflow-y: auto !important;
    max-height: calc(100vh - 200px) !important;
    flex: 1 1 auto;
    -webkit-overflow-scrolling: touch;
}
.modal-dialog-scrollable .modal-header,
.modal-dialog-scrollable .modal-footer {
    flex-shrink: 0;
}

/* Sleek Scrollbar for Modal Body */
.modal-body::-webkit-scrollbar {
    width: 6px;
}
.modal-body::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}
.modal-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
.modal-body::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
[data-bs-theme="dark"] .modal-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}
[data-bs-theme="dark"] .modal-body::-webkit-scrollbar-thumb {
    background: #475569;
}
[data-bs-theme="dark"] .modal-body::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* 10. Interactive Button Tooltips */
.btn > i,
.btn-group .btn > i,
a.btn > i {
    pointer-events: none;
}

.tooltip {
    z-index: 99999 !important;
    pointer-events: none !important;
}
.tooltip-inner {
    background-color: #0f172a !important;
    color: #ffffff !important;
    padding: 6px 12px !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    border-radius: 6px !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25) !important;
}
.tooltip.bs-tooltip-top .tooltip-arrow::before {
    border-top-color: #0f172a !important;
}
.tooltip.bs-tooltip-bottom .tooltip-arrow::before {
    border-bottom-color: #0f172a !important;
}
.tooltip.bs-tooltip-start .tooltip-arrow::before {
    border-left-color: #0f172a !important;
}
.tooltip.bs-tooltip-end .tooltip-arrow::before {
    border-right-color: #0f172a !important;
}
