/* ===== CSS Variables - Light Theme (default) ===== */
:root {
  /* Status colors */
  --color-failed: #AA4643;
  --color-changed: #4572A7;
  --color-unchanged: #89A54E;
  --color-unreported: #3D96AE;
  --color-noop: #DB843D;
  --color-skipped: orange;
  --color-total: #989898;

  /* UI colors */
  --color-darkblue: #2C3E50;
  --color-yellow: #F0E965;
  --color-link: #2E5D8C;
  --color-bg: #ffffff;
  --color-bg-secondary: #f5f5f5;
  --color-text: #333333;
  --color-text-muted: #666666;
  --color-border: #e0e0e0;
  --color-footer-bg: #E8E8E8;

  /* Scroll button */
  --color-scroll-btn: #777;
  --color-scroll-btn-hover: #888;
  --color-scroll-btn-text: #EEE;

  /* JSON syntax highlighting */
  --color-json-string: #2E5D8C;
  --color-json-string-hover: #1e70bf;
  --color-json-number: darkorange;
  --color-json-number-hover: #ffab3d;
  --color-json-boolean: blue;
  --color-json-boolean-hover: #7171fc;
  --color-json-key: rgb(97, 117, 54);
  --color-json-key-hover: rgb(158, 185, 101);
  --color-json-null: magenta;

  /* Component colors */
  --color-segment-bg: #ffffff;
  --color-table-bg: #ffffff;
  --color-table-header-bg: #f9fafb;
  --color-input-bg: #ffffff;
  --color-dropdown-bg: #ffffff;
  --color-card-bg: #ffffff;
}

/* ===== CSS Variables - Dark Theme ===== */
[data-theme="dark"] {
  /* Status colors - bolder/brighter for dark backgrounds */
  --color-failed: #ff5555;
  --color-changed: #5badff;
  --color-unchanged: #89A54E;
  --color-unreported: #17a2b8;
  --color-noop: #ffb86c;
  --color-skipped: #ffa500;
  --color-total: #b0b0b0;

  /* UI colors */
  --color-darkblue: #1a252f;
  --color-yellow: #F0E965;
  --color-link: #79c0ff;
  --color-bg: #1b1c1d;
  --color-bg-secondary: #0d1117;
  --color-text: #e6edf3;
  --color-text-muted: #a0a0a0;
  --color-border: #555555;
  --color-footer-bg: #242526;

  /* Scroll button */
  --color-scroll-btn: #555;
  --color-scroll-btn-hover: #666;
  --color-scroll-btn-text: #EEE;

  /* JSON syntax highlighting - brighter for dark bg */
  --color-json-string: #79c0ff;
  --color-json-string-hover: #a5d6ff;
  --color-json-number: #ffb347;
  --color-json-number-hover: #ffc977;
  --color-json-boolean: #79c0ff;
  --color-json-boolean-hover: #a5d6ff;
  --color-json-key: rgb(158, 185, 101);
  --color-json-key-hover: rgb(180, 210, 130);
  --color-json-null: #ff79c6;

  /* Component colors */
  --color-segment-bg: #161b22;
  --color-table-bg: #161b22;
  --color-table-header-bg: #0d1117;
  --color-input-bg: #0d1117;
  --color-dropdown-bg: #161b22;
  --color-card-bg: #161b22;
}

/* ===== Dark Theme Overrides ===== */
[data-theme="dark"] body {
  background-color: var(--color-bg);
  color: var(--color-text);
}

[data-theme="dark"] .ui.segment {
  background-color: var(--color-segment-bg);
  color: var(--color-text);
  border-color: var(--color-border);
}

[data-theme="dark"] .ui.table {
  background-color: var(--color-table-bg);
  color: var(--color-text);
  border-color: var(--color-border);
}

[data-theme="dark"] .ui.table thead th {
  background-color: var(--color-table-header-bg);
  color: var(--color-text);
  border-color: var(--color-border);
}

[data-theme="dark"] .ui.table tbody tr {
  border-color: var(--color-border);
}

[data-theme="dark"] .ui.table tbody td {
  border-color: var(--color-border);
}

/* Table row backgrounds in dark mode */
[data-theme="dark"] .ui.table tbody tr {
  background-color: var(--color-table-bg);
}

[data-theme="dark"] .ui.table tbody tr:hover {
  background-color: var(--color-bg-secondary) !important;
}

