/* Default to dark mode - prevents white flash */
html:not([data-bs-theme="light"]) {
  background-color: #151f2c !important;
  color-scheme: dark;
}

html:not([data-bs-theme="light"]) body {
  background-color: #151f2c !important;
  color: #ffffff !important;
}

/* Dark mode for Tabler components - prevents flash */
html:not([data-bs-theme="light"]) .card {
  background-color: #232e3c !important;
  border-color: #2d3748 !important;
  color: #ffffff !important;
}

html:not([data-bs-theme="light"]) .navbar {
  background-color: #1d273b !important;
  border-color: #2d3748 !important;
}

html:not([data-bs-theme="light"]) .table {
  color: #ffffff !important;
}

html:not([data-bs-theme="light"]) .card-header {
  background-color: transparent !important;
  border-color: #2d3748 !important;
  color: #ffffff !important;
}

html:not([data-bs-theme="light"]) .page-wrapper {
  background-color: #151f2c !important;
}

html:not([data-bs-theme="light"]) .form-control,
html:not([data-bs-theme="light"]) .form-select {
  background-color: #1d273b !important;
  border-color: #2d3748 !important;
  color: #ffffff !important;
}

/* Cross-browser select arrow via wrapper ::after */
.select-wrapper {
  position: relative;
}

.select-wrapper .form-select {
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  background-image: none !important;
  padding-right: 2.25rem !important;
}

.select-wrapper::after {
  content: "";
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid #6c757d;
  pointer-events: none;
}

html:not([data-bs-theme="light"]) .select-wrapper::after {
  border-top-color: #adb5bd;
}

html:not([data-bs-theme="light"]) .dropdown-menu {
  background-color: #232e3c !important;
  border-color: #2d3748 !important;
}

html:not([data-bs-theme="light"]) .dropdown-item {
  color: #ffffff !important;
}

html:not([data-bs-theme="light"]) .list-group-item {
  background-color: transparent !important;
  border-color: #2d3748 !important;
  color: #ffffff !important;
}

html:not([data-bs-theme="light"]) .btn {
  background-color: #1d273b !important;
  border-color: #2d3748 !important;
  color: #ffffff !important;
}

html:not([data-bs-theme="light"]) .btn:hover {
  background-color: #232e3c !important;
}

html:not([data-bs-theme="light"]) .btn-primary {
  background-color: #f59f00 !important;
  border-color: #f59f00 !important;
  color: #000000 !important;
}

html:not([data-bs-theme="light"]) .btn-check:checked + .btn {
  background-color: #f59f00 !important;
  border-color: #f59f00 !important;
  color: #000000 !important;
}

html:not([data-bs-theme="light"]) .page-header {
  background-color: transparent !important;
}

html:not([data-bs-theme="light"]) .page-title {
  color: #ffffff !important;
}

.navbar-brand-image {
  filter: none !important;
}

/* Dynamic Logo Visibility */
/* Default (Dark Mode) */
.logo-light {
  display: none !important;
}
.logo-dark {
  display: block !important;
}

/* Light Mode Override */
html[data-bs-theme="light"] .logo-light {
  display: block !important;
}
html[data-bs-theme="light"] .logo-dark {
  display: none !important;
}

:root {
  --tblr-primary: #f59f00;
}

/* Universal slider style: all native range inputs get the same bar & ball */
input.form-range {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}

input.form-range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: #dee2e6;
}

input.form-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border: none;
  border-radius: 50%;
  background: #f59f00;
  cursor: pointer;
}

input.form-range::-moz-range-track {
  height: 4px;
  border: none;
  border-radius: 2px;
  background: #dee2e6;
}

input.form-range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 50%;
  background: #f59f00;
  cursor: pointer;
}

/* Left-fill override for Max Rain / Max Wind sliders */
input.filled-left {
  --range-progress: 50%;
}

input.filled-left::-webkit-slider-runnable-track {
  background: linear-gradient(
    to right,
    #f59f00 0%,
    #f59f00 var(--range-progress),
    #dee2e6 var(--range-progress),
    #dee2e6 100%
  );
}

input.filled-left::-moz-range-progress {
  height: 4px;
  border-radius: 2px;
  background: #f59f00;
}

#manualControls.controls-disabled {
  opacity: 0.45;
}

/* Keep switch thumb visible in both states */
.form-switch-3 .form-check-input {
  border: none !important;
  background-color: #dee2e6;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23adb5bd'/%3e%3c/svg%3e") !important;
  background-position: left 0.125rem center;
  background-size: 1.125rem;
  background-repeat: no-repeat;
  transition: background-position 0.15s ease-in-out, background-color 0.15s ease-in-out, background-image 0.15s ease-in-out;
}

.form-switch-3 .form-check-input:checked {
  border: none !important;
  background-color: #f59f00;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23ffffff'/%3e%3c/svg%3e") !important;
  background-position: right 0.125rem center;
  background-size: 1.125rem;
  background-repeat: no-repeat;
}

.history-chart svg {
  width: 100%;
  height: 240px;
  display: block;
}

.history-chart .grid-line {
  stroke: #dfe3e7;
  stroke-dasharray: 4 4;
  stroke-width: 1;
}

.history-chart .axis-label {
  fill: #6c757d;
  font-size: 11px;
}

.history-chart .history-line {
  fill: none;
  stroke: #f59f00;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.history-chart .history-point {
  fill: #f59f00;
}

/* Robust noUiSlider Customization */
html body .noUi-target {
    background: #dee2e6;
    border: none;
    border-radius: 2px;
    box-shadow: none;
    height: 4px;
    /* Remove custom margins to align with native inputs */
    margin: 0;
}

html body .noUi-connect {
    background: #f59f00;
}

/* The handle itself — matches native slider thumbs */
html body .noUi-horizontal .noUi-handle {
    width: 16px;
    height: 16px;
    right: -8px;
    top: -6px;
    border: none;
    border-radius: 50%;
    background: #f59f00;
    cursor: pointer;
    box-shadow: none;
    outline: none;
}

/* Remove default pseudo-elements */
html body .noUi-handle:before,
html body .noUi-handle:after {
    display: none;
}

/* Active/Hover states */
html body .noUi-handle:hover,
html body .noUi-handle:active {
    transform: scale(1.1);
    background: #f59f00;
}

/* Remove any potential tooltips causing layout jumps if not wanted,
   though user didn't complain about them. Kept simple. */
html body .noUi-tooltip {
    display: none; /* Hide internal noUiSlider tooltips if they look ugly; we rely on the text below or simple aesthetics */
}

.chart-tooltip {
  display: none;
  position: absolute;
  background: #ffffff;
  color: #1e293b;
  padding: 4px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  z-index: 1000;
  pointer-events: none;
  font-size: 12px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
