/**
 * Dash Horizon — selects, DataTables, markdown editor, file inputs
 * Loaded after theme.min.css so component rules win without global colour force.
 */

/* ------------------------------------------------------------------ */
/* Issue 1 — Native selects                                           */
/* ------------------------------------------------------------------ */
body.dh-theme,
body.dh-theme .primary-content {
  color-scheme: dark;
}

body.dh-theme select,
body.dh-theme select.form-control,
body.dh-theme select.custom-select,
body.dh-theme .form-control:not([type]):is(select),
body.dh-theme .dataTables_length select,
body.dh-theme .dataTables_wrapper select {
  background-color: var(--dh-bg-input, #172235);
  color: var(--dh-text-primary, #ffffff);
  border-color: rgba(255, 255, 255, 0.18);
  color-scheme: dark;
}

body.dh-theme select:focus,
body.dh-theme select.form-control:focus,
body.dh-theme select.custom-select:focus {
  border-color: var(--dh-accent-2, #6f98c5);
  box-shadow: var(--dh-focus);
  outline: none;
  color: var(--dh-text-primary, #ffffff);
  background-color: var(--dh-bg-input, #172235);
}

body.dh-theme select:disabled,
body.dh-theme select option:disabled {
  color: var(--dh-text-muted, #aab8ca);
  opacity: 0.7;
}

body.dh-theme select.is-invalid,
body.dh-theme select.form-control.is-invalid {
  border-color: var(--dh-danger, #ff6b6b);
}

body.dh-theme select option,
body.dh-theme select optgroup {
  background-color: #172235;
  color: #ffffff;
}

body.dh-theme select option:checked,
body.dh-theme select option:hover,
body.dh-theme select option:focus {
  background-color: #243a63;
  color: #ffffff;
}

body.dh-theme select optgroup {
  font-weight: 700;
  color: var(--dh-accent-2, #6f98c5);
}

/* ------------------------------------------------------------------ */
/* Issue 4 — Tables / DataTables                                      */
/* ------------------------------------------------------------------ */
body.dh-theme .table,
body.dh-theme .dataTable,
body.dh-theme table.table-list {
  --bs-table-bg: transparent;
  --bs-table-color: #eef4ff;
  --bs-table-border-color: rgba(255, 255, 255, 0.10);
  --bs-table-hover-bg: rgba(255, 255, 255, 0.05);
  --bs-table-hover-color: #ffffff;
  --bs-table-striped-bg: rgba(255, 255, 255, 0.03);
  --bs-table-striped-color: #eef4ff;
  background-color: transparent !important;
  color: var(--dh-text-secondary, #dce8f8) !important;
  border-color: var(--dh-border-2, rgba(255, 255, 255, 0.10)) !important;
}

body.dh-theme .table-container,
body.dh-theme .table-responsive,
body.dh-theme .dataTables_wrapper,
body.dh-theme .dataTables_wrapper table.table-list {
  background: var(--dh-bg-table, rgba(7, 17, 31, 0.92)) !important;
  border: 1px solid var(--dh-border) !important;
  border-radius: var(--dh-radius) !important;
  color: var(--dh-text-secondary, #dce8f8);
}

body.dh-theme .dataTables_wrapper table.table-list {
  margin: 10px 0 !important;
  width: 100% !important;
}

body.dh-theme .table thead th,
body.dh-theme .dataTable thead th,
body.dh-theme table.table-list thead th,
body.dh-theme .dataTables_wrapper table.table-list thead th,
body.dh-theme .dataTables_wrapper table.table-list thead th.sorting_asc,
body.dh-theme .dataTables_wrapper table.table-list thead th.sorting_desc,
body.dh-theme .dataTables_wrapper table.table-list thead th.sorting {
  background-color: rgba(255, 255, 255, 0.06) !important;
  color: var(--dh-text-primary, #ffffff) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12) !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
}

body.dh-theme .table tbody tr,
body.dh-theme .dataTable tbody tr,
body.dh-theme table.table-list tbody tr {
  background-color: transparent !important;
  color: var(--dh-text-secondary, #dce8f8) !important;
}

body.dh-theme .table tbody td,
body.dh-theme .table tbody th,
body.dh-theme .dataTable tbody td,
body.dh-theme .dataTable tbody th,
body.dh-theme table.table-list tbody td,
body.dh-theme .table-list > tbody > tr > td,
body.dh-theme .table-list > tbody > tr:hover > td {
  background-color: transparent !important;
  color: var(--dh-text-secondary, #dce8f8) !important;
  border-color: rgba(255, 255, 255, 0.10) !important;
  border-left-color: transparent !important;
}

body.dh-theme .table-list > tbody > tr > td a.border-left {
  border-left-color: rgba(255, 255, 255, 0.12) !important;
  color: var(--dh-link, #6ea8ff);
}

body.dh-theme .table tbody tr:hover,
body.dh-theme .dataTable tbody tr:hover,
body.dh-theme .table-hover tbody tr:hover,
body.dh-theme .table-list > tbody > tr:hover {
  background-color: var(--dh-bg-table-hover, rgba(255, 255, 255, 0.05)) !important;
  color: #ffffff !important;
}

body.dh-theme .table tbody tr:hover > td,
body.dh-theme .table-list > tbody > tr:hover > td {
  background-color: transparent !important;
  color: #eef4ff !important;
}

body.dh-theme .table-striped tbody tr:nth-of-type(odd),
body.dh-theme .table-striped tbody tr:nth-of-type(odd) > td {
  background-color: rgba(255, 255, 255, 0.03) !important;
}

body.dh-theme .table a:not(.btn),
body.dh-theme .dataTable a:not(.btn),
body.dh-theme table.table-list a:not(.btn) {
  color: var(--dh-link, #6ea8ff);
}

body.dh-theme .table a:not(.btn):hover,
body.dh-theme table.table-list a:not(.btn):hover {
  color: var(--dh-soft, #d8e9ff);
}

body.dh-theme .table .text-muted,
body.dh-theme table.table-list .text-muted {
  color: var(--dh-text-muted, #aab8ca) !important;
}

/* Status badges remain accessible on dark rows */
body.dh-theme .table .label,
body.dh-theme .table .badge,
body.dh-theme table.table-list .label,
body.dh-theme table.table-list .badge,
body.dh-theme .status {
  color: #fff;
}

/* DataTables controls */
body.dh-theme .dataTables_wrapper .dataTables_length,
body.dh-theme .dataTables_wrapper .dataTables_filter,
body.dh-theme .dataTables_wrapper .dataTables_info,
body.dh-theme .dataTables_wrapper .dataTables_paginate {
  color: var(--dh-text-secondary, #dce8f8) !important;
}

body.dh-theme .dataTables_wrapper .dataTables_filter label,
body.dh-theme .dataTables_wrapper .dataTables_length label {
  color: var(--dh-text-secondary, #dce8f8) !important;
}

body.dh-theme .dataTables_wrapper .dataTables_filter label .form-control,
body.dh-theme .dataTables_wrapper .dataTables_filter input[type="search"],
body.dh-theme .dataTables_wrapper .dataTables_filter input {
  background: var(--dh-bg-input, #172235) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23aab8ca' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='M14 14l-3-3'/%3E%3C/svg%3E") no-repeat 12px center !important;
  background-size: 16px 16px !important;
  color: var(--dh-text-primary, #ffffff) !important;
  border: 1px solid rgba(255, 255, 255, 0.18) !important;
  padding-left: 40px !important;
  min-height: 40px;
  border-radius: var(--dh-radius-sm);
}

body.dh-theme .dataTables_wrapper .dataTables_filter label .form-control::placeholder,
body.dh-theme .dataTables_wrapper .dataTables_filter input::placeholder {
  color: var(--dh-text-muted, #aab8ca);
  opacity: 0.9;
}

body.dh-theme .dataTables_wrapper .dataTables_paginate .paginate_button,
body.dh-theme .dataTables_wrapper .dataTables_paginate .paginate_button a,
body.dh-theme .pagination .page-link {
  background: rgba(255, 255, 255, 0.06) !important;
  color: var(--dh-text-secondary, #dce8f8) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
}

body.dh-theme .dataTables_wrapper .dataTables_paginate .paginate_button.current,
body.dh-theme .dataTables_wrapper .dataTables_paginate .paginate_button.current a,
body.dh-theme .dataTables_wrapper .dataTables_paginate .paginate_button:hover,
body.dh-theme .pagination .page-item.active .page-link {
  background: var(--dh-accent, #1A3F6B) !important;
  color: #ffffff !important;
  border-color: var(--dh-accent-2, #6f98c5) !important;
}

body.dh-theme .dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
body.dh-theme .dataTables_wrapper .dataTables_paginate .paginate_button.disabled a,
body.dh-theme .pagination .page-item.disabled .page-link {
  background: rgba(255, 255, 255, 0.03) !important;
  color: var(--dh-text-muted, #aab8ca) !important;
  opacity: 0.7;
}

/* Responsive DataTables child rows */
body.dh-theme table.dataTable > tbody > tr.child,
body.dh-theme table.dataTable > tbody > tr.child ul.dtr-details,
body.dh-theme table.dataTable > tbody > tr.child span.dtr-title,
body.dh-theme table.dataTable > tbody > tr.child span.dtr-data {
  background: var(--dh-bg-panel-raised, #0d1b2e) !important;
  color: var(--dh-text-secondary, #dce8f8) !important;
  border-color: rgba(255, 255, 255, 0.10) !important;
}

body.dh-theme .dataTables_empty,
body.dh-theme td.dataTables_empty {
  color: var(--dh-text-muted, #aab8ca) !important;
  background: transparent !important;
}

/* Sorting icons — keep visible on dark headers */
body.dh-theme table.dataTable thead .sorting:before,
body.dh-theme table.dataTable thead .sorting:after,
body.dh-theme table.dataTable thead .sorting_asc:before,
body.dh-theme table.dataTable thead .sorting_asc:after,
body.dh-theme table.dataTable thead .sorting_desc:before,
body.dh-theme table.dataTable thead .sorting_desc:after {
  opacity: 0.85;
  color: #ffffff;
}

/* ------------------------------------------------------------------ */
/* Issue 5 — Bootstrap Markdown editor                                */
/* ------------------------------------------------------------------ */
body.dh-theme .md-editor,
body.dh-theme div.md-editor,
body.dh-theme div.md-editor.active {
  background: var(--dh-bg-panel, rgba(7, 17, 31, 0.92)) !important;
  border: 1px solid rgba(255, 255, 255, 0.18) !important;
  border-radius: var(--dh-radius) !important;
  color: var(--dh-text-secondary, #dce8f8);
  box-shadow: none !important;
}

body.dh-theme .md-editor > .md-header,
body.dh-theme .md-editor .md-header,
body.dh-theme .md-editor > .btn-toolbar,
body.dh-theme .md-editor .btn-toolbar {
  background-color: #121c2e !important;
  background: #121c2e !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
  color: #eef4ff !important;
}

body.dh-theme .md-editor .btn-toolbar .btn,
body.dh-theme .md-editor .md-header .btn,
body.dh-theme .md-editor .md-controls .md-control {
  background: rgba(255, 255, 255, 0.06) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  color: #eef4ff !important;
  box-shadow: none !important;
}

body.dh-theme .md-editor .btn-toolbar .btn:hover,
body.dh-theme .md-editor .btn-toolbar .btn:focus,
body.dh-theme .md-editor .btn-toolbar .btn.active,
body.dh-theme .md-editor .md-controls .md-control:hover {
  background: #243a63 !important;
  color: #ffffff !important;
  border-color: rgba(255, 255, 255, 0.22) !important;
}

body.dh-theme .md-editor .md-controls .md-control {
  color: #c5d4e8 !important;
}

body.dh-theme .md-editor > textarea,
body.dh-theme .md-editor > textarea.markdown-editor,
body.dh-theme .md-editor > textarea.form-control,
body.dh-theme textarea.markdown-editor,
body.dh-theme textarea[name="message"],
body.dh-theme textarea[name="replymessage"] {
  background-color: #0f1828 !important;
  color: #eef4ff !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
  caret-color: #ffffff;
}

body.dh-theme .md-editor > textarea::placeholder,
body.dh-theme textarea.markdown-editor::placeholder {
  color: var(--dh-text-muted, #aab8ca) !important;
  opacity: 0.9;
}

body.dh-theme .md-editor > .md-preview,
body.dh-theme .md-editor .md-preview {
  background-color: #0f1828 !important;
  color: #eef4ff !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
}

body.dh-theme .md-editor > .md-preview a {
  color: var(--dh-link, #6ea8ff);
}

body.dh-theme .md-editor .md-footer,
body.dh-theme .md-editor > .md-footer,
body.dh-theme .markdown-editor-status {
  background: #121c2e !important;
  color: #c5d4e8 !important;
  border-top: 1px solid rgba(255, 255, 255, 0.10);
  text-align: right;
}

/* ------------------------------------------------------------------ */
/* Issue 6 — File upload fields                                       */
/* ------------------------------------------------------------------ */
body.dh-theme input[type="file"],
body.dh-theme .form-control[type="file"],
body.dh-theme input[type="file"].form-control {
  background-color: var(--dh-bg-input, #172235);
  color: #eef4ff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--dh-radius-sm);
  padding: 0.45rem 0.65rem;
  max-width: 100%;
  color-scheme: dark;
}

body.dh-theme input[type="file"]::file-selector-button,
body.dh-theme input[type="file"]::-webkit-file-upload-button {
  background-color: #243a63;
  color: #ffffff;
  border: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.18);
  margin-right: 0.85rem;
  padding: 0.55rem 1rem;
  border-radius: 8px 0 0 8px;
  cursor: pointer;
  font-weight: 700;
}

body.dh-theme input[type="file"]:hover::file-selector-button,
body.dh-theme input[type="file"]:hover::-webkit-file-upload-button {
  background-color: #2f4d7a;
}

body.dh-theme input[type="file"]:focus {
  border-color: var(--dh-accent-2, #6f98c5);
  box-shadow: var(--dh-focus);
  outline: none;
}

body.dh-theme input[type="file"]:disabled {
  opacity: 0.65;
  color: var(--dh-text-muted);
}

body.dh-theme .custom-file-label,
body.dh-theme .custom-file .custom-file-label {
  background-color: var(--dh-bg-input, #172235) !important;
  color: #eef4ff !important;
  border-color: rgba(255, 255, 255, 0.18) !important;
}

body.dh-theme .custom-file-label::after {
  background-color: #243a63 !important;
  color: #ffffff !important;
  border-left: 1px solid rgba(255, 255, 255, 0.18) !important;
}

body.dh-theme .custom-file-input:focus ~ .custom-file-label {
  border-color: var(--dh-accent-2, #6f98c5) !important;
  box-shadow: var(--dh-focus);
}

body.dh-theme .input-group .btn-file,
body.dh-theme .btn-file {
  background: #243a63 !important;
  color: #ffffff !important;
  border-color: rgba(255, 255, 255, 0.18) !important;
}

/* Attachment rows / Add More */
body.dh-theme .file-input,
body.dh-theme .row.fileupload,
body.dh-theme #fileUploadsContainer,
body.dh-theme .ticket-attachments-message {
  color: var(--dh-text-secondary, #dce8f8);
}

body.dh-theme #fileUploadsContainer input[type="file"],
body.dh-theme .attach-file input[type="file"] {
  width: 100%;
}

/* ------------------------------------------------------------------ */
/* Powered by — restyle only, never hide                              */
/* ------------------------------------------------------------------ */
body.dh-theme #footer .copyright,
body.dh-theme .dhds-footer .copyright,
body.dh-theme a[href*="whmcs.com"],
body.dh-theme .powered-by-whmcs,
body.dh-theme #poweredby {
  color: var(--dh-text-muted, #aab8ca);
  font-size: 13px;
}

body.dh-theme a[href*="whmcs.com"]:hover {
  color: var(--dh-soft, #d8e9ff);
}
