@import url('https://klimaforum-kiel.de/lib/css/fonts.css');

/* =========================================================
   1) THEME / TYPOGRAPHY
   ========================================================= */

:root,
[data-bs-theme='light'] {
  --bs-font-sans-serif: 'laca', sans-serif;
}

pre,
code,
table th,
table td {
  font-family: var(--bs-font-monospace);
}

/* Globale Textauswahl und Maus deaktivieren */
html.touch,
body.touch,
body.touch * {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  -webkit-touch-callout: none;
  cursor: none !important;
}


/* =========================================================
   2) LAYOUT: HEADER + PAGE BASICS
   ========================================================= */

header {
  background-color: var(--bs-body-bg);
  border: none !important;
}

.site-header {
  background-color: rgba(var(--bs-body-bg-rgb), 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.site-header-inner {
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

header h1 {
  font-size: 2.2rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 400;
}

header nav {
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

header nav a {
  color: var(--bs-link-color);
  text-decoration: none;
  font-weight: 500;
}

header nav i {
  color: inherit;
}

label i {
  color: var(--bs-secondary-color);
}

.alert {
  font-size: 0.95rem;
}

pre {
  color: var(--bs-danger-text-emphasis);
  white-space: pre-wrap;
  word-break: break-word;
}

/* =========================================================
   3) TREE / SENSOR CONTAINERS
   ========================================================= */

.device-block {
  background-color: rgba(0, 108, 165, 0.03);
  border-radius: 1rem;
}

.chart-panel {
  background-color: var(--bs-body-bg);
  border-radius: 0.85rem;
}

.tree-controls-header {
  padding: 1.5rem;
  background: transparent;
  box-shadow: none;
  border: 0;
}

.sensor-meta-grid {
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--bs-secondary-color);
}

.sensor-meta-row {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  align-items: center;
  column-gap: 0.45rem;
  justify-items: start;
}

.sensor-meta-label {
  font-weight: 600;
  color: var(--bs-body-color);
}

.sensor-meta-value {
  text-align: left;
}

.sensor-meta-value-with-dot {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.sensor-status-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--bs-secondary-color);
  opacity: 0.35;
}

.sensor-status-dot.is-active {
  background: var(--bs-primary);
  opacity: 1;
  animation: sensor-pulse 1.8s ease-in-out infinite;
}

@keyframes sensor-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(var(--bs-primary-rgb), 0.5);
  }
  70% {
    box-shadow: 0 0 0 0.45rem rgba(var(--bs-primary-rgb), 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(var(--bs-primary-rgb), 0);
  }
}

/* =========================================================
   4) ACCORDION + TABLE DATA
   ========================================================= */

.accordion {
  --bs-accordion-active-bg: var(--bs-primary-bg-subtle);
  --bs-accordion-active-color: var(--bs-primary-text-emphasis);
  --bs-accordion-border-color: var(--bs-border-color);
  --bs-accordion-btn-focus-border-color: var(--bs-primary-border-subtle);
  --bs-accordion-btn-focus-box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.2);
}

.accordion-button:not(.collapsed) {
  font-weight: 600;
}

table th,
table td {
  font-size: 0.75rem;
  font-weight: lighter;
  white-space: nowrap;
}

table th {
  text-align: left;
}

table td {
  text-align: right;
}

table td.time_at,
table td.tree_id,
table td.app_id,
table td.weather_id,
table th.gateway,
table td.gateway {
  text-align: left;
}

/* =========================================================
   5) WEATHER WIDGET
   ========================================================= */

.weather-card {
  font-size: 0.79rem;
}

.weather-card-header {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.weather-card-icon {
  font-size: 2rem;
  line-height: 1;
  flex-shrink: 0;
}

.weather-station-name {
  display: block;
}

.weather-condition-text {
  font-size: 0.7rem;
  color: var(--bs-secondary-color);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.weather-rows {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.weather-row {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  line-height: 1.35;
}

.wrow-icon {
  font-size: 0.95rem;
  color: var(--bs-secondary-color);
  width: 1.1rem;
  text-align: center;
  flex-shrink: 0;
}

.wrow-val {
  font-size: 0.79rem;
  font-weight: 500;
  color: var(--bs-body-color);
  white-space: nowrap;
}

.weather-interval {
  font-size: 0.7rem;
  color: var(--bs-secondary-color);
  font-weight: 400;
}

.tree-image-trigger {
  display: inline-block;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: zoom-in;
}

.tree-image-thumb {
  box-shadow: 0 0.35rem 1rem rgba(0, 0, 0, 0.14);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.tree-image-trigger:hover .tree-image-thumb,
.tree-image-trigger:focus-visible .tree-image-thumb {
  transform: translateY(-1px) scale(1.015);
  box-shadow: 0 0.65rem 1.2rem rgba(0, 0, 0, 0.2);
}

.tree-image-modal-content {
  background: rgba(var(--bs-body-bg-rgb), 0.92);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: 0.9rem;
}

.tree-image-modal-header {
  padding-bottom: 0.5rem;
}

.tree-image-modal-img {
  display: block;
  width: 100%;
  max-height: calc(100vh - 10rem);
  object-fit: contain;
  border-radius: 0.6rem;
}

/* =========================================================
   6) CHARTS
   ========================================================= */

.chart-canvas-wrap {
  width: 100%;
  aspect-ratio: 3 / 2;
}

.chart-canvas-wrap-compact {
  height: 240px;
}

.chart-canvas-wrap-wide {
  height: 380px;
}

.scale-toggle {
  font-size: 0.65rem;
  padding: 0.15rem 0.45rem;
  line-height: 1.2;
  flex-shrink: 0;
}

/* =========================================================
   7) MAP
   ========================================================= */

.map-box {
  width: 100%;
  aspect-ratio: 3 / 2;
  border-radius: 6px;
}

.map-ctrl-group {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  margin-bottom: 6px !important;
}

.map-ctrl-btn {
  display: block !important;
  line-height: 30px !important;
  text-align: center !important;
  cursor: pointer !important;
  margin-bottom: 4px !important;
  text-decoration: none !important;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.map-ctrl-btn i.bi::before {
  font-size: 18px !important;
  color: var(--bs-body-color) !important;
  border: 1px solid var(--bs-border-color) !important;
  background: rgba(var(--bs-body-bg-rgb), 0.7) !important;
  border-radius: 4px !important;
  padding: 4px !important;
}

.map-ctrl-btn:last-child {
  margin-bottom: 0 !important;
}

.map-ctrl-btn:hover i.bi::before {
  background: rgba(var(--bs-body-bg-rgb), 0.85) !important;
  text-decoration: none !important;
}

.map-ctrl-btn.active i.bi::before {
  background: rgba(var(--bs-body-bg-rgb), 1) !important;
  text-decoration: none !important;
}

/* =========================================================
   8) RESPONSIVE
   ========================================================= */

@media (max-width: 768px) {
  body {
    font-size: 0.95rem;
  }

  .container-fluid {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .site-header-inner {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .sensor-meta-row {
    grid-template-columns: 6.75rem minmax(0, 1fr);
  }

  .tree-image-modal-img {
    max-height: calc(100vh - 8rem);
  }

  table {
    font-size: 0.8rem;
  }

  pre {
    font-size: 0.75rem;
  }
}
