/* ==========================================================================
   PULSE — Device Console
   Design tokens: everything alive has a pulse. Devices pulse cyan when
   online; a person's presence pulses pink (the heart-selfie motif).
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* --- Color --- */
  --bg-void: #0a0e17;
  --bg-panel: #101828;
  --bg-panel-raised: #16213a;
  --bg-panel-hover: #1c2c48;

  --accent-cyan: #4ce0d2;
  --accent-cyan-dim: #2a8f86;
  --accent-amber: #ffb454;
  --accent-pink: #ff5d8f;
  --accent-pink-dim: #b23f64;
  --danger: #ff6b6b;

  --text-primary: #e8edf4;
  --text-secondary: #8b98ac;
  --text-mono: #7fe8da;

  --border-hairline: rgba(140, 160, 200, 0.14);
  --border-hairline-strong: rgba(140, 160, 200, 0.26);

  /* --- Type --- */
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* --- Layout --- */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --nav-height: 68px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-void);
  color: var(--text-primary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  background-image:
    radial-gradient(circle at 15% 0%, rgba(76, 224, 210, 0.08), transparent 45%),
    radial-gradient(circle at 85% 15%, rgba(255, 93, 143, 0.06), transparent 40%),
    linear-gradient(var(--bg-void), var(--bg-void));
  background-attachment: fixed;
}

/* Faint hex-grid texture used behind hero/panel areas */
.grid-texture {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--border-hairline) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-hairline) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(ellipse at 50% 0%, black 0%, transparent 70%);
  opacity: 0.5;
}

a { color: inherit; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}

.mono {
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

button {
  font-family: var(--font-body);
  cursor: pointer;
}

/* ---------------------------------------------------------------------
   Signature element: the pulse ring.
   A slow expanding ring behind a solid dot — used for "online" device
   status (cyan) and for the selfie/heart feature (pink). One motif,
   two contexts: system heartbeat, human presence.
   --------------------------------------------------------------------- */
.pulse-ring {
  position: relative;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan);
  flex-shrink: 0;
}
.pulse-ring::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1.5px solid var(--accent-cyan);
  opacity: 0.6;
  animation: pulse-out 2.2s ease-out infinite;
}
.pulse-ring.offline {
  background: var(--text-secondary);
  box-shadow: none;
}
.pulse-ring.offline::before { display: none; }
.pulse-ring.pink {
  background: var(--accent-pink);
  box-shadow: 0 0 8px var(--accent-pink);
}
.pulse-ring.pink::before {
  border-color: var(--accent-pink);
}

@keyframes pulse-out {
  0%   { transform: scale(0.6); opacity: 0.6; }
  100% { transform: scale(2.2); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .pulse-ring::before { animation: none; display: none; }
}

/* ---------------------------------------------------------------------
   Top navigation
   --------------------------------------------------------------------- */
.topnav {
  height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--border-hairline);
  background: rgba(10, 14, 23, 0.7);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.02em;
}

.nav-links {
  display: flex;
  gap: 4px;
  background: var(--bg-panel);
  border: 1px solid var(--border-hairline);
  padding: 4px;
  border-radius: 999px;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 18px;
  border-radius: 999px;
  transition: color 0.15s, background 0.15s;
}
.nav-links a.active {
  color: var(--bg-void);
  background: var(--accent-cyan);
}
.nav-links a:not(.active):hover {
  color: var(--text-primary);
  background: var(--bg-panel-hover);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-chip img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1.5px solid var(--border-hairline-strong);
}
.user-chip .name {
  font-size: 13px;
  color: var(--text-secondary);
}
.signout-btn {
  background: transparent;
  border: 1px solid var(--border-hairline-strong);
  color: var(--text-secondary);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: border-color 0.15s, color 0.15s;
}
.signout-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* ---------------------------------------------------------------------
   Page shell
   --------------------------------------------------------------------- */
.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 40px 28px 80px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 16px;
}

.page-head h1 { font-size: 28px; }

.stat-pill {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg-panel);
  border: 1px solid var(--border-hairline);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
}
.stat-pill b { color: var(--accent-cyan); font-weight: 600; }

.btn-primary {
  background: var(--accent-cyan);
  color: #06211f;
  border: none;
  font-weight: 600;
  font-size: 14px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  transition: transform 0.12s, box-shadow 0.12s;
}
.btn-primary:hover {
  box-shadow: 0 0 0 3px rgba(76, 224, 210, 0.18);
}
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  background: var(--bg-panel-raised);
  color: var(--text-primary);
  border: 1px solid var(--border-hairline-strong);
  font-weight: 500;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
}
.btn-secondary:hover { background: var(--bg-panel-hover); }

