/* ═══════════════════════════════════════════════════════════════════════════
   LUMINA Vision Node — Stylesheet
   Medical-tech dark dashboard | Design System v1.0
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── CSS Custom Properties ──────────────────────────────────────────────── */
:root {
  /* Palette */
  --color-primary: #1e293b;
  --color-on-primary: #ffffff;
  --color-secondary: #334155;
  --color-accent: #22c55e;
  --color-accent-hover: #16a34a;
  --color-background: #0f172a;
  --color-foreground: #f8fafc;
  --color-muted: #272f42;
  --color-border: #475569;
  --color-destructive: #ef4444;
  --color-destructive-hover: #dc2626;
  --color-warning: #f59e0b;
  --color-warning-bg: rgba(245, 158, 11, 0.12);
  --color-safe: #22c55e;
  --color-safe-bg: rgba(34, 197, 94, 0.12);
  --color-danger-bg: rgba(239, 68, 68, 0.12);

  /* Typography */
  --font-heading:
    "Figtree", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-body: "Noto Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(34, 197, 94, 0.15);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Transitions */
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--color-background);
  color: var(--color-foreground);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}

/* ── Utilities ──────────────────────────────────────────────────────────── */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}

.text-muted {
  color: #94a3b8;
}
.text-sm {
  font-size: 0.8125rem;
}

.icon-sm {
  width: 18px;
  height: 18px;
  vertical-align: -3px;
}
.icon-md {
  width: 28px;
  height: 28px;
}
.icon-lg {
  width: 48px;
  height: 48px;
  color: #64748b;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-xl);
  background: linear-gradient(
    180deg,
    rgba(30, 41, 59, 0.9) 0%,
    rgba(15, 23, 42, 0.95) 100%
  );
  border-bottom: 1px solid var(--color-border);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.logo-icon svg {
  display: block;
  filter: drop-shadow(0 0 8px rgba(34, 197, 94, 0.4));
}

.logo-text {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-foreground);
  line-height: 1.2;
}

.logo-sub {
  font-weight: 400;
  color: var(--color-accent);
}

.logo-tagline {
  font-size: 0.6875rem;
  font-weight: 400;
  color: #94a3b8;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.status-badge {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--color-muted);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 500;
  border: 1px solid var(--color-border);
  transition: background var(--duration-fast) var(--ease-out);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #64748b;
  transition: background var(--duration-normal) var(--ease-out);
}

.status-dot.active {
  background: var(--color-accent);
  box-shadow: 0 0 8px var(--color-accent);
}
.status-dot.warning {
  background: var(--color-warning);
  box-shadow: 0 0 8px var(--color-warning);
}
.status-dot.danger {
  background: var(--color-destructive);
  box-shadow: 0 0 8px var(--color-destructive);
}

.header-time {
  font-size: 0.875rem;
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
}

/* ── Main Grid ──────────────────────────────────────────────────────────── */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: var(--space-lg);
  padding: var(--space-lg) var(--space-xl);
  flex: 1;
  min-height: 0;
}

/* ── Panels ─────────────────────────────────────────────────────────────── */
.panel {
  background: var(--color-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid rgba(71, 85, 105, 0.4);
  background: rgba(51, 65, 85, 0.3);
}

.panel-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.panel-title {
  font-family: var(--font-heading);
  font-size: 0.9375rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--color-foreground);
}

.panel-right {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  min-height: 0;
}

/* ── Camera Panel ───────────────────────────────────────────────────────── */
.panel-camera {
  display: flex;
  flex-direction: column;
}

.camera-status {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.2);
  color: #94a3b8;
  font-weight: 500;
}

.camera-status.live {
  background: var(--color-safe-bg);
  color: var(--color-accent);
}

.camera-container {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-feed {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.camera-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  background: rgba(15, 23, 42, 0.85);
  color: #64748b;
  text-align: center;
  pointer-events: none;
}

.camera-placeholder p {
  font-size: 0.9375rem;
}

.camera-controls {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  white-space: nowrap;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}
.btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
  font-weight: 600;
}
.btn-sm {
  padding: 6px 12px;
  font-size: 0.8125rem;
}

