/*
|--------------------------------------------------------------------------
| NOUS ERP – Dark/Light mode hardening
|--------------------------------------------------------------------------
| The dashboard template relies on CSS variables (set via html[data-theme]).
| Some third‑party libs (Bootstrap Table/DataTables/FileInput) ship with
| light-only defaults. This file normalizes common UI controls so dark mode
| is applied consistently across tables, inputs, selects, modals, dropdowns.
|
| IMPORTANT: This file must be loaded AFTER style.css
*/

/* -----------------------------
    Bootstrap CSS variables
------------------------------*/
html[data-theme="dark"] {
    /* Let the browser render native controls (select/file/date) in dark UI when possible */
    color-scheme: dark;

    --bs-body-bg: var(--bg-color);
    --bs-body-color: var(--text-primary-light);
    --bs-emphasis-color: var(--text-primary-light);
    --bs-secondary-color: var(--text-secondary-light);
    --bs-tertiary-color: var(--text-secondary-light);
    --bs-border-color: var(--neutral-300);
    --bs-border-color-translucent: var(--border-color);
    --bs-link-color: var(--primary-400);
    --bs-link-hover-color: var(--primary-300);
    --bs-card-bg: var(--white);
    --bs-modal-bg: var(--white);
}

/* Some browsers ignore color-scheme on html, so enforce on native controls too */
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
    color-scheme: dark;
}

/* -----------------------------
    Forms (inputs / select / textarea)
------------------------------*/
html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] textarea {
    background-color: var(--white) !important;
    color: var(--text-primary-light) !important;
    border-color: var(--input-form-light) !important;
}

/* Native select dropdown options (fix invisible text in dark mode on Windows/Chrome) */
html[data-theme="dark"] select,
html[data-theme="dark"] .form-select {
    color: var(--text-primary-light) !important;
    background-color: var(--white) !important;
}

html[data-theme="dark"] select option,
html[data-theme="dark"] .form-select option,
html[data-theme="dark"] select optgroup,
html[data-theme="dark"] .form-select optgroup {
    background-color: var(--white) !important;
    color: var(--text-primary-light) !important;
}

html[data-theme="dark"] .form-control::placeholder,
html[data-theme="dark"] textarea::placeholder {
    color: var(--text-secondary-light) !important;
    opacity: 0.85;
}

html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .form-select:focus,
html[data-theme="dark"] textarea:focus {
    background-color: var(--white) !important;
    border-color: var(--primary-600) !important;
}

