/* 
 * Dashboard component styles
 */

/* Cards */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border-color);
}

.card-title {
  font-family: var(--font-display);
  font-size: var(--font-size-md);
  font-weight: 500;
  color: var(--text-primary);
}

/* Stat cards (Summary style) */
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  text-align: center;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.stat-card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-md);
}

.stat-card.alert {
  border-color: var(--status-alert);
  background: var(--status-alert-soft);
}

.stat-card.warn {
  border-color: var(--status-warn);
  background: var(--status-warn-soft);
}

.stat-card.ok {
  border-color: var(--status-ok);
  background: var(--status-ok-soft);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
}

.stat-card.alert .stat-value { color: var(--status-alert); }
.stat-card.warn .stat-value { color: var(--status-warn); }
.stat-card.ok .stat-value { color: var(--status-ok); }

.stat-label {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-top: var(--space-sm);
}

.stat-sub {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

/* Unit/Bed cards */
.unit-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.unit-card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.unit-card.status-fallen {
  border-color: var(--status-alert);
  box-shadow: 0 0 0 1px var(--status-alert), var(--shadow-md);
  animation: pulse-alert 2s infinite;
}

.unit-card.status-tracking {
  border-color: var(--status-warn);
}

.unit-card.status-normal {
  border-color: var(--status-ok);
}

.unit-card.status-offline {
  opacity: 0.6;
}

@keyframes pulse-alert {
  0%, 100% { box-shadow: 0 0 0 1px var(--status-alert), 0 0 0 0 rgba(232, 93, 92, 0.4); }
  50% { box-shadow: 0 0 0 1px var(--status-alert), 0 0 0 8px rgba(232, 93, 92, 0); }
}

.unit-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-color);
}

.unit-id {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--font-size-lg);
  color: var(--text-primary);
}

.unit-voxel-meta {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-md);
  min-height: 72px;
  align-items: center;
  background: var(--bg-body);
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}

.unit-voxel-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
}

.unit-voxel-stat .label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.unit-thermal {
  height: 100px;
  background: var(--bg-body);
  display: flex;
  align-items: center;
  justify-content: center;
}

.unit-thermal canvas {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.unit-thermal .offline-icon {
  font-size: 2rem;
  color: var(--text-muted);
}

.unit-card-footer {
  padding: var(--space-md);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Status chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.chip--fall, .chip--alert {
  background: var(--status-alert-soft);
  color: var(--status-alert);
}

.chip--track, .chip--warn {
  background: var(--status-warn-soft);
  color: var(--status-warn);
}

.chip--ok {
  background: var(--status-ok-soft);
  color: var(--status-ok);
}

.chip--stale, .chip--offline {
  background: var(--status-stale-soft);
  color: var(--status-stale);
}

/* Alert cards */
.alert-card {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  transition: border-color var(--transition-fast);
}

.alert-card:hover {
  border-color: var(--border-light);
}

.alert-card.need-help {
  border-left: 3px solid var(--status-alert);
  background: var(--status-alert-soft);
}

.alert-card.no-help {
  border-left: 3px solid var(--status-ok);
}

.alert-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.alert-content {
  flex: 1;
  min-width: 0;
}

.alert-title {
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.alert-meta {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.alert-time {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-primary {
  background: var(--accent-primary);
  color: white;
}

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-alert {
  background: var(--status-alert);
  color: white;
}

.btn-outline {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-secondary);
}

.btn-outline:hover {
  border-color: var(--text-muted);
  color: var(--text-primary);
  background: var(--bg-hover);
}

.btn-sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--font-size-xs);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-elevated);
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-lg);
}

.tab {
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.tab:hover {
  color: var(--text-secondary);
}

.tab.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* Forms */
.form-group {
  margin-bottom: var(--space-lg);
}

.form-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.form-input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--font-size-md);
}

.form-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-primary-soft);
  outline: none;
}

.form-hint {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

.form-row {
  display: flex;
  gap: var(--space-md);
}

.form-row > * {
  flex: 1;
}

/* Filters */
.filters {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.filter-select {
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  min-width: 120px;
}

.filter-btn {
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-btn:hover {
  border-color: var(--border-light);
  color: var(--text-primary);
}

.filter-btn.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
}

/* Chart container */
.chart-container {
  position: relative;
  height: 220px;
}

/* HUD panel */
.hud-panel {
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-md);
}

.hud-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border-color);
}

.hud-row:last-child {
  border-bottom: none;
}

.hud-label {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hud-value {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--font-size-sm);
  color: var(--text-primary);
}

.hud-value.alert { color: var(--status-alert); }
.hud-value.warn { color: var(--status-warn); }
.hud-value.ok { color: var(--status-ok); }