.btn-primary {
  background: var(--color-accent);
  color: #000;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover {
  background: var(--color-accent-hover);
  box-shadow: var(--shadow-glow);
}
.btn-primary:disabled {
  background: #374151;
  color: #6b7280;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-danger {
  background: var(--color-destructive);
  color: #fff;
}
.btn-danger:hover {
  background: var(--color-destructive-hover);
}

.btn-ghost {
  background: transparent;
  color: #94a3b8;
  border: 1px solid transparent;
  padding: 6px 8px;
}
.btn-ghost:hover {
  color: var(--color-foreground);
  background: var(--color-muted);
}

.btn-close {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all var(--duration-fast) var(--ease-out);
}
.btn-close:hover {
  color: var(--color-foreground);
  background: var(--color-muted);
}
.btn-close:active {
  transform: scale(0.95);
}
.btn-close:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ── Upload Panel ───────────────────────────────────────────────────────── */
.panel-upload {
  flex-shrink: 0;
}

.upload-form {
  padding: var(--space-lg);
}

.upload-dropzone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-xl);
  text-align: center;
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
  position: relative;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(39, 47, 66, 0.3);
}

.upload-dropzone:hover,
.upload-dropzone.drag-over {
  border-color: var(--color-accent);
  background: rgba(34, 197, 94, 0.06);
}

.dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  color: #94a3b8;
}

.link-text {
  color: var(--color-accent);
  font-weight: 500;
}

.upload-preview {
  position: absolute;
  inset: 4px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  background: #000;
}

.upload-actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-top: var(--space-md);
}

.upload-status {
  font-size: 0.8125rem;
  font-weight: 500;
}

.upload-status.success {
  color: var(--color-accent);
}
.upload-status.error {
  color: var(--color-destructive);
}

/* ── Reference Gallery ──────────────────────────────────────────────────── */
.reference-gallery {
  display: flex;
  gap: var(--space-sm);
  padding: 0 var(--space-lg) var(--space-md);
  flex-wrap: wrap;
}

.ref-photo-card {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid var(--color-border);
  transition: border-color var(--duration-fast);
  cursor: pointer;
  flex-shrink: 0;
}

.ref-photo-card:hover {
  border-color: var(--color-accent);
}
.ref-photo-card:active {
  transform: scale(0.95);
}

.ref-photo-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ref-photo-card .ref-delete {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  background: rgba(239, 68, 68, 0.85);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--duration-fast);
}

.ref-photo-card:hover .ref-delete {
  opacity: 1;
}

.reference-gallery-empty {
  padding: 0 var(--space-lg) var(--space-md);
  color: #64748b;
  font-size: 0.8125rem;
}

/* ── Patient Config Panel ──────────────────────────────────────────────── */
.panel-patient-config {
  flex-shrink: 0;
}

.config-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-lg);
}

.config-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.config-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.config-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.625rem;
  font-weight: 700;
  background: var(--color-muted);
}

.config-input,
.config-select {
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-background);
  color: var(--color-foreground);
  font-family: var(--font-body);
  font-size: 0.875rem;
  transition: border-color var(--duration-fast) var(--ease-out);
}

.config-input:focus,
.config-select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.config-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.config-emotion-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.emotion-indicator {
  font-size: 1.25rem;
  transition: color var(--duration-normal) var(--ease-out);
}

.config-hint {
  font-size: 0.6875rem;
  color: #64748b;
  margin-top: 2px;
}

.config-actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 0 var(--space-lg) var(--space-md);
}

.config-status {
  font-size: 0.8125rem;
  font-weight: 500;
}

.config-status.success {
  color: var(--color-accent);
}

.config-status.error {
  color: var(--color-destructive);
}

/* ── Camera Config Panel ───────────────────────────────────────────────── */
.panel-camera-config {
  flex-shrink: 0;
}