.dashboard-display-field {
    display: block;
    width: 100%;
    min-height: calc(1.5em + 0.75rem + 2px);
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: var(--bs-border-radius, 0.375rem);
    background-color: var(--bs-tertiary-bg, #f8f9fa);
    color: inherit;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

html[data-theme="dark"] .dashboard-display-field,
html[data-theme="dark"] .form-control:disabled,
html[data-theme="dark"] .form-control[readonly],
html[data-theme="dark"] .form-select:disabled,
html[data-theme="dark"] textarea.form-control:disabled,
html[data-theme="dark"] textarea.form-control[readonly] {
    background-color: var(--neutral-100) !important;
    color: var(--text-primary-light) !important;
    border-color: var(--input-form-light) !important;
    -webkit-text-fill-color: var(--text-primary-light) !important;
    opacity: 1;
}

html[data-theme="dark"] .form-control-plaintext {
    color: var(--text-primary-light) !important;
}

html[data-theme="dark"] .form-control-plaintext.bg-light,
html[data-theme="dark"] .form-control-plaintext.border,
html[data-theme="dark"] .form-control.bg-light,
html[data-theme="dark"] .form-select.bg-light,
html[data-theme="dark"] textarea.bg-light {
    background-color: var(--neutral-100) !important;
    color: var(--text-primary-light) !important;
    border-color: var(--input-form-light) !important;
}

html[data-theme="dark"] .input-group-text {
    background-color: var(--neutral-100) !important;
    color: var(--text-secondary-light) !important;
    border-color: var(--input-form-light) !important;
}

/* Native file input (fix white "Choose file" button area) */
html[data-theme="dark"] input[type="file"].form-control,
html[data-theme="dark"] input[type="file"].form-control:focus {
    background-color: var(--white) !important;
    color: var(--text-primary-light) !important;
    border-color: var(--input-form-light) !important;
}

/* Some pages use plain <input type="file"> without .form-control */
html[data-theme="dark"] input[type="file"] {
    background-color: var(--white) !important;
    color: var(--text-primary-light) !important;
    border-color: var(--input-form-light) !important;
}

html[data-theme="dark"] input[type="file"]::file-selector-button,
html[data-theme="dark"] input[type="file"]::-webkit-file-upload-button {
    background-color: var(--neutral-100) !important;
    color: var(--text-primary-light) !important;
    border-color: var(--input-form-light) !important;
}

html[data-theme="dark"] .form-control[type="file"]::file-selector-button {
    background-color: var(--neutral-100) !important;
    color: var(--text-primary-light) !important;
    border-color: var(--input-form-light) !important;
}

/* WebKit fallback */
html[data-theme="dark"] .form-control[type="file"]::-webkit-file-upload-button {
    background-color: var(--neutral-100) !important;
    color: var(--text-primary-light) !important;
    border-color: var(--input-form-light) !important;
}

/* file input plugin (krajee fileinput) */
html[data-theme="dark"] .file-caption,
html[data-theme="dark"] .file-caption-main {
    background-color: var(--white) !important;
}

html[data-theme="dark"] .file-caption-name,
html[data-theme="dark"] .file-caption-icon {
    color: var(--text-primary-light) !important;
}

/* -----------------------------
    Tables (Bootstrap + template + DataTables)
------------------------------*/
html[data-theme="dark"] .table {
    --bs-table-color: var(--text-secondary-light);
    --bs-table-bg: var(--white);
    --bs-table-border-color: var(--neutral-200);
    --bs-table-striped-bg: var(--neutral-100);
    --bs-table-striped-color: var(--text-secondary-light);
    --bs-table-hover-bg: var(--neutral-200);
    --bs-table-hover-color: var(--text-primary-light);
}

/* DataTables sometimes ships explicit white backgrounds; force dark variables */
html[data-theme="dark"] table.dataTable,
html[data-theme="dark"] table.dataTable.no-footer,
html[data-theme="dark"] table.dataTable thead th,
html[data-theme="dark"] table.dataTable thead td,
html[data-theme="dark"] table.dataTable tbody td,
html[data-theme="dark"] table.dataTable tbody th {
    background-color: var(--white) !important;
    color: var(--text-secondary-light) !important;
    border-color: var(--neutral-200) !important;
}

html[data-theme="dark"] table.dataTable thead th,
html[data-theme="dark"] table.dataTable thead td {
    background-color: var(--neutral-100) !important;
    color: var(--text-primary-light) !important;
}

html[data-theme="dark"] .dataTables_wrapper .dataTables_scrollBody,
html[data-theme="dark"] .dataTables_wrapper .dataTables_scroll {
    background-color: var(--white) !important;
}

html[data-theme="dark"] .table > :not(caption) > * > * {
    background-color: var(--bs-table-bg) !important;
    color: var(--bs-table-color) !important;
    border-color: var(--bs-table-border-color) !important;
}

html[data-theme="dark"] .table thead th,
html[data-theme="dark"] .table thead td {
    background-color: var(--neutral-100) !important;
    color: var(--text-primary-light) !important;
    border-color: var(--neutral-200) !important;
}

html[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: var(--neutral-100) !important;
}

html[data-theme="dark"] .table-hover > tbody > tr:hover > * {
    background-color: var(--neutral-200) !important;
    color: var(--text-primary-light) !important;
}

/* template custom tables (ensure cells inherit dark background) */
html[data-theme="dark"] .basic-table tbody td,
html[data-theme="dark"] .bordered-table tbody tr td,
html[data-theme="dark"] .basic-border-table tbody tr td,
html[data-theme="dark"] .striped-table tbody tr td,
html[data-theme="dark"] .vertical-striped-table tbody tr td {
    background-color: var(--white) !important;
    color: var(--text-secondary-light) !important;
    border-color: var(--neutral-200) !important;
}

html[data-theme="dark"] .basic-table thead th,
html[data-theme="dark"] .bordered-table thead tr th,
html[data-theme="dark"] .basic-border-table thead tr th,
html[data-theme="dark"] .striped-table thead tr th,
html[data-theme="dark"] .vertical-striped-table thead tr th {
    background-color: var(--neutral-100) !important;
    color: var(--text-primary-light) !important;
    border-color: var(--neutral-200) !important;
}

/* DataTables controls */
html[data-theme="dark"] .dataTables_wrapper .dataTables_length select,
html[data-theme="dark"] .dataTables_wrapper .dataTables_filter input {
    background-color: var(--white) !important;
    color: var(--text-primary-light) !important;
    border: 1px solid var(--input-form-light) !important;
}

html[data-theme="dark"] .dataTables_wrapper .dataTables_info,
html[data-theme="dark"] .dataTables_wrapper .dataTables_paginate {
    color: var(--text-secondary-light) !important;
}

html[data-theme="dark"]
    .dataTables_wrapper
    .dataTables_paginate
    .paginate_button {
    color: var(--text-secondary-light) !important;
    border-color: var(--neutral-200) !important;
}

html[data-theme="dark"]
    .dataTables_wrapper
    .dataTables_paginate
    .paginate_button.current,
html[data-theme="dark"]
    .dataTables_wrapper
    .dataTables_paginate
    .paginate_button.current:hover {
    background: var(--neutral-200) !important;
    color: var(--text-primary-light) !important;
    border-color: var(--neutral-200) !important;
}

html[data-theme="dark"]
    .dataTables_wrapper
    .dataTables_paginate
    .paginate_button:hover {
    background: var(--neutral-100) !important;
    color: var(--text-primary-light) !important;
    border-color: var(--neutral-200) !important;
}

/* -----------------------------
    Dropdowns / Modals
------------------------------*/
html[data-theme="dark"] .dropdown-menu {
    background-color: var(--white) !important;
    border-color: var(--neutral-200) !important;
}

html[data-theme="dark"] .dropdown-item {
    color: var(--text-secondary-light) !important;
}

html[data-theme="dark"] .dropdown-item:hover,
html[data-theme="dark"] .dropdown-item:focus {
    background-color: var(--neutral-100) !important;
    color: var(--text-primary-light) !important;
}

html[data-theme="dark"] .modal-content {
    background-color: var(--white) !important;
    color: var(--text-primary-light) !important;
    border-color: var(--neutral-200) !important;
}

html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-footer {
    border-color: var(--neutral-200) !important;
}

/* ================================
    SweetAlert2 fixes (WOW Dashboard)
   ================================ */

/* prevent global font-size/line-height overrides */
.swal2-container {
    font-family: inherit !important;
}

.swal2-popup {
    font-size: 0.95rem !important;
    line-height: 1.35 !important;
    border-radius: 14px !important;
    padding: 1.1rem 1.25rem !important;
    width: 32rem !important;
    max-width: calc(100% - 2rem) !important;
    box-sizing: border-box !important;
}

/* title + text sizes */
.swal2-title {
    font-size: 1.25rem !important;
    font-weight: 700 !important;
    margin: 0.4rem 0 0.2rem !important;
}

.swal2-html-container {
    font-size: 0.95rem !important;
    margin-top: 0.35rem !important;
}

/* buttons sizing */
.swal2-actions {
    gap: 0.5rem !important;
    margin-top: 1rem !important;
}

.swal2-styled {
    font-size: 0.9rem !important;
    padding: 0.55rem 1rem !important;
    border-radius: 10px !important;
    line-height: 1.1 !important;
}

/* icons not huge */
.swal2-icon {
    transform: scale(0.9);
    margin: 0.7rem auto 0.2rem !important;
}

/* Toast sizing */
.swal2-toast {
    padding: 0.65rem 0.8rem !important;
    border-radius: 12px !important;
}

.swal2-toast .swal2-title {
    font-size: 0.95rem !important;
    font-weight: 600 !important;
    margin: 0 !important;
}

.swal2-toast .swal2-html-container {
    font-size: 0.85rem !important;
    margin: 0.15rem 0 0 !important;
}

/* Dark mode support (based on body class) */
body.dark-mode .swal2-popup,
html.dark body .swal2-popup,
[data-theme="dark"] .swal2-popup {
    background: #111827 !important;
    color: #e5e7eb !important;
}

body.dark-mode .swal2-html-container,
html.dark body .swal2-html-container,
[data-theme="dark"] .swal2-html-container {
    color: #cbd5e1 !important;
}

/* =========================================================
    Roles > Create Role (Permissions Cards) - Theme Fix
    No Blade changes required
   ========================================================= */

/* Base card polish (light/dark safe) */
#basic-horizontal-layouts .card.h-100.shadow-sm {
    border-radius: 12px;
    overflow: hidden;
}

/* Header layout + remove hard light background */
#basic-horizontal-layouts .card.h-100.shadow-sm > .card-header.bg-light {
    background: transparent !important; /* kill bg-light */
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

/* Title inside header */
#basic-horizontal-layouts .card.h-100.shadow-sm > .card-header.bg-light h6 {
    font-weight: 600;
    font-size: 0.95rem;
}

