/* =========================
   TYPOGRAPHY / TEXT BLOCKS
========================= */

.title {
  font-size: medium;
  font-weight: 500;
  margin: 0 0 0.25rem;
}

.text p {
  font-size: small;
  text-align: justify;
  line-height: 1.25;
}

.error-msg {
  font-size: small;
  color: #c0392b;
  margin-top: 6px;
}

.meta {
  margin-top: 8px;
  font-size: x-small;
  color: #666;
  line-height: 1.6;
}

.meta-key {
  font-weight: 700;
  margin-right: 4px;
}

/* =========================
   LEGEND PANEL
========================= */

.raster-legend {
  position: absolute;
  top: 0.8em;
  right: 0.8em;
  z-index: 150;

  width: 260px;
  max-width: 260px;

  display: flex;
  flex-direction: column;
  gap: 12px;

  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(6px);

  padding: 12px;
  border-radius: 10px;

  box-shadow:
    0 2px 10px rgba(0, 0, 0, 0.14),
    0 1px 3px rgba(0, 0, 0, 0.08);

  font-family: Marianne, Arial, sans-serif;
  font-size: 0.85em;
}

.raster-legend-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 2px;
  color: #111;
}

/* =========================
   LEGEND SECTIONS
========================= */

.legend-section {
  display: flex;
  flex-direction: column;
  gap: 3px;

  margin-top: 4px;
}

.legend-section label {
  font-size: 12px;
  font-weight: 600;
  color: #444;

  margin-bottom: 1px;
}

/* =========================
   INPUTS / SELECTS
========================= */

.ui-input {
  width: 100%;
  box-sizing: border-box;

  padding: 0.42em 0.55em;

  border-radius: 6px;
  border: 1px solid #d5d5d5;

  background: white;

  font-family: Marianne, Arial, sans-serif;
  font-size: 0.85em;

  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.ui-input:focus {
  outline: none;
  border-color: var(--theme-color);
  box-shadow: 0 0 0 2px rgba(195, 98, 24, 0.12);
}

#legend-asset-select,
#legend-colormap-select {
  width: 100%;
}

/* =========================
   UNIFIED RANGE SLIDERS (FILLED STYLE)
========================= */

#legend-opacity-slider,
input[type="range"] {
  --value: 0%;

  width: 100%;
  margin: 8px 0;

  appearance: none;
  -webkit-appearance: none;

  background: transparent;
}

/* =========================
   TRACK (CHROME / SAFARI)
========================= */

#legend-opacity-slider::-webkit-slider-runnable-track,
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;

  background: linear-gradient(
    to right,
    var(--theme-color) 0%,
    var(--theme-color) var(--value),
    rgba(0, 0, 0, 0.08) var(--value),
    rgba(0, 0, 0, 0.08) 100%
  );
}

/* =========================
   TRACK (FIREFOX BASE)
========================= */

#legend-opacity-slider::-moz-range-track,
input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;

  background: rgba(0, 0, 0, 0.08);
}

/* Firefox filled portion (equivalent to noUi connect) */
#legend-opacity-slider::-moz-range-progress,
input[type="range"]::-moz-range-progress {
  height: 6px;
  border-radius: 999px;

  background: var(--theme-color);
}

/* =========================
   THUMB (CHROME / SAFARI)
========================= */

#legend-opacity-slider::-webkit-slider-thumb,
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;

  width: 12px;
  height: 12px;

  margin-top: -3px;

  border-radius: 50%;
  border: 2px solid var(--theme-color);
  background: white;

  cursor: grab;

  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

/* =========================
   THUMB (FIREFOX)
========================= */

#legend-opacity-slider::-moz-range-thumb,
input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;

  border-radius: 50%;
  border: 2px solid var(--theme-color);
  background: white;

  cursor: grab;

  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

/* =========================
   ACTIVE STATE
========================= */

#legend-opacity-slider:active::-webkit-slider-thumb,
input[type="range"]:active::-webkit-slider-thumb {
  cursor: grabbing;
}

#legend-opacity-slider:active::-moz-range-thumb,
input[type="range"]:active::-moz-range-thumb {
  cursor: grabbing;
}

/* =========================
   COLOR GRADIENT
========================= */