.panel-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  background: rgba(34, 197, 94, 0.12);
  color: var(--color-accent);
  letter-spacing: 0.03em;
}

.camera-config-form {
  padding: var(--space-lg);
}

.camera-config-form .text-muted {
  margin-bottom: var(--space-lg);
  font-size: 0.8125rem;
  line-height: 1.5;
}

.camera-config-form form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #cbd5e1;
}

.form-row input {
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-background);
  color: var(--color-foreground);
  font-family: var(--font-body);
  font-size: 0.875rem;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
  width: 100%;
  height: 42px;
  box-sizing: border-box;
}

.form-row input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

.form-row input::placeholder {
  color: #64748b;
}

.form-row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.form-row-2col > div {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row-2col > div label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #cbd5e1;
}

.form-row-2col > div input {
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-background);
  color: var(--color-foreground);
  font-family: var(--font-body);
  font-size: 0.875rem;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
  width: 100%;
  height: 42px;
  box-sizing: border-box;
}

.form-row-2col > div input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

.form-row-2col > div input::placeholder {
  color: #64748b;
}

.camera-config-form .btn {
  align-self: flex-start;
  margin-top: var(--space-sm);
}

.camera-config-form .config-status {
  display: inline-block;
  margin-left: var(--space-md);
  vertical-align: middle;
}

