/* Dark theme styles for the Beard Guard page and its Picture-in-Picture mini window. */

:root {
  color-scheme: dark;
  --background: #0f1115;
  --surface: #181b22;
  --surface-raised: #222632;
  --border: #2c3140;
  --text: #e6e8ee;
  --text-muted: #8b92a5;
  --accent: #60a5fa;
  --accent-strong: #3b82f6;
  --warning: #facc15;
  --danger: #f87171;
  --success: #4ade80;
  --radius: 12px;
  --chart-series-1: #3987e5;
  --chart-series-1-hover: #6da7ec;
  --chart-series-2: #d95926;
  --chart-grid: #2c3140;
  --chart-baseline: #3d4356;
  --delta-good: #0ca30c;
  --delta-bad: #e66767;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--text);
  line-height: 1.45;
}

[hidden] {
  display: none !important;
}

h1, h2 {
  margin: 0;
  font-weight: 600;
}

h2 {
  font-size: 0.95rem;
  margin-bottom: 0.6rem;
}

button,
select {
  font: inherit;
  color: var(--text);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.primary {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  font-weight: 600;
  min-width: 6rem;
}

button.danger:hover:not(:disabled) {
  border-color: var(--danger);
  color: var(--danger);
}

.link-button {
  background: none;
  border: none;
  padding: 0;
  text-decoration: underline;
  color: inherit;
}

.muted {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1rem 0.75rem;
}

.privacy-note {
  margin: 0;
  color: var(--success);
  font-size: 0.9rem;
}

.banner {
  max-width: 1100px;
  margin: 0.5rem auto;
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
}

.banner.warning {
  background: rgba(250, 204, 21, 0.12);
  border: 1px solid rgba(250, 204, 21, 0.4);
}

.banner.error {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.45);
}

.layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.5rem 1rem 2rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 820px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

.video-frame {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.video-frame video,
.video-frame canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: scaleX(-1);
}

.camera-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  color: var(--text-muted);
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin: 0.75rem 0;
}