/* Thermal view */
.thermal-view {
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.thermal-view canvas {
  display: block;
  width: 100%;
  image-rendering: pixelated;
}

.voxel-view {
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.voxel-view canvas {
  display: block;
  width: 100%;
}

.voxel-view--wide canvas {
  min-height: 320px;
}

.voxel-caption {
  font-size: 12px;
  margin-top: 8px;
  padding: 0 12px 12px;
}

/* Timeline */
.timeline {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.timeline-item {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.timeline-time {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 60px;
}

.timeline-content {
  flex: 1;
  font-size: var(--font-size-sm);
}

.timeline-icon {
  font-size: 1rem;
}

/* Resident card */
.resident-card {
  display: flex;
  gap: var(--space-lg);
  padding: var(--space-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
}

.resident-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  flex-shrink: 0;
}

.resident-info h3 {
  font-family: var(--font-display);
  font-size: var(--font-size-xl);
  margin-bottom: var(--space-xs);
}

.resident-meta {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
}

.resident-tags {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.tag {
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

/* Audio list */
.audio-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.audio-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.audio-item .play-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  transition: all var(--transition-fast);
}

.audio-item .play-btn:hover {
  transform: scale(1.1);
}

.audio-info {
  flex: 1;
}

.audio-name {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  color: var(--text-primary);
}

.audio-duration {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

/* Table styles */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.data-table th,
.data-table td {
  padding: var(--space-md);
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  background: var(--bg-elevated);
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background: var(--bg-hover);
}

/* Log viewer */
.log-viewer {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  max-height: 400px;
  overflow-y: auto;
  line-height: 1.8;
}

.log-line {
  display: flex;
  gap: var(--space-md);
}

.log-time {
  color: var(--text-muted);
  flex-shrink: 0;
}

.log-level {
  font-weight: 500;
  flex-shrink: 0;
  min-width: 50px;
}

.log-level.info { color: var(--status-ok); }
.log-level.warn { color: var(--status-warn); }
.log-level.error { color: var(--status-alert); }

.log-message {
  color: var(--text-secondary);
}

/* Demo toasts (non-blocking, top-right) — info/error only; fall uses fallAlert.js */
.demo-toast-root {
  position: fixed;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
  max-width: min(360px, calc(100vw - 2 * var(--space-lg)));
}

.demo-toast {
  pointer-events: auto;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-md);
  font-weight: 500;
  line-height: 1.4;
  box-shadow: var(--shadow-lg);
  border: 1px solid transparent;
  opacity: 0;
  transform: translateX(12px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  cursor: pointer;
}

.demo-toast--visible {
  opacity: 1;
  transform: translateX(0);
}

.demo-toast--fall {
  background: var(--status-alert-soft);
  border-color: var(--status-alert);
  color: var(--status-alert);
}

.demo-toast--info {
  background: var(--bg-surface);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.demo-toast--error {
  background: var(--status-alert-soft);
  border-color: var(--status-alert);
  color: var(--text-primary);
}

/* Center-screen persistent fall alert */
.fall-alert-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  background: rgba(8, 10, 14, 0.72);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.fall-alert-overlay--visible {
  opacity: 1;
  pointer-events: auto;
}

.fall-alert-card {
  width: min(520px, 92vw);
  padding: 40px 36px 32px;
  text-align: center;
  background: var(--bg-surface);
  border: 3px solid var(--status-alert);
  border-radius: var(--radius-lg);
  box-shadow:
    0 0 0 8px rgba(232, 93, 92, 0.15),
    0 24px 64px rgba(0, 0, 0, 0.45);
  animation: fall-alert-pulse 1.8s ease-in-out infinite;
}

@keyframes fall-alert-pulse {
  0%, 100% {
    box-shadow:
      0 0 0 8px rgba(232, 93, 92, 0.15),
      0 24px 64px rgba(0, 0, 0, 0.45);
  }
  50% {
    box-shadow:
      0 0 0 16px rgba(232, 93, 92, 0.08),
      0 24px 72px rgba(232, 93, 92, 0.25);
  }
}

.fall-alert-icon {
  font-size: 4.5rem;
  line-height: 1;
  margin-bottom: var(--space-md);
}

.fall-alert-title {
  font-family: var(--font-display);
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--status-alert);
  margin: 0 0 var(--space-md);
  letter-spacing: 0.04em;
}

.fall-alert-building {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--status-alert);
  margin: 0 0 var(--space-xs);
}

.fall-alert-building:empty {
  display: none;
}

.fall-alert-location {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 var(--space-xs);
}

.fall-alert-resident {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin: 0 0 var(--space-xs);
  min-height: 1.4em;
}

.fall-alert-resident:empty {
  display: none;
}

.fall-alert-time {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin: 0 0 var(--space-xl);
}

.fall-alert-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  flex-wrap: wrap;
}

.fall-alert-actions .btn {
  min-width: 140px;
  padding: 12px 24px;
  font-size: var(--font-size-md);
  font-weight: 600;
}

/* Line B room height-adaptation workspace */
.height-adapt-card .card-header p {
  margin: 4px 0 0;
}

.height-adapt-controls,
.height-adapt-modes,
.height-adapt-meta {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-bottom: var(--space-md);
}

.height-adapt-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

.height-adapt-cell input {
  width: 64px;
  padding: 6px;
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.height-adapt-meta {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

.height-adapt-meta #haExport {
  margin-left: auto;
}

.height-adapt-views {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-md);
}

.height-adapt-views h4 {
  margin: 0 0 var(--space-xs);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

.height-adapt-views canvas {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

@media (max-width: 900px) {
  .height-adapt-views {
    grid-template-columns: 1fr;
  }
}