/* ── Logs Panel ─────────────────────────────────────────────────────────── */
.panel-logs {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.logs-container {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.log-count {
  font-size: 0.75rem;
  color: #94a3b8;
}

/* ── Empty State ────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl) var(--space-lg);
  text-align: center;
  gap: var(--space-sm);
  color: #64748b;
  height: 100%;
}

.empty-state p:first-of-type {
  font-weight: 500;
  color: #94a3b8;
  margin-top: var(--space-sm);
}

/* ── Log Table ──────────────────────────────────────────────────────────── */
.log-table-wrapper {
  overflow-x: auto;
}

.log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.log-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.log-table th {
  background: var(--color-secondary);
  color: #cbd5e1;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.6875rem;
  letter-spacing: 0.05em;
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.log-table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid rgba(71, 85, 105, 0.3);
  vertical-align: middle;
}

.log-table tbody tr {
  transition: background var(--duration-fast) var(--ease-out);
  cursor: pointer;
}

.log-table tbody tr:hover {
  background: rgba(34, 197, 94, 0.05);
}

.log-table tbody tr:active {
  transform: scale(0.995);
}

.log-table tbody tr:nth-child(even) {
  background: rgba(51, 65, 85, 0.2);
}

.log-table tbody tr:nth-child(even):hover {
  background: rgba(34, 197, 94, 0.07);
}

/* ── Status Badges (Table) ──────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.badge-aman {
  background: var(--color-safe-bg);
  color: var(--color-safe);
}

.badge-perhatian {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.badge-darurat {
  background: var(--color-danger-bg);
  color: var(--color-destructive);
}

.badge-safe {
  background: var(--color-safe-bg);
  color: var(--color-safe);
}

.badge-attention {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.badge-emergency {
  background: var(--color-danger-bg);
  color: var(--color-destructive);
}

/* ── Snapshot Thumbnail ─────────────────────────────────────────────────── */
.snapshot-thumb {
  width: 60px;
  height: 45px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: transform var(--duration-fast);
}

.snapshot-thumb:hover {
  transform: scale(1.05);
  border-color: var(--color-accent);
}

/* ── Modal ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 200ms var(--ease-out);
}

.modal-card {
  background: var(--color-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  max-width: 600px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 250ms var(--ease-out);
}

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

.modal-header h3 {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.125rem;
}

.modal-body {
  padding: var(--space-lg);
}

.modal-body img {
  width: 100%;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
  border: 1px solid var(--color-border);
}

.modal-body .detail-row {
  margin-bottom: var(--space-md);
}

.modal-body .detail-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
  margin-bottom: var(--space-xs);
}

.modal-body .detail-value {
  font-size: 0.9375rem;
  color: var(--color-foreground);
  line-height: 1.5;
}

/* ── Toast ──────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  background: var(--color-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  box-shadow: var(--shadow-md);
  font-size: 0.875rem;
  animation: slideInRight 300ms var(--ease-out);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  max-width: 380px;
}

.toast-success {
  border-left: 3px solid var(--color-accent);
}
.toast-error {
  border-left: 3px solid var(--color-destructive);
}
.toast-info {
  border-left: 3px solid #3b82f6;
}

.toast-removing {
  animation: slideOutRight 250ms var(--ease-in-out) forwards;
}

/* ── Footer ─────────────────────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: var(--space-md);
  border-top: 1px solid var(--color-border);
  color: #64748b;
  font-size: 0.75rem;
  flex-shrink: 0;
}

/* ── Animations ─────────────────────────────────────────────────────────── */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOutRight {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

@keyframes pulse-dot {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.icon-spin {
  animation: spin 1s linear infinite;
}

.status-dot.active {
  animation: pulse-dot 2s var(--ease-in-out) infinite;
}

.status-badge.badge-offline {
  background: var(--color-danger-bg);
  border-color: var(--color-destructive);
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .main-grid {
    grid-template-columns: 1fr;
  }

  .panel-camera {
    max-height: 50vh;
  }
}

@media (max-width: 768px) {
  .header {
    padding: var(--space-sm) var(--space-md);
    flex-wrap: wrap;
    gap: var(--space-sm);
  }

  .header-right {
    gap: var(--space-sm);
  }

  .logo-text {
    font-size: 1.125rem;
  }
  .logo-tagline {
    display: none;
  }

  .main-grid {
    padding: var(--space-md);
  }

  .camera-controls {
    flex-direction: column;
  }

  .btn-lg {
    width: 100%;
    justify-content: center;
  }

  .upload-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .log-table {
    font-size: 0.75rem;
  }
  .log-table th,
  .log-table td {
    padding: var(--space-xs) var(--space-sm);
  }

  .snapshot-thumb {
    width: 48px;
    height: 36px;
  }

  .patient-header-inner {
    flex-direction: column;
    text-align: center;
  }

  .patient-button-grid {
    grid-template-columns: 1fr;
  }

  .patient-sos-btn {
    grid-column: auto;
  }

  .patient-clock {
    font-size: 42px;
  }

  .mode-grid {
    grid-template-columns: 1fr;
  }

  .landing-title {
    font-size: 42px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Patient Dashboard
   ═══════════════════════════════════════════════════════════════════════════ */

.patient-body {
  background: #f4f7fb;
  color: #172033;
  font-family: Arial, sans-serif;
}

.patient-header {
  background: #172033;
  color: white;
  padding: 24px;
  text-align: center;
}

.patient-header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 900px;
  margin: auto;
  flex-wrap: wrap;
  gap: 8px;
}

.patient-header-inner a {
  color: #cbd5e1;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.patient-header-inner a:hover {
  color: #fff;
}

.patient-header h1 {
  margin: 0;
  font-size: 36px;
}

.patient-header p {
  margin: 8px 0 0;
  font-size: 18px;
  color: #cbd5e1;
}

.patient-main {
  width: 100%;
  max-width: 900px;
  margin: auto;
  padding: 28px 20px;
}

.patient-clock {
  text-align: center;
  font-size: 52px;
  font-weight: 700;
  margin-bottom: 8px;
}

.patient-date {
  text-align: center;
  font-size: 22px;
  margin-bottom: 24px;
}

.patient-status-card,
.patient-answer-card,
.patient-setup-card {
  background: white;
  border-radius: 18px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.08);
}

.patient-status-card h2,
.patient-answer-card h2,
.patient-setup-card h2 {
  margin-top: 0;
}

#zoneStatus {
  font-size: 25px;
  font-weight: 700;
}

#locationDetail {
  font-size: 17px;
  line-height: 1.5;
}

.patient-safe {
  color: #15803d;
}
.patient-warning {
  color: #b45309;
}
.patient-danger {
  color: #dc2626;
}

.patient-button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.patient-sos-btn {
  grid-column: 1 / -1;
  font-size: 28px;
}

.patient-btn {
  min-height: 90px;
  border: none;
  border-radius: 16px;
  padding: 18px;
  font-size: 21px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.patient-btn:hover {
  opacity: 0.9;
}

.patient-btn-primary {
  background: #2563eb;
  color: white;
}
.patient-btn-location {
  background: #059669;
  color: white;
}
.patient-btn-family {
  background: #374151;
  color: white;
}
.patient-btn-sos {
  background: #dc2626;
  color: white;
}

#answerText {
  font-size: 22px;
  line-height: 1.7;
  margin-bottom: 0;
}

.patient-setup-card {
  border: 2px dashed #94a3b8;
}

.patient-setup-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.patient-setup-row input {
  width: 140px;
  padding: 13px;
  border: 1px solid #94a3b8;
  border-radius: 10px;
  font-size: 18px;
}

.patient-setup-row button {
  min-height: 55px;
  font-size: 17px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Landing Page (index.html)
   ═══════════════════════════════════════════════════════════════════════════ */

.landing-body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a, #1e293b);
  color: white;
  font-family: Arial, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.landing-container {
  width: 100%;
  max-width: 850px;
  text-align: center;
}

.landing-title {
  margin: 0 0 10px;
  font-size: 52px;
}

.landing-subtitle {
  font-size: 21px;
  color: #cbd5e1;
  margin-bottom: 40px;
}

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}

.mode-card {
  padding: 38px 24px;
  border-radius: 20px;
  text-decoration: none;
  color: white;
  transition:
    transform 0.2s,
    opacity 0.2s;
}

.mode-card:hover {
  transform: translateY(-5px);
  opacity: 0.95;
}

.mode-patient {
  background: #2563eb;
}
.mode-family {
  background: #059669;
}

.mode-icon {
  font-size: 60px;
}

.mode-card h2 {
  font-size: 28px;
  margin: 18px 0 10px;
}

.mode-card p {
  font-size: 18px;
  line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MEMORIES — Family-to-Patient Photo Memories (TASK 3)
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Family Dashboard: Memories Upload Section ─────────────────────────── */
.panel-memories {
  flex-shrink: 0;
}

.memories-upload {
  padding: var(--space-lg);
}

.memories-section-title {
  margin: 0 0 var(--space-xs);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-foreground);
  font-family: var(--font-heading);
}

.memories-desc {
  margin: 0 0 var(--space-lg);
  color: #94a3b8;
  font-size: 0.8125rem;
  line-height: 1.5;
}

/* ── Symmetrical 4-Column Form Layout ─────────────────────────────────── */
.memory-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: var(--space-md);
  align-items: end;
}

.memory-form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.memory-form-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #cbd5e1;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.memory-form-input {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-background);
  color: var(--color-foreground);
  font-size: 0.875rem;
  font-family: var(--font-body);
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
  width: 100%;
  height: 42px;
  box-sizing: border-box;
}