.raster-legend-gradient {
  width: 100%;
  height: 14px;

  border-radius: 5px;
  border: 1px solid #d5d5d5;
}

/* =========================
   RANGE SLIDER
========================= */

.legend-range-slider,
#legend-slider {
  margin: 8px 0;
}

.legend-range-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.legend-apply-btn {
  width: 100%;
}

/* =========================
   HISTOGRAM
========================= */

.legend-histogram {
  display: flex;
  align-items: flex-end;
  gap: 1px;

  width: 100%;
  height: 64px;

  margin-top: 6px;
}

.legend-histogram-bar {
  flex: 1;
  min-width: 1px;

  background: #666;
  opacity: 0.9;

  border-radius: 1px 1px 0 0;
}

/* =========================
   STATS
========================= */

.legend-stats {
  display: flex;
  flex-direction: column;
  gap: 5px;

  padding-top: 4px;

  font-size: 12px;
}

.legend-stats div {
  display: flex;
  justify-content: space-between;
  align-items: center;

  gap: 12px;
}

.legend-stats span {
  color: #666;
}

.legend-stats strong {
  font-weight: 600;
  color: #111;
}

/* =========================
   NOUISLIDER
========================= */

.noUi-target {
  border: none;
  box-shadow: none;

  background: rgba(0, 0, 0, 0.08);

  height: 6px;
}

.noUi-connect {
  background: var(--theme-color);
}

.noUi-handle {
  width: 16px !important;
  height: 16px !important;

  right: -8px !important;
  top: -5px !important;

  border-radius: 50%;
  border: 2px solid var(--theme-color);

  background: white;
  box-shadow: none;

  cursor: grab;
}

.noUi-handle:active {
  cursor: grabbing;
}

.noUi-handle::before,
.noUi-handle::after {
  display: none;
}

/* =========================
   BUTTONS
========================= */

.ui-btn {
  padding: 0.45em 0.7em;

  border-radius: 6px;
  border: 1px solid #d0d0d0;

  background: white;
  color: #111;

  font-family: Marianne, Arial, sans-serif;
  font-size: 0.85em;
  font-weight: 600;

  cursor: pointer;

  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.1s ease;
}

.ui-btn:hover {
  background: #f6f6f6;
}

.ui-btn:active {
  transform: scale(0.98);
}

.ui-btn-primary {
  border-color: var(--theme-color);
  color: var(--theme-color);
  background-color: white;
}

.ui-btn-primary:hover {
  background-color: var(--theme-color);
  color: white;
}

/* =========================
   BASEMAP CONTROL
========================= */

.ui-basemap-panel {
  position: absolute;
  bottom: 0.8em;
  left: 0.8em;
  z-index: 1000;
  display: flex;
  gap: 6px;
  align-items: center;
}

.basemap-btn.active {
  background: var(--theme-color);
  border-color: var(--theme-color);
  color: white;
}

.ui-panel .ui-btn {
  width: auto;
  height: auto;

  flex: 0 0 auto;
  align-self: center;
  line-height: 1;
}

.ui-popup-panel {
  position: absolute;
  top: 0.8em;
  left: 0.8em;

  display: flex;
  flex-direction: column;
  gap: 6px;

  z-index: 50;
}

.pixel-toggle-btn {
  width: auto;
  z-index: 1000;
}

.pixel-toggle-btn.active {
  background: var(--theme-color);
  border-color: var(--theme-color);
  color: white;
}

.ui-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.stats-compare-grid {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  font-size: 11px;
  border-top: 1px dashed #555;
  padding-top: 6px;
}

.stats-col {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  padding: 6px;
  border-radius: 4px;
  line-height: 1.4;
}

.stats-col strong {
  display: inline-block;
  margin-bottom: 4px;
}

/* =========================
   COLLAPSIBLE SECTIONS
========================= */

.legend-collapsible-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: #444;
  user-select: none;
  margin-top: 4px;
}

.legend-collapsible-toggle .toggle-arrow {
  font-size: 10px;
  transition: transform 0.2s ease;
}

.legend-collapsible-toggle.open .toggle-arrow {
  transform: rotate(180deg);
}

.legend-collapsible-content {
  display: none;
}

.legend-collapsible-content.open {
  display: block;
}