/* Striped tables */
[data-theme="dark"] .ui.striped.table tbody tr:nth-child(2n) {
  background-color: var(--color-bg-secondary);
}

[data-theme="dark"] .ui.form input,
[data-theme="dark"] .ui.form textarea,
[data-theme="dark"] .ui.input input,
[data-theme="dark"] textarea {
  background-color: var(--color-input-bg);
  color: var(--color-text);
  border-color: var(--color-border);
}

[data-theme="dark"] select,
[data-theme="dark"] .ui.form select {
  background-color: var(--color-segment-bg);
  color: var(--color-text);
  border-color: var(--color-border);
  border: 1px solid var(--color-border);
}

[data-theme="dark"] .ui.dropdown,
[data-theme="dark"] .ui.dropdown .menu {
  background-color: var(--color-dropdown-bg);
  color: var(--color-text);
  border-color: var(--color-border);
}

[data-theme="dark"] .ui.dropdown .menu > .item {
  color: var(--color-text);
  border-color: var(--color-border);
}

[data-theme="dark"] .ui.dropdown .menu > .item:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .ui.selection.dropdown {
  background-color: var(--color-dropdown-bg);
  border-color: var(--color-border);
}

[data-theme="dark"] .ui.card,
[data-theme="dark"] .ui.cards > .card {
  background-color: var(--color-card-bg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .ui.message {
  background-color: var(--color-bg-secondary);
  color: var(--color-text);
  border-color: var(--color-border);
}

[data-theme="dark"] pre.result,
[data-theme="dark"] pre.error_message,
[data-theme="dark"] td.error_message,
[data-theme="dark"] .log-message {
  background-color: var(--color-bg-secondary);
  color: var(--color-text);
}

/* Failures page dark mode - override Fomantic UI .negative which uses !important */
[data-theme="dark"] td.negative.error_message {
  background-color: #4a1515 !important;
  color: #ffcccc !important;
}

/* DataTables in dark mode - ensure proper dark styling */
[data-theme="dark"] .dataTables_wrapper {
  color: var(--color-text);
}

[data-theme="dark"] table.dataTable tbody tr {
  background-color: var(--color-table-bg) !important;
}

[data-theme="dark"] table.dataTable tbody tr:hover {
  background-color: var(--color-bg-secondary) !important;
}

[data-theme="dark"] table.dataTable tbody td {
  color: var(--color-text);
  background-color: transparent;
}

[data-theme="dark"] table.dataTable thead th {
  background-color: var(--color-table-header-bg) !important;
  color: var(--color-text) !important;
  border-color: var(--color-border) !important;
}

/* Billboard.js chart tooltip - improved readability */
.bb-tooltip th {
  background-color: #555;
  color: #fff;
}

.bb-tooltip td {
  color: #222 !important;
  background-color: #fff !important;
}

/* Billboard.js chart dark mode */
[data-theme="dark"] .bb text,
[data-theme="dark"] .bb-axis text,
[data-theme="dark"] .bb-axis-x text,
[data-theme="dark"] .bb-axis-y text {
  fill: var(--color-text) !important;
}

[data-theme="dark"] .bb-axis line,
[data-theme="dark"] .bb-axis path {
  stroke: var(--color-border) !important;
}

[data-theme="dark"] .bb-legend-item text {
  fill: var(--color-text) !important;
}

/* Billboard.js chart tooltip - dark mode */
[data-theme="dark"] .bb-tooltip {
  background-color: #2a2a2a !important;
}

[data-theme="dark"] .bb-tooltip tr {
  border-color: #555 !important;
}

[data-theme="dark"] .bb-tooltip th {
  background-color: #444 !important;
  color: #e0e0e0 !important;
}

[data-theme="dark"] .bb-tooltip td {
  background-color: #2a2a2a !important;
  color: #e0e0e0 !important;
  border-left-color: #555 !important;
}

/* DataTables pagination dark mode */
[data-theme="dark"] .dataTables_paginate .paginate_button {
  color: var(--color-text) !important;
  background-color: var(--color-table-bg) !important;
  border-color: var(--color-border) !important;
}

[data-theme="dark"] .dataTables_paginate .paginate_button:hover {
  color: var(--color-text) !important;
  background-color: var(--color-bg-secondary) !important;
  border-color: var(--color-border) !important;
}

[data-theme="dark"] .dataTables_paginate .paginate_button.current {
  color: #fff !important;
  background: var(--color-darkblue) !important;
  border-color: var(--color-darkblue) !important;
}

[data-theme="dark"] .dataTables_paginate .paginate_button.disabled {
  color: var(--color-text-muted) !important;
  background-color: var(--color-table-bg) !important;
}

/* DataTables export buttons (Copy, CSV, Excel, etc.) */
[data-theme="dark"] .dt-buttons .dt-button,
[data-theme="dark"] .buttons-copy,
[data-theme="dark"] .buttons-csv,
[data-theme="dark"] .buttons-excel,
[data-theme="dark"] .buttons-pdf,
[data-theme="dark"] .buttons-print {
  color: var(--color-text) !important;
  background-color: var(--color-table-bg) !important;
  border-color: var(--color-border) !important;
}

[data-theme="dark"] .dt-buttons .dt-button:hover {
  color: var(--color-text) !important;
  background-color: var(--color-bg-secondary) !important;
}

/* Fomantic UI checkboxes in dark mode */
[data-theme="dark"] .ui.checkbox label,
[data-theme="dark"] .ui.checkbox + label {
  color: var(--color-text) !important;
}

[data-theme="dark"] .ui.checkbox input:checked ~ label:before {
  background-color: var(--color-darkblue);
  border-color: var(--color-darkblue);
}

[data-theme="dark"] .ui.checkbox label:before {
  background-color: var(--color-input-bg);
  border-color: var(--color-border);
}

[data-theme="dark"] .ui.toggle.checkbox label {
  color: var(--color-text) !important;
}

[data-theme="dark"] .ui.toggle.checkbox label:before {
  background-color: var(--color-border);
}

[data-theme="dark"] .ui.toggle.checkbox input:checked ~ label:before {
  background-color: var(--color-changed) !important;
}

/* Fomantic UI buttons in dark mode */
[data-theme="dark"] .ui.button {
  background-color: var(--color-table-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

[data-theme="dark"] .ui.button:hover {
  background-color: var(--color-bg-secondary);
  color: var(--color-text);
}

[data-theme="dark"] .ui.primary.button {
  background-color: var(--color-changed);
  color: #fff;
}

/* Tabs/menu items in dark mode */
[data-theme="dark"] .ui.secondary.menu .item {
  color: var(--color-text);
}

[data-theme="dark"] .ui.secondary.menu .active.item {
  background-color: var(--color-bg-secondary);
  color: var(--color-text);
}

[data-theme="dark"] .ui.tabular.menu .item {
  color: var(--color-text);
  background-color: transparent;
  border-color: var(--color-border);
}

[data-theme="dark"] .ui.tabular.menu .active.item {
  background-color: var(--color-table-bg);
  color: var(--color-text);
  border-color: var(--color-border);
  border-bottom-color: var(--color-table-bg);
}

/* Ensure status labels keep white text on colored backgrounds in dark mode */
[data-theme="dark"] .ui.label.status,
[data-theme="dark"] .ui.label.failed,
[data-theme="dark"] .ui.label.failure,
[data-theme="dark"] .ui.label.changed,
[data-theme="dark"] .ui.label.success,
[data-theme="dark"] .ui.label.unchanged,
[data-theme="dark"] .ui.label.unreported,
[data-theme="dark"] .ui.label.noop,
[data-theme="dark"] .ui.label.skipped {
  color: #fff;
}

/* Basic labels - muted grey in dark mode */
[data-theme="dark"] .ui.label.basic,
[data-theme="dark"] .ui.basic.label {
  color: #ccc !important;
  background-color: #4e4e4e;
  border-color: #666;
}

/* Generic labels (no status color) - like time stamps and zero counts */
[data-theme="dark"] .ui.label.status:not(.failed):not(.changed):not(.unchanged):not(.unreported):not(.noop):not(.skipped),
[data-theme="dark"] .ui.label.count:not(.failed):not(.changed):not(.unchanged):not(.unreported):not(.noop):not(.skipped) {
  color: #ccc !important;
  background-color: #4e4e4e;
}

[data-theme="dark"] .ui.header {
  color: var(--color-text);
}

[data-theme="dark"] .ui.list .item {
  color: var(--color-text);
}

[data-theme="dark"] .ui.breadcrumb a {
  color: var(--color-link);
}

[data-theme="dark"] .ui.breadcrumb .divider {
  color: var(--color-text-muted);
}

[data-theme="dark"] .dataTables_wrapper .dataTables_filter input,
[data-theme="dark"] .dataTables_wrapper .dataTables_length select {
  background-color: var(--color-input-bg);
  color: var(--color-text);
  border-color: var(--color-border);
}

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

[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button {
  color: var(--color-text) !important;
}

[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: var(--color-bg-secondary) !important;
  color: var(--color-text) !important;
}

[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: var(--color-darkblue) !important;
  color: #fff !important;
}

/* ===== Base Styles ===== */
body {
  margin: 0;
  font-family: "Open Sans", sans-serif;
  font-size: 1.2rem;
}

a {
  color: var(--color-link);
  text-decoration: none;
}

h1.ui.header.no-margin-bottom {
  margin-bottom: 0;
}

.ui.select-environment > i.dropdown.icon {
  margin: 0.4em 0 0 1em !important;
}

.ui.select-environment.loading.selection.dropdown > i.dropdown.icon {
  padding: 1em 0.5em !important;
  margin: 0 !important;
}

/* Environment selector - wider for long branch names, grey background in both modes */
.ui.select-environment.dropdown {
  min-width: 22em !important;
}

.ui.select-environment.selection.dropdown {
  background-color: #4a4a4a !important;
  color: #f0f0f0 !important;
  border-color: #666 !important;
}

.ui.select-environment.selection.dropdown .text,
.ui.select-environment.selection.dropdown .default.text {
  color: #f0f0f0 !important;
}

.ui.select-environment.selection.dropdown .menu {
  background-color: #3a3a3a !important;
  border-color: #666 !important;
}

.ui.select-environment.selection.dropdown .menu .item {
  color: #f0f0f0 !important;
  border-color: #555 !important;
}

.ui.select-environment.selection.dropdown .menu .item:hover {
  background-color: rgba(255, 255, 255, 0.12) !important;
}

.ui.select-environment.selection.dropdown .menu .item.active,
.ui.select-environment.selection.dropdown .menu .item.selected {
  color: #79c0ff !important;
  font-weight: 600;
}

.ui.grid.padding-bottom {
  padding-bottom: 4em !important;
}

.status {
  width: 13.2em;
  text-align: center;
  display: block;
}

.ui[class*="very basic"].table.dataTable > thead > tr:first-child > th {
  padding-top: 0.8em !important;
  padding-bottom: 0.7em !important;
}

.ui[class*="very compact"].table>tbody>tr>td,
.ui[class*="very compact"].table>tfoot>tr>td,
.ui[class*="very compact"].table>tr>td {
  padding: 0.15em 0.1em;
}

.factlist li {
  word-wrap: break-word;
}

.ui.table.wrapped td {
  word-wrap: break-word;
}

.ui.label.status {
  color: white;
  text-shadow: 0 0 1px;
}

/* Status Colors - Failed */
.ui.header.failed, .ui.line.failed {
  color: var(--color-failed);
}

.ui.label.failed, .ui.label.failure, .ui.label.events.failure {
  background-color: var(--color-failed);
}

/* Status Colors - Changed */
.ui.header.changed, .ui.line.changed {
  color: var(--color-changed);
}

.ui.label.changed, .ui.label.success, .ui.label.events.success {
  background-color: var(--color-changed);
}

/* Status Colors - Unreported */
.ui.header.unreported {
  color: var(--color-unreported);
}

.ui.label.unreported {
  background-color: var(--color-unreported);
}

/* Status Colors - Noop */
.ui.header.noop {
  color: var(--color-noop);
}

.ui.label.noop, .ui.label.events.noop {
  background-color: var(--color-noop);
}

/* Status Colors - Total */
.ui.label.resources.total, .ui.label.nodes.total {
  background-color: var(--color-total);
}

/* Status Colors - Unchanged */
.ui.header.unchanged {
  color: var(--color-unchanged);
}

.ui.label.unchanged {
  background-color: var(--color-unchanged);
}

/* Status Colors - Skipped */
.ui.line.skipped {
  color: var(--color-skipped);
}

.ui.label.skipped, .ui.label.resources.skipped {
  background-color: var(--color-skipped);
}

.count {
  width: 4em;
  text-align: center;
  display: block;
}

.absolute {
  position: fixed;
  bottom: 0;
  width: 100%;
  background: var(--color-footer-bg);
}

.absolute div {
  padding: 1em;
}

/* Darkblue Theme */
.ui.menu.darkblue {
  background-color: var(--color-darkblue);
  border-radius: 0px !important;
}

.ui.darkblue.header, i.darkblue {
  color: var(--color-darkblue);
}

/* Overview page statistics - make population/resources numbers more readable */
.ui.header.darkblue.no-margin-bottom {
  color: #1a1a1a;
  font-weight: 600;
}

[data-theme="dark"] .ui.header.darkblue.no-margin-bottom {
  color: var(--color-text);
}

.ui.labels .darkblue.label::before, .ui.darkblue.labels .label::before, .ui.darkblue.label::before {
  background-color: var(--color-darkblue);
}

.ui.darkblue.labels .label, .ui.darkblue.label {
  background-color: var(--color-darkblue);
  border-color: var(--color-darkblue);
  color: #FFF;
}

/* Yellow Theme */
.ui.menu.yellow {
  background-color: var(--color-yellow);
}

.ui.yellow.header, i.yellow {
  color: var(--color-yellow);
}

.ui.labels .yellow.label::before, .ui.yellow.labels .label::before, .ui.yellow.label::before {
  background-color: var(--color-yellow);
}

.ui.yellow.labels .label, .ui.yellow.label {
  background-color: var(--color-yellow);
  border-color: var(--color-yellow);
}

/* Scroll Button */
#scroll-btn-top {
  position: fixed;
  overflow: hidden;
  z-index: 99999999;
  opacity: 0;
  visibility: hidden;
  width: 50px;
  height: 48px;
  line-height: 48px;
  right: 30px;
  bottom: 85px;
  padding-top: 2px;
  background-color: var(--color-scroll-btn);
  text-align: center;
  color: var(--color-scroll-btn-text);
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  border-bottom-right-radius: 10px;
  border-bottom-left-radius: 10px;
  -webkit-transition: all 0.5s ease-in-out;
  -moz-transition: all 0.5s ease-in-out;
  -ms-transition: all 0.5s ease-in-out;
  -o-transition: all 0.5s ease-in-out;
  transition: all 0.5s ease-in-out;
}

#scroll-btn-top:hover {
  background-color: var(--color-scroll-btn-hover);
}

#scroll-btn-top.show {
  visibility: visible;
  cursor: pointer;
  opacity: 1.0;
}

#scroll-btn-top i {
  position: absolute;
  top: 50%;
  left: 50%;
  margin: 0;
  margin-right: -50%;
  transform: translate(-50%, -50%)
}

#dailyReportsChartContainer {
  height: 160px;
}