.memory-form-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

.memory-file-input-wrapper {
  position: relative;
  height: 42px;
  display: flex;
  align-items: center;
}

.memory-form-file {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-background);
  color: var(--color-foreground);
  font-size: 0.8125rem;
  font-family: var(--font-body);
  cursor: pointer;
  transition: border-color 0.2s;
  box-sizing: border-box;
  display: flex;
  align-items: center;
}

.memory-form-file:focus {
  outline: none;
  border-color: var(--color-accent);
}

.memory-form-file::file-selector-button {
  background: var(--color-secondary);
  color: var(--color-foreground);
  border: none;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.8125rem;
  margin-right: 10px;
  transition: background 0.2s;
  height: 30px;
}

.memory-form-file::file-selector-button:hover {
  background: var(--color-border);
}

.btn-memory-upload {
  width: 100%;
  justify-content: center;
  padding: 0 20px;
  font-weight: 600;
  font-size: 0.875rem;
  height: 42px;
  box-sizing: border-box;
  white-space: nowrap;
}

.memory-status {
  font-size: 0.8125rem;
  margin-top: var(--space-md);
  min-height: 20px;
  padding: 0 var(--space-lg);
}

.memory-status.success {
  color: var(--color-safe);
}

.memory-status.error {
  color: var(--color-destructive);
}

