/* ================================================================
   PAS Sensor Node — App Styles
   Design: industrial dark, amber accent, monospaced data readouts.
   Signature: sensor activity bars — the heartbeat of the device.
================================================================ */

/* ── Tokens ── */
:root {
  --bg:        #0a0c0f;
  --surface:   #111417;
  --surface2:  #181c21;
  --border:    #1e2227;
  --muted:     #2a2f38;
  --text:      #dde3ee;
  --dim:       #5c6880;
  --accent:    #f0a500;   /* amber — surveillance/warning */
  --accent2:   #00c896;   /* teal — active/ok */
  --danger:    #e84b4b;
  --warn:      #f5a623;
  --pass:      #2ecc71;
  --mono:      'JetBrains Mono', 'Fira Code', monospace;
  --sans:      'Inter', system-ui, sans-serif;
  --r:         5px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

/* ── Phase system ── */
.phase {
  display: none;
  min-height: 100dvh;
  flex-direction: column;
}
.phase.visible { display: flex; }

/* ================================================================
   SETUP PHASE
================================================================ */
#phase-setup, #phase-passphrase {
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
}

.auth-box {
  width: 100%;
  max-width: 380px;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
}
.auth-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
  flex-shrink: 0;
}
.auth-wordmark {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .2em;
  color: var(--accent);
  text-transform: uppercase;
}

.auth-box h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.02em;
  margin-bottom: 6px;
}
.auth-box .sub {
  font-size: 13px;
  color: var(--dim);
  margin-bottom: 28px;
}

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 11px;
  font-family: var(--mono);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text);
  font-size: 15px;
  font-family: var(--sans);
  outline: none;
  transition: border-color .2s;
}
.field input:focus { border-color: var(--accent); }

.field-error {
  display: none;
  font-size: 12px;
  color: var(--danger);
  margin-top: 6px;
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--r);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .2s;
  margin-top: 8px;
}
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary:active { opacity: .8; }

.btn-ghost {
  width: 100%;
  padding: 10px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--dim);
  font-size: 13px;
  cursor: pointer;
  margin-top: 10px;
  transition: border-color .2s, color .2s;
}
.btn-ghost:hover { border-color: var(--muted); color: var(--text); }

.auth-note {
  font-size: 11px;
  color: var(--dim);
  margin-top: 16px;
  line-height: 1.7;
  padding: 12px;
  background: var(--surface);
  border-radius: var(--r);
  border: 1px solid var(--border);
}

/* ================================================================
   ARMED PHASE
================================================================ */
#phase-armed {
  padding: 0;
  overflow-y: auto;
}

/* ── Top bar ── */
.topbar {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}
.topbar-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent2);
  box-shadow: 0 0 8px var(--accent2);
  animation: blink 3s infinite;
  flex-shrink: 0;
}
@keyframes blink {
  0%,90%,100% { opacity:1; }
  95%          { opacity:.2; }
}
.topbar-title {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .1em;
  color: var(--accent);
  flex: 1;
  text-transform: uppercase;
}
#device-label {
  font-size: 12px;
  color: var(--dim);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.battery-status { font-family: var(--mono); font-size: 11px; color: var(--dim); }
.battery-status.low { color: var(--danger); }

/* ── Sections ── */
.armed-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }

.section-label {
  font-size: 10px;
  font-family: var(--mono);
  letter-spacing: .15em;
  color: var(--dim);
  text-transform: uppercase;
  margin-bottom: 10px;
}

/* ── Sensor cards ── */
.sensor-cards { display: flex; flex-direction: column; gap: 8px; }
.sensor-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px;
}
.sensor-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.sensor-card-name { font-weight: 600; font-size: 13px; flex: 1; }
.sensor-status {
  font-size: 10px;
  font-family: var(--mono);
  padding: 2px 8px;
  border-radius: 3px;
  background: var(--muted);
  color: var(--dim);
  text-transform: uppercase;
}
.sensor-status[data-ok="true"] {
  background: rgba(0,200,150,.12);
  color: var(--accent2);
}
.sensor-status[data-ok="false"] {
  background: rgba(232,75,75,.1);
  color: var(--danger);
}