/* Checkboxes spacing & alignment */
#basic-horizontal-layouts .card.h-100.shadow-sm .form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
#basic-horizontal-layouts .card.h-100.shadow-sm .form-check-label.small {
    line-height: 1.2;
    opacity: 0.95;
}

/* =========================
    DARK MODE (all variants)
   ========================= */
body.dark-mode #basic-horizontal-layouts .card.h-100.shadow-sm,
html[data-theme="dark"] #basic-horizontal-layouts .card.h-100.shadow-sm,
.theme-dark #basic-horizontal-layouts .card.h-100.shadow-sm {
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: none !important;
}

body.dark-mode
    #basic-horizontal-layouts
    .card.h-100.shadow-sm
    > .card-header.bg-light,
html[data-theme="dark"]
    #basic-horizontal-layouts
    .card.h-100.shadow-sm
    > .card-header.bg-light,
.theme-dark
    #basic-horizontal-layouts
    .card.h-100.shadow-sm
    > .card-header.bg-light {
    background: rgba(255, 255, 255, 0.06) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: rgba(255, 255, 255, 0.92) !important;
}

body.dark-mode #basic-horizontal-layouts .card.h-100.shadow-sm .card-body,
html[data-theme="dark"]
    #basic-horizontal-layouts
    .card.h-100.shadow-sm
    .card-body,