/* ── Memories Gallery Header ──────────────────────────────────────────── */
.memories-gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 var(--space-lg);
  margin-bottom: var(--space-sm);
}

.btn-clear-memories {
  color: #ef4444 !important;
  font-size: 0.75rem;
}

.btn-clear-memories:hover {
  background: rgba(239, 68, 68, 0.12) !important;
}

/* ── Family Dashboard: Memories Gallery ────────────────────────────────── */
.memories-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-md);
  margin-top: var(--space-md);
}

.memories-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--space-xl);
  color: #64748b;
  font-size: 0.9375rem;
}

.memories-empty.hidden {
  display: none;
}

.memory-card {
  position: relative;
  background: var(--color-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition:
    transform 0.2s,
    box-shadow 0.2s;
}

.memory-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.memory-photo {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}

.memory-info {
  padding: var(--space-sm) var(--space-md);
}

.memory-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--color-foreground);
}

.memory-relation {
  font-size: 0.8125rem;
  color: #94a3b8;
  margin-top: 2px;
}

.memory-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 1.125rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition:
    opacity 0.2s,
    background 0.2s;
}

.memory-card:hover .memory-delete {
  opacity: 1;
}

.memory-delete:hover {
  background: var(--color-destructive);
}

/* ── Patient Dashboard: Memories Display ───────────────────────────────── */
.patient-memories-card {
  background: var(--color-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.patient-memories-card h2 {
  margin: 0 0 var(--space-xs);
  font-size: 1.5rem;
  color: var(--color-foreground);
}

.patient-memories-card > p {
  margin: 0 0 var(--space-md);
  color: #94a3b8;
  font-size: 1rem;
}

.patient-memories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-md);
}

.patient-memories-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--space-xl);
  color: #64748b;
  font-size: 1rem;
  background: var(--color-muted);
  border-radius: var(--radius-md);
}

.patient-memory-card {
  background: var(--color-muted);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition:
    transform 0.2s,
    box-shadow 0.2s;
}

.patient-memory-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--color-accent);
}

.patient-memory-photo {
  width: 100%;
  height: 240px;
  object-fit: cover;
  display: block;
}

.patient-memory-info {
  padding: var(--space-md);
  text-align: center;
}

.patient-memory-name {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--color-foreground);
}

.patient-memory-relation {
  font-size: 1rem;
  color: var(--color-accent);
  margin-top: 4px;
  font-weight: 500;
}

/* ── Memory Enlarge Popup (Patient Dashboard) ─────────────────────────── */
.memory-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(6px);
}

.memory-popup-overlay.hidden {
  display: none;
}

.memory-popup-card {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  background: var(--color-primary);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow:
    var(--shadow-lg),
    0 0 40px rgba(34, 197, 94, 0.2);
  animation: popupFadeIn 0.25s ease-out;
}

@keyframes popupFadeIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.memory-popup-card img {
  display: block;
  max-width: 90vw;
  max-height: 70vh;
  object-fit: contain;
  background: #000;
}

.memory-popup-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  z-index: 10;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.memory-popup-close:hover {
  background: rgba(239, 68, 68, 0.8);
}

.memory-popup-info {
  padding: var(--space-lg);
  text-align: center;
  background: var(--color-primary);
}

.memory-popup-name {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-foreground);
  font-family: var(--font-heading);
}

.memory-popup-relation {
  font-size: 1.25rem;
  color: var(--color-accent);
  margin-top: 4px;
  font-weight: 500;
}