/* JSON Syntax Highlighting */
pre.json {
  padding: 0;
  margin: 0;
  font-family: "Open Sans", sans-serif;
}

.string {
  color: var(--color-json-string);
}
a .string:hover {
  color: var(--color-json-string-hover);
}
.number {
  color: var(--color-json-number);
}
a .number:hover {
  color: var(--color-json-number-hover);
}
.boolean {
  color: var(--color-json-boolean);
}
a .boolean:hover {
  color: var(--color-json-boolean-hover);
}
.key {
  color: var(--color-json-key);
}
a .key:hover {
  color: var(--color-json-key-hover);
}
.null {
  color: var(--color-json-null);
}

textarea, /* query */
pre.result,
pre.error_message,
td.error_message,
td.code {
  font-family: "Cousine", monospace;
  font-size: 1rem;
}

.warning_message,
.info_message {
  font-size: 1rem;
}

#friendly_div {
  margin-bottom: 1em;
}

.ui.inverted.menu .active.item {
  background:rgba(255,255,255,.15);
  color:#fff!important
}

.ui.inverted.menu .active.item:hover {
  background:rgba(255,255,255,.15);
  color:#fff!important
}

.dataTables_length > label {
  margin-right: 1em;
}

#facts_table td {
  vertical-align: top;
}

/* Theme Toggle Button */
#theme-toggle {
  background: transparent;
  border: none;
  padding: 0.5em;
  cursor: pointer;
  color: #fff;
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

#theme-toggle:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}

#theme-toggle i {
  margin: 0;
}