.theme-dark #basic-horizontal-layouts .card.h-100.shadow-sm .card-body {
    color: rgba(255, 255, 255, 0.88) !important;
}

/* Checkbox/label colors in dark */
body.dark-mode
    #basic-horizontal-layouts
    .card.h-100.shadow-sm
    .form-check-label,
html[data-theme="dark"]
    #basic-horizontal-layouts
    .card.h-100.shadow-sm
    .form-check-label,
.theme-dark #basic-horizontal-layouts .card.h-100.shadow-sm .form-check-label {
    color: rgba(255, 255, 255, 0.88) !important;
}

body.dark-mode
    #basic-horizontal-layouts
    .card.h-100.shadow-sm
    .form-check-input,
html[data-theme="dark"]
    #basic-horizontal-layouts
    .card.h-100.shadow-sm
    .form-check-input,
.theme-dark #basic-horizontal-layouts .card.h-100.shadow-sm .form-check-input {
    background-color: transparent !important;
    border-color: rgba(255, 255, 255, 0.35) !important;
}

body.dark-mode
    #basic-horizontal-layouts
    .card.h-100.shadow-sm
    .form-check-input:checked,
html[data-theme="dark"]
    #basic-horizontal-layouts
    .card.h-100.shadow-sm
    .form-check-input:checked,
.theme-dark
    #basic-horizontal-layouts
    .card.h-100.shadow-sm
    .form-check-input:checked {
    border-color: transparent !important;
}

/* Hover for better UX in dark */
body.dark-mode #basic-horizontal-layouts .card.h-100.shadow-sm:hover,
html[data-theme="dark"] #basic-horizontal-layouts .card.h-100.shadow-sm:hover,
.theme-dark #basic-horizontal-layouts .card.h-100.shadow-sm:hover {
    border-color: rgba(255, 255, 255, 0.18) !important;
    background: rgba(255, 255, 255, 0.05) !important;
}

/* =========================
    LIGHT MODE refinement
   ========================= */
body:not(.dark-mode)
    #basic-horizontal-layouts
    .card.h-100.shadow-sm
    > .card-header.bg-light {
    background: rgba(0, 0, 0, 0.03) !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

body:not(.dark-mode) #basic-horizontal-layouts .card.h-100.shadow-sm {
    border: 1px solid rgba(0, 0, 0, 0.06);
}

/* Keep small body padding clean */
#basic-horizontal-layouts .card.h-100.shadow-sm .card-body.py-2 {
    padding-top: 10px !important;
    padding-bottom: 10px !important;
}

/* ==========================================
    Real Estate leases > units multiselect
   ========================================== */
.lease-unit-select[multiple] {
    min-height: 11.5rem !important;
    max-height: 18rem;
    height: auto !important;
    overflow-y: auto;
    padding: 0.75rem 0.9375rem !important;
    background-image: none !important;
    line-height: 1.45;
}

