/* Dark theme overrides (scoped to html.dark) */

html.dark body {
  color: #e0e6ef;
  background: #0f1218;
}

/* Header */
html.dark .header {
  background: #171b22;
  box-shadow: 0 1px 0 0 #2a2f3a;
}
html.dark .header .user-names h5,
html.dark .header .user-names span,
html.dark .header a,
html.dark .header i {
  color: #e0e6ef;
}

/* Sidebar */
html.dark .sidebar {
  background: #131720;
  border-right: 1px solid #2a2f3a;
}
html.dark #sidebar-menu a { color: #cfd6e4; }
html.dark #sidebar-menu a.active,
html.dark #sidebar-menu a:hover { color: #ffffff; }
html.dark #sidebar-menu .menu-title { color: #8f99ad; }
html.dark .sidebar .submenu ul { background: #0f141d; }
html.dark .sidebar .submenu a { color: #cbd3e3; }

/* Content wrappers and cards */
html.dark .page-wrapper { background: #0f1218; }
html.dark .card,
html.dark .card .card,
html.dark .card-body,
html.dark .card-header,
html.dark .modal-content,
html.dark .dropdown-menu {
  background: #171b22;
  color: #e0e6ef;
  border-color: #2a2f3a;
}
html.dark .card-header,
html.dark .modal-header,
html.dark .dropdown-menu { border-bottom: 1px solid #2a2f3a; }
html.dark .modal-footer,
html.dark .card-footer { border-top: 1px solid #2a2f3a; }

/* Tables */
html.dark .table { color: #e0e6ef; border-color: #2a2f3a; }
html.dark .table thead th { background: #1b2029; color: #e0e6ef; border-color: #2a2f3a; }
html.dark .table tbody tr { background: #171b22; }
html.dark .table-striped > tbody > tr:nth-of-type(2n+1) { background-color: #141922; }
html.dark .table-bordered td,
html.dark .table-bordered th { border-color: #2a2f3a; }

/* Forms */
html.dark .form-control,
html.dark .select2-container--default .select2-selection--single,
html.dark .select2-dropdown { 
  background-color: #12161f;
  color: #e0e6ef;
  border-color: #2a2f3a;
}
html.dark .form-control::placeholder { color: #8a93a5; }
html.dark .select2-results__option { color: #e0e6ef; }
html.dark .select2-search__field { background: #12161f; color: #e0e6ef; }

/* Buttons (keep primary color, adjust outlines) */
html.dark .btn-outline-secondary { color: #cbd3e3; border-color: #3a4150; }
html.dark .btn-outline-secondary:hover { background: #222836; color: #fff; }

/* Badges and helpers */
html.dark .badge.bg-secondary { background-color: #2a2f3a !important; color: #cfd6e4; }
html.dark .text-muted { color: #9aa3b5 !important; }

/* Misc components */
html.dark .dropdown-item { color: #cfd6e4; }
html.dark .dropdown-item:hover { background: #1f2530; color: #fff; }
html.dark .list-group-item { background: #171b22; color: #e0e6ef; border-color: #2a2f3a; }
html.dark .nav-tabs .nav-link { color: #cfd6e4; }
html.dark .nav-tabs .nav-link.active { background: #171b22; color: #fff; border-color: #2a2f3a #2a2f3a transparent; }

/* Charts, plugin containers (general background fix) */
html.dark .apexcharts-canvas, 
html.dark .fc,
html.dark .fc .fc-scrollgrid {
  background: #171b22;
}

/* ApexCharts text & tooltip */
html.dark .apexcharts-title-text,
html.dark .apexcharts-subtitle-text,
html.dark .apexcharts-legend-text,
html.dark .apexcharts-datalabel,
html.dark .apexcharts-xaxis text,
html.dark .apexcharts-yaxis text {
  fill: #e0e6ef !important;
  color: #e0e6ef !important;
}
html.dark .apexcharts-tooltip {
  background: #1b2029 !important;
  border-color: #2a2f3a !important;
}
html.dark .apexcharts-tooltip .apexcharts-tooltip-title {
  background: #131720 !important;
  border-bottom: 1px solid #2a2f3a !important;
  color: #e0e6ef !important;
}

/* DataTables */
html.dark .dataTables_wrapper .dataTables_filter label,
html.dark .dataTables_wrapper .dataTables_length label,
html.dark .dataTables_wrapper .dataTables_info {
  color: #cfd6e4;
}
html.dark .dataTables_wrapper .dataTables_filter input,
html.dark .dataTables_wrapper .dataTables_length select {
  background: #12161f;
  color: #e0e6ef;
  border: 1px solid #2a2f3a;
  border-radius: 8px;
}
html.dark .dataTables_wrapper .dataTables_paginate .paginate_button {
  color: #cfd6e4 !important;
  border: 1px solid #2a2f3a !important;
  background: #171b22 !important;
}
html.dark .dataTables_wrapper .dataTables_paginate .paginate_button.current,
html.dark .dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  color: #fff !important;
  background: #1f2530 !important;
  border-color: #3a4150 !important;
}
html.dark table.dataTable thead th,
html.dark table.dataTable thead td {
  background-color: #1b2029;
  color: #e0e6ef;
  border-bottom: 1px solid #2a2f3a;
}
html.dark table.dataTable.no-footer { border-bottom: 1px solid #2a2f3a; }

/* Notyf (toasts) */
html.dark .notyf__toast {
  color: #e0e6ef;
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);
}
html.dark .notyf__message { color: #e0e6ef; }

/* Ensure header toggle icon is visible in dark */
html.dark .header #themeToggle i {
  color: #e0e6ef;
  --fa-primary-color: #e0e6ef;
  --fa-secondary-color: #e0e6ef;
}

/* DataTables v2 (dt-*) wrappers */
html.dark .dt-container .dt-search input.dt-input,
html.dark .dt-container .dt-length select.dt-input,
html.dark .dt-container .dt-input {
  background-color: #12161f !important;
  color: #e0e6ef !important;
  border: 1px solid #2a2f3a !important;
}
html.dark .dt-container .dt-info { color: #cfd6e4 !important; }
html.dark .dt-container .dt-paging .dt-paging-button {
  color: #cfd6e4 !important;
  border: 1px solid #2a2f3a !important;
  background: #171b22 !important;
}
html.dark .dt-container .dt-paging .dt-paging-button.current,
html.dark .dt-container .dt-paging .dt-paging-button:hover {
  color: #fff !important;
  background: #1f2530 !important;
  border-color: #3a4150 !important;
}
html.dark .dt-container .dt-scroll,
html.dark .dt-container .dt-scroll-head,
html.dark .dt-container .dt-scroll-body,
html.dark .dt-container .dt-scroll-foot {
  background: #171b22 !important;
}

/* DataTables table backgrounds and stripes */
html.dark table.dataTable { background-color: #171b22 !important; color: #e0e6ef; }
html.dark table.dataTable > thead > tr > th,
html.dark table.dataTable > thead > tr > td { background-color: #1b2029 !important; color: #e0e6ef !important; }
html.dark table.dataTable > tfoot > tr > th,
html.dark table.dataTable > tfoot > tr > td { background-color: #1b2029 !important; color: #e0e6ef !important; }
html.dark table.dataTable tbody tr { background-color: #171b22 !important; }
html.dark table.dataTable.stripe tbody tr.odd,
html.dark table.dataTable.display tbody tr.odd { background-color: #151a23 !important; }
html.dark table.dataTable.stripe tbody tr.even,
html.dark table.dataTable.display tbody tr.even { background-color: #171b22 !important; }
html.dark table.dataTable.hover tbody tr:hover,
html.dark table.dataTable.display tbody tr:hover { background-color: #1f2530 !important; }
html.dark table.dataTable.no-footer { border-bottom: 1px solid #2a2f3a !important; }

/* Floating panels/forms (custom) */
html.dark #floatingForm,
html.dark .floatingForm {
  background: #171b22 !important;
  color: #e0e6ef !important;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.6) !important;
}
html.dark #floatingForm .floatingForm-header,
html.dark .floatingForm-header {
  background-color: #1b2029 !important;
  color: #e0e6ef !important;
  box-shadow: 0 5px 8px rgba(0, 0, 0, 0.4) !important;
}
html.dark #floatingForm .close-btn,
html.dark .floatingForm-header .close-btn { color: #e0e6ef !important; }

/* Floating Normas panel */
html.dark #floatingNormas {
  background: #171b22 !important;
  color: #e0e6ef !important;
  box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.6) !important;
}
html.dark #floatingNormas .floatingNormas-header {
  background: #1b2029 !important;
  color: #e0e6ef !important;
}
html.dark #floatingNormas .floatingNormas-header .close-btn { color: #e0e6ef !important; }
html.dark #floatingNormas .floatingNormas-body { color: #e0e6ef !important; }

/* Mail view content */
html.dark .mailview-content,
html.dark .mailview-inner {
  background: #171b22 !important;
  color: #e0e6ef !important;
}
html.dark .mailview-header { border-bottom: 1px solid #2a2f3a !important; }
html.dark .mailview-footer { border-top: 1px solid #2a2f3a !important; }
html.dark .mailview-content p,
html.dark .mailview-content h1,
html.dark .mailview-content h2,
html.dark .mailview-content h3,
html.dark .mailview-content h4,
html.dark .mailview-content h5,
html.dark .mailview-content h6,
html.dark .mailview-content span,
html.dark .mailview-inner p,
html.dark .mailview-inner span,
html.dark .send-user p span,
html.dark .send-user.send-user-name h4,
html.dark .send-user.send-user-name h4 span,
html.dark .sender-name,
html.dark .receiver-name {
  color: #e0e6ef !important;
}
/* Tag pills inside mail header */
html.dark .send-user .email-market,
html.dark .email-office,
html.dark .email-bills,
html.dark .email-work {
  filter: brightness(0.9) contrast(1.1);
}
/* Status badges */
html.dark .custom-badge.status-blue,
html.dark a.custom-badge.status-blue,
html.dark .status-blue,
html.dark a.status-blue {
  background-color: rgba(0, 140, 255, 0.15) !important;
  color: #4da3ff !important;
}

/* Card-box custom blocks */
html.dark .card-box {
  background: #171b22 !important;
  color: #e0e6ef !important;
  border: 1px solid #2a2f3a !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.35) !important;
}
html.dark .card-box h1,
html.dark .card-box h2,
html.dark .card-box h3,
html.dark .card-box h4,
html.dark .card-box h5,
html.dark .card-box h6,
html.dark .card-box p,
html.dark .card-box span,
html.dark .card-box label,
html.dark .card-box .text-muted {
  color: #e0e6ef !important;
}
html.dark .card-box .form-control::placeholder { color: #8a93a5 !important; }

/* Good morning block */
html.dark .good-morning-blk {
  background: #171b22 !important;
  color: #e0e6ef !important;
  border: 1px solid #2a2f3a !important;
}
html.dark .good-morning-blk:before { background-image: none !important; }
html.dark .morning-user h2,
html.dark .morning-user h2 span,
html.dark .morning-user p { color: #e0e6ef !important; }
html.dark .morning-user p { color: #cfd6e4 !important; }

/* Labels: make them slightly muted but readable in dark */
html.dark label,
html.dark .col-form-label,
html.dark .form-check-label,
html.dark .form-label,
html.dark .local-forms label,
html.dark .settings-form .input-block label,
html.dark .invoices-main-form label,
html.dark .modal-body label {
  color: #cbd3e3 !important;
}

/* SweetAlert2 (swal) dark theme */
html.dark .swal2-popup {
  background: #171b22 !important;
  color: #e0e6ef !important;
  border: 1px solid #2a2f3a !important;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5) !important;
}
html.dark .swal2-title,
html.dark .swal2-html-container { color: #e0e6ef !important; }
html.dark .swal2-actions .swal2-styled.swal2-confirm {
  background: var(--color-primary) !important;
  color: #fff !important;
  border: 1px solid var(--color-primary) !important;
}
html.dark .swal2-actions .swal2-styled.swal2-cancel,
html.dark .swal2-actions .swal2-styled.swal2-deny {
  background: #2a2f3a !important;
  color: #e0e6ef !important;
  border: 1px solid #3a4150 !important;
}
html.dark .swal2-styled:focus { box-shadow: 0 0 0 0.2rem rgba(6, 152, 52, 0.35) !important; }
html.dark .swal2-input,
html.dark .swal2-textarea,
html.dark .swal2-select {
  background: #12161f !important;
  color: #e0e6ef !important;
  border: 1px solid #2a2f3a !important;
}
html.dark .swal2-checkbox label,
html.dark .swal2-radio label { color: #e0e6ef !important; }
html.dark .swal2-icon { border-color: #3a4150 !important; }
html.dark .swal2-timer-progress-bar { background: var(--color-primary) !important; }
html.dark .swal2-toast { background: #171b22 !important; color: #e0e6ef !important; border: 1px solid #2a2f3a !important; }

/* Header logo: force white mask in dark */
html.dark .header .logo span img {
  filter: grayscale(100%) brightness(1000%) contrast(100%) sepia(100%) !important;
}

/* Buttons: lighten cancel primary in dark mode */
html.dark .btn-primary.cancel-form,
html.dark .cancel-form.btn-primary {
  background-color: #f3f4f6 !important; /* near-white */
  color: #111827 !important; /* dark text */
  border-color: #d1d5db !important;
}
html.dark .btn-primary.cancel-form:hover,
html.dark .cancel-form.btn-primary:hover {
  background-color: #e5e7eb !important;
  border-color: #cbd5e1 !important;
}
html.dark .btn-primary.cancel-form:active,
html.dark .cancel-form.btn-primary:active,
html.dark .btn-primary.cancel-form.active,
html.dark .cancel-form.btn-primary.active {
  background-color: #dde3ea !important;
  border-color: #cbd5e1 !important;
}
html.dark .btn-primary.cancel-form:focus,
html.dark .cancel-form.btn-primary:focus {
  box-shadow: 0 0 0 0.25rem rgba(17, 24, 39, 0.25) !important;
}