.status-pill {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.status-pill[data-status="idle"] {
  color: var(--accent);
}

.status-pill[data-status="near"] {
  color: var(--warning);
  border-color: rgba(250, 204, 21, 0.5);
}

.status-pill[data-status="picking"],
.status-pill[data-status="alarm"] {
  color: var(--background);
  background: var(--danger);
  border-color: var(--danger);
}

.status-pill[data-status="alarm"] {
  animation: alarm-pulse 1.2s ease-in-out infinite;
}

@keyframes alarm-pulse {
  50% {
    opacity: 0.55;
  }
}

.debug-metrics {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.checkbox input {
  accent-color: var(--accent);
  width: 1rem;
  height: 1rem;
}

.sidebar {
  display: grid;
  gap: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.count-card {
  text-align: center;
}

.today-count {
  font-size: 4rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.settings summary {
  cursor: pointer;
  font-weight: 600;
}

.settings[open] summary {
  margin-bottom: 0.75rem;
}

.settings {
  display: grid;
}

.settings[open] > *:not(summary) {
  margin-bottom: 0.85rem;
}

.settings[open] > *:last-child {
  margin-bottom: 0;
}

.field {
  display: grid;
  gap: 0.35rem;
  font-size: 0.9rem;
}

.field > span {
  display: flex;
  justify-content: space-between;
}

.field output {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.field input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.event-list {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
  max-height: 220px;
  overflow-y: auto;
  font-variant-numeric: tabular-nums;
}

.event-list li {
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border);
}

.log-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.diagnostics .muted + .muted {
  margin-top: 0.5rem;
}

.background-report {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  font-size: 0.8rem;
  display: grid;
  gap: 0.4rem;
}

.background-report li {
  padding-left: 0.6rem;
  border-left: 3px solid var(--border);
}

.background-report li.passed {
  border-left-color: var(--success);
}

.background-report li.failed {
  border-left-color: var(--danger);
}

.flash-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  border: 10px solid var(--danger);
  box-shadow: inset 0 0 40px rgba(248, 113, 113, 0.6);
  opacity: 0;
  z-index: 10;
}

body.mini-window {
  min-height: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.mini-video-frame {
  flex: 1;
  min-height: 0;
  background: #000;
}

.mini-video-frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  display: block;
}

body.mini-window {
  cursor: pointer;
}

body.mini-window.compact .mini-video-frame {
  display: none;
}

body.mini-window.compact .mini-info {
  flex: 1;
}

.mini-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  font-size: 0.85rem;
}

.mini-count strong {
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
}

body:not([data-mode="web"]) .web-only,
body[data-mode="web"] .desktop-only,
body[data-mode="dashboard"] .overlay-root,
body[data-mode="web"] .overlay-root {
  display: none !important;
}

.desktop-note {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
}

.trends,
.perf {
  grid-column: 1 / -1;
}

.section-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
}

.section-header h2 {
  margin: 0;
}

.range-presets {
  display: inline-flex;
  gap: 0.25rem;
}

.range-presets button {
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
}

.range-presets button[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat-tile {
  background: var(--surface-raised);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
}

.stat-label,
.stat-detail {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 600;
  line-height: 1.2;
}

.stat-delta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.stat-delta[data-direction="down"] {
  color: var(--delta-good);
}

.stat-delta[data-direction="up"] {
  color: var(--delta-bad);
}

.chart {
  position: relative;
  margin: 0 0 1rem;
}

.chart-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
}

.chart-title {
  font-weight: 600;
}

.chart-legend {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.9rem;
  color: var(--text-muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-swatch.bar {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--chart-series-1);
}

.legend-swatch.line {
  width: 14px;
  height: 2px;
  border-radius: 1px;
  background: var(--chart-series-2);
}

.chart-body svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart-body svg:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.chart .gridline {
  stroke: var(--chart-grid);
  stroke-width: 1;
}

.chart .baseline {
  stroke: var(--chart-baseline);
  stroke-width: 1;
}

.chart .axis-label {
  fill: var(--text-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chart .end-label {
  fill: var(--text);
  font-size: 11px;
  font-weight: 600;
}

.chart .bar {
  fill: var(--chart-series-1);
}

.chart .bar.is-hovered {
  fill: var(--chart-series-1-hover);
}

.chart .trend-line {
  fill: none;
  stroke: var(--chart-series-2);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart .trend-dot {
  fill: var(--chart-series-2);
  stroke: var(--surface);
  stroke-width: 2;
}

.chart .crosshair {
  stroke: var(--text-muted);
  stroke-width: 1;
  pointer-events: none;
}

.chart-tooltip {
  position: absolute;
  top: 1.5rem;
  z-index: 5;
  pointer-events: none;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font-size: 0.8rem;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.tooltip-title {
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.tooltip-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tooltip-value {
  font-weight: 600;
}

.tooltip-detail {
  color: var(--text-muted);
}

.tooltip-key {
  width: 12px;
  height: 2px;
  border-radius: 1px;
}

.tooltip-key.bar {
  background: var(--chart-series-1);
}

.tooltip-key.line {
  background: var(--chart-series-2);
}

.table-view summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.table-view table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.table-view th,
.table-view td {
  text-align: left;
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.table-view th {
  color: var(--text-muted);
  font-weight: 500;
}

.perf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
  margin: 0 0 0.75rem;
}

.perf-grid dt {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.perf-grid dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.perf-actions {
  display: flex;
  gap: 0.5rem;
}

body[data-mode="overlay"] {
  min-height: 0;
  height: 100vh;
  overflow: hidden;
  user-select: none;
}

body[data-mode="overlay"] > :not(.overlay-root, .flash-overlay, script, template) {
  display: none !important;
}

.overlay-root,
.overlay-root .mini-ui {
  height: 100%;
}

.overlay-root .mini-ui {
  display: flex;
  flex-direction: column;
}

body[data-mode="overlay"]:not(.preview) .mini-video-frame {
  display: none;
}

.overlay-root .mini-video-frame {
  position: relative;
}

.overlay-root .video-frame {
  display: block !important;
  height: 100%;
  border: 0;
  border-radius: 0;
}

.overlay-root .camera-placeholder {
  display: none;
}

.overlay-root .mini-info {
  flex: 1;
}

.overlay-root .status-pill {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}