/* Signature element: activity bar */
.activity-bar-track {
  height: 4px;
  background: var(--muted);
  border-radius: 2px;
  overflow: hidden;
}
.activity-bar {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  background: var(--accent2);
  transition: width .15s ease;
}
.sensor-readout {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--dim);
  margin-top: 6px;
}

/* ── Alert feed ── */
.alert-feed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.alert-count-badge {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--muted);
  padding: 2px 8px;
  border-radius: 10px;
  color: var(--dim);
}
#alert-feed { display: flex; flex-direction: column; gap: 6px; }
.feed-empty {
  font-size: 13px;
  color: var(--dim);
  padding: 20px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--r);
}

.alert-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px 12px;
  border-left-width: 3px;
  animation: slideIn .2s ease;
}
@keyframes slideIn {
  from { opacity:0; transform: translateY(-6px); }
  to   { opacity:1; transform: translateY(0); }
}
.alert-item.sev-critical { border-left-color: var(--danger); }
.alert-item.sev-high     { border-left-color: var(--warn); }
.alert-item.sev-medium   { border-left-color: var(--accent); }
.alert-item.sev-low      { border-left-color: var(--accent2); }

.alert-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.alert-sensor {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--accent);
  letter-spacing: .1em;
}
.alert-sev {
  font-size: 10px;
  font-family: var(--mono);
  text-transform: uppercase;
  color: var(--dim);
}
.alert-time { font-size: 10px; color: var(--dim); margin-left: auto; font-family: var(--mono); }
.alert-msg  { font-size: 12px; color: var(--text); line-height: 1.5; }

/* ── Controls ── */
.controls { display: flex; flex-direction: column; gap: 8px; }
.btn-armed {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: var(--r);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .2s;
}
.btn-armed:disabled { opacity: .4; cursor: not-allowed; }
.btn-armed.start  { background: var(--accent2); color: #000; }
.btn-armed.stop   { background: var(--muted);   color: var(--text); }
.btn-armed.sm     { background: var(--bg); color: var(--accent); border: 1px solid var(--accent); }
.btn-armed.lock   { background: var(--bg); color: var(--dim);    border: 1px solid var(--border); }

/* ================================================================
   SENSOR MODE PHASE
================================================================ */
#phase-sensor-mode {
  background: #000000;
  align-items: center;
  justify-content: center;
  position: fixed;
  inset: 0;
  z-index: 9999;
}

.sm-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 0 32px;
}

.sm-badge {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .25em;
  color: rgba(240,165,0,.3);
  text-transform: uppercase;
}

.sm-dot-ring {
  width: 72px; height: 72px;
  border-radius: 50%;
  border: 1px solid rgba(0,200,150,.12);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: ringPulse 4s ease-in-out infinite;
}
@keyframes ringPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(0,200,150,.0); }
  50%      { box-shadow: 0 0 0 16px rgba(0,200,150,.05); }
}
.sm-center-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent2);
  box-shadow: 0 0 12px var(--accent2);
  animation: blink 3s infinite;
}

.sm-stats {
  font-family: var(--mono);
  font-size: 11px;
  color: rgba(255,255,255,.22);
  line-height: 2.4;
  text-align: center;
  letter-spacing: .04em;
}
.sm-stats span { display: block; }

.sm-exit-btn {
  position: absolute;
  bottom: 36px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.3);
  border-radius: 20px;
  padding: 9px 22px;
  font-size: 12px;
  font-family: var(--mono);
  cursor: pointer;
  letter-spacing: .08em;
  transition: background .2s, color .2s;
}
.sm-exit-btn:active { background: rgba(255,255,255,.12); color: rgba(255,255,255,.6); }
