/* =========================================================
   BirdPI – Page Styles: Viewport
   ========================================================= */

body.page-viewport .wrap.fullheight {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 100vw;
  overflow: hidden;
}

/* --- Kopfbereich --- */
.page-viewport .head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}
.page-viewport .head .controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--grid);
  border-radius: var(--radius);
  padding: 8px 12px;
  flex-grow: 1;
}
.page-viewport .head .small { font-size: 12px; color: var(--muted); }

/* --- Tabs --- */
.tab-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.tab-nav {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--grid);
}
.tab-btn {
  padding: 8px 14px;
  cursor: pointer;
  background: none;
  border: none;
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s ease, border-color .15s ease;
}
.tab-btn:hover { color: var(--fg); }
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab-content {
  flex: 1;
  min-height: 0;
}
.tab-pane {
  display: none;
  height: 100%;
}
.tab-pane.active {
  display: flex;
  flex-direction: column;
}

/* --- Panes --- */
.pane {
  background: var(--card);
  border: 1px solid var(--grid);
  border-radius: var(--radius);
  padding: 8px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}
.pane .pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0 10px 0;
  border-bottom: 1px solid var(--grid);
  margin-bottom: 8px;
}
.pane .pane-title { font-weight: 600; }

/* --- Tabelle --- */
.table-wrap {
  overflow: auto;
  flex: 1;
  min-height: 0;
}
table.fixed { width: 100%; border-collapse: collapse; border-spacing: 0; }
table.fixed th, table.fixed td { padding: 8px 10px; border-bottom: 1px solid var(--grid); text-align: left; }
table.fixed th {
  height: var(--tbl-h);
  font-size: 12px;
  color: var(--muted);
  background: var(--tbl-b);
  position: sticky;
  top: 0;
  z-index: 5;
  box-shadow: 0 1px 0 var(--grid);
}
table.fixed tr:nth-child(even) { background: var(--row-alt); }

/* --- Plot-Container --- */
.plot-wrap {
  position: relative;
  flex: 1;
  min-height: 200px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#chart-canvas,
#time-chart-canvas,
#species-chart-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* --- Heatmap Kalender --- */
.heatmap-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 8px;
}
.heatmap-controls h3 {
  margin: 0;
  font-size: 1.1em;
}
.heatmap-controls button {
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--grid);
  border-radius: var(--radius);
  padding: 2px 8px;
  font-size: 24px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s ease;
}
.heatmap-controls button:hover {
  border-color: var(--accent);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 1fr;
  gap: 4px;
  width: 100%;
  height: 100%;
}
.calendar-day {
  background: var(--card);
  border: 1px solid var(--grid);
  border-radius: 4px;
  padding: 4px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.calendar-day.has-data { color: var(--bg); }
.day-number { font-weight: bold; }
.day-detections { font-size: 0.9em; }
.weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  font-weight: bold;
  text-align: center;
  margin-bottom: 4px;
  font-size: 12px;
}

/* --- Heatmap Table (legacy) --- */
.heatmap-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.heatmap-table th, .heatmap-table td {
  border: 1px solid var(--grid);
  padding: 4px;
  text-align: center;
}
.heatmap-table th { background: var(--tbl-b); }
.heatmap-table td { min-width: 25px; }

/* --- Bubble/Network Chart --- */
#bubble-chart-container,
#network-chart-container {
  position: relative;
  width: 100%;
  height: 100%;
}

/* --- Tabellen-Spaltenbreiten --- */
#det-table { table-layout: fixed; }
#det-table th.time  { width: 18%; }
#det-table th.name  { width: 30%; }
#det-table th.cat   { width: 30%; }
#det-table th.score { width: 16%; }

/* Art-Spalte: horizontal scrollen bei langen Namen */
#det-table td.name-cell {
  max-width: 0;
  overflow-x: auto;
  white-space: nowrap;
  padding-right: 16px;
}

/* Kategorie-Label */
#det-table td.cat-cell {
  text-align: left;
}

/* --- Bottom Row --- */
.page-viewport .bottom-row {
  flex-shrink: 0;
}
.page-viewport .bottom-row .badge { background: var(--badge-bg); }
.clickable { cursor: pointer; user-select: none; }