.lease-unit-select[multiple] option {
    padding: 0.45rem 0.75rem;
    border-radius: 8px;
}

[dir="rtl"] .lease-unit-select[multiple] {
    text-align: right;
}

html[data-theme="dark"] .lease-unit-select[multiple] option:checked,
html[data-theme="dark"] .lease-unit-select[multiple] option:hover {
    background: var(--primary-600) linear-gradient(0deg, var(--primary-600), var(--primary-600)) !important;
    color: #fff !important;
}

/* ==========================================
    Global pagination hardening
   ========================================== */
.pagination {
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 0;
}

.pagination .page-item {
    display: inline-flex;
}

.pagination .page-item:not(:first-child) .page-link {
    margin-left: 0;
}

.pagination .page-link {
    min-width: 2.6rem;
    min-height: 2.6rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.85rem;
    border-radius: 10px !important;
    border: 1px solid var(--input-form-light) !important;
    background-color: var(--white);
    color: var(--text-primary-light) !important;
    box-shadow: none !important;
    transition: all 0.2s ease;
}

.pagination .page-link:hover,
.pagination .page-link:focus {
    background-color: #ffffff;
    border-color: var(--primary-main) !important;
    color: var(--primary-main) !important;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.08) !important;
}

.pagination .page-item.active .page-link {
    background-color: var(--primary-main) !important;
    border-color: var(--primary-main) !important;
    color: #ffffff !important;
}

.pagination .page-item.disabled .page-link {
    background-color: #f8fafc;
    color: #94a3b8 !important;
    border-color: #e2e8f0 !important;
    opacity: 1;
}

[dir="rtl"] .pagination {
    direction: rtl;
}

html[data-theme="dark"] .pagination .page-link {
    background-color: var(--white) !important;
    border-color: var(--neutral-200) !important;
    color: var(--text-primary-light) !important;
}

html[data-theme="dark"] .pagination .page-link:hover,
html[data-theme="dark"] .pagination .page-link:focus {
    background-color: var(--neutral-100) !important;
    border-color: var(--primary-400) !important;
    color: var(--text-primary-light) !important;
}

html[data-theme="dark"] .pagination .page-item.active .page-link {
    background-color: var(--primary-600) !important;
    border-color: var(--primary-600) !important;
    color: #ffffff !important;
}

html[data-theme="dark"] .pagination .page-item.disabled .page-link {
    background-color: var(--neutral-100) !important;
    border-color: var(--neutral-200) !important;
    color: var(--text-secondary-light) !important;
}

nav .small.text-muted {
    margin-bottom: 0;
}
/* =========================================================
     Global Status Toggle (Success/Grey Logic)
   ========================================================= */
.status-toggle {
    background-color: #adb5bd !important; /* Grey / Inactive */
    border-color: #adb5bd !important;
    cursor: pointer;
    width: 40px !important;
    height: 20px !important;
}

.status-toggle:checked {
    background-color: #198754 !important; /* Success / Active */
    border-color: #198754 !important;
}

/* ==========================================
    Dashboard footer
   ========================================== */
.dashboard-footer {
    border-top: 1px solid rgba(148, 163, 184, 0.18);
}

.dashboard-footer__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.dashboard-footer__brand,
.dashboard-footer__meta {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.dashboard-footer__meta {
    margin-inline-start: auto;
    text-align: end;
}

.dashboard-footer__system {
    color: #0f172a;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.2;
}

.dashboard-footer__copy,
.dashboard-footer__credit {
    color: #64748b;
    font-size: 0.88rem;
    line-height: 1.55;
}

.dashboard-footer__symbol {
    display: inline-block;
    margin-inline-end: 0.25rem;
}

.dashboard-footer__credit a {
    color: var(--primary-main);
    font-weight: 600;
    text-decoration: none;
}

.dashboard-footer__credit a:hover,
.dashboard-footer__credit a:focus {
    text-decoration: underline;
}

html[data-theme="dark"] .dashboard-footer {
    background-color: var(--white);
    border-top-color: var(--neutral-200);
}

html[data-theme="dark"] .dashboard-footer__system {
    color: var(--text-primary-light);
}

html[data-theme="dark"] .dashboard-footer__copy,
html[data-theme="dark"] .dashboard-footer__credit {
    color: var(--text-secondary-light);
}

@media (max-width: 767.98px) {
    .dashboard-footer__inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .dashboard-footer__meta {
        margin-inline-start: 0;
        text-align: start;
    }
}