.btn-pink {
  background: var(--accent-pink);
  color: #2b0714;
  border: none;
  font-weight: 600;
  font-size: 14px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
}
.btn-pink:hover {
  box-shadow: 0 0 0 3px rgba(255, 93, 143, 0.2);
}
.btn-pink:disabled, .btn-primary:disabled, .btn-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-danger-ghost {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 13px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
}
.btn-danger-ghost:hover {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.3);
}

/* ---------------------------------------------------------------------
   Device grid
   --------------------------------------------------------------------- */
.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.device-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
  padding: 18px;
  transition: border-color 0.15s, background 0.15s;
}
.device-card:hover {
  border-color: var(--border-hairline-strong);
  background: var(--bg-panel-raised);
}

.device-card .row1 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.device-card .device-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
}
.device-card .device-uid {
  font-size: 11.5px;
  color: var(--accent-cyan);
  opacity: 0.85;
}
.device-card .device-meta {
  font-size: 12.5px;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
}
.device-card .device-type {
  display: inline-block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  border: 1px solid var(--border-hairline-strong);
  padding: 2px 8px;
  border-radius: 999px;
}

.device-card-admin-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  border-top: 1px solid var(--border-hairline);
  padding-top: 12px;
}

/* ---------------------------------------------------------------------
   Selfie booth
   --------------------------------------------------------------------- */
.booth-layout {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 24px;
}
@media (max-width: 860px) {
  .booth-layout { grid-template-columns: 1fr; }
}

.booth-stage {
  background: var(--bg-panel);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.camera-frame {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #05070d;
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-hairline-strong);
}
.camera-frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* mirror, like a real selfie cam */
}
.camera-frame .placeholder {
  color: var(--text-secondary);
  font-size: 13.5px;
  text-align: center;
  padding: 0 30px;
  line-height: 1.6;
}
.camera-frame canvas { display: none; }

.rec-indicator {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(10, 14, 23, 0.75);
  backdrop-filter: blur(6px);
  padding: 6px 12px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--danger);
  border: 1px solid rgba(255, 107, 107, 0.35);
}
.rec-indicator .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
  animation: rec-blink 1.1s ease-in-out infinite;
}
@keyframes rec-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.heart-mask-outline {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.85;
}

.booth-controls {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.booth-note {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 14px;
  line-height: 1.6;
  border-top: 1px solid var(--border-hairline);
  padding-top: 14px;
}

.gallery-panel h3 {
  font-size: 16px;
  margin-bottom: 14px;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}

.photo-tile {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-hairline);
  aspect-ratio: 1;
  background: var(--bg-panel-raised);
}
.photo-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.photo-tile .tile-pulse {
  position: absolute;
  top: 8px;
  left: 8px;
}
.photo-tile .tile-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(10, 14, 23, 0.65);
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}
.photo-tile:hover .tile-delete { opacity: 1; }
.tile-delete:hover { background: var(--danger); }

.empty-note {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 24px 0;
  text-align: center;
  border: 1px dashed var(--border-hairline-strong);
  border-radius: var(--radius-md);
}

/* ---------------------------------------------------------------------
   Login page
   --------------------------------------------------------------------- */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 20px;
}

.login-card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 400px;
  background: rgba(16, 24, 40, 0.75);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-hairline-strong);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  text-align: center;
}

.login-mark {
  width: 52px;
  height: 52px;
  margin: 0 auto 20px;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--accent-cyan), var(--accent-cyan-dim));
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card h1 {
  font-size: 22px;
  margin-bottom: 6px;
}
.login-card p.sub {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin-bottom: 28px;
  line-height: 1.6;
}

#googleBtnContainer {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}

.login-consent-note {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.7;
  text-align: left;
  background: var(--bg-panel);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-top: 8px;
}
.login-consent-note b { color: var(--text-primary); }

.login-status {
  font-size: 13px;
  color: var(--accent-amber);
  margin-top: 14px;
  min-height: 18px;
}

/* ---------------------------------------------------------------------
   Admin
   --------------------------------------------------------------------- */
.admin-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-amber);
  border: 1px solid rgba(255, 180, 84, 0.35);
  padding: 3px 9px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
  padding: 22px;
  margin-bottom: 20px;
}
.panel h2 {
  font-size: 16px;
  margin-bottom: 16px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.table th {
  text-align: left;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-hairline-strong);
}
.table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border-hairline);
}
.table tr:last-child td { border-bottom: none; }

.inline-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.inline-form input, .inline-form select {
  background: var(--bg-panel-raised);
  border: 1px solid var(--border-hairline-strong);
  color: var(--text-primary);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: var(--font-body);
}
.inline-form input:focus, .inline-form select:focus {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 1px;
}

.thumb-sm {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border-hairline-strong);
}

.center-note {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}
.center-note h2 { color: var(--text-primary); margin-bottom: 8px; }

@media (max-width: 640px) {
  .topnav { padding: 0 14px; }
  .nav-links a { padding: 8px 12px; font-size: 13px; }
  .page { padding: 24px 16px 60px; }
  .user-chip .name { display: none; }
}
