/* SOMNUS GUARD ADAS STYLESHEET */
:root {
  --color-hud-green: #39ff14;
  --color-hud-cyan: #00f0ff;
  --color-hud-gold: #ffd700;
  --color-hud-red: #ff2a2a;
  --color-bg-dark: #020308;
  --color-panel-bg: rgba(6, 15, 30, 0.75);
  --color-panel-border: rgba(0, 240, 255, 0.2);
  --color-text-bright: #e5f8ff;
  --font-hud: 'Orbitron', sans-serif;
  --font-mono: 'Share Tech Mono', monospace;
  --font-title: 'Rajdhani', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body, html {
  width: 100%;
  height: 100%;
  background-color: var(--color-bg-dark);
  color: var(--color-text-bright);
  font-family: var(--font-mono);
  overflow: hidden;
}

#app-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 15px;
  gap: 15px;
}

/* HEADER STYLE */
.app-header {
  height: 45px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--color-panel-border);
  padding-bottom: 5px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pulse-icon {
  width: 10px;
  height: 10px;
  background-color: var(--color-hud-green);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--color-hud-green);
  animation: pulse-green 1.5s infinite;
}

@keyframes pulse-green {
  0% { transform: scale(0.9); opacity: 0.6; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.6; }
}

.header-logo h1 {
  font-family: var(--font-hud);
  font-size: 1.25rem;
  letter-spacing: 3px;
  color: #fff;
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}

.system-time {
  font-size: 1rem;
  letter-spacing: 1px;
  color: var(--color-hud-cyan);
}

/* MAIN LAYOUT COCKPIT GRID */
.main-layout {
  flex-grow: 1;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 15px;
  min-height: 0; /* allows grid items to shrink */
}

/* Glassmorphism panel system */
.glass-panel {
  background: var(--color-panel-bg);
  border: 1px solid var(--color-panel-border);
  border-radius: 6px;
  box-shadow: inset 0 0 20px rgba(0, 240, 255, 0.05), 0 5px 15px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  padding: 12px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.panel-header {
  font-family: var(--font-hud);
  font-size: 0.85rem;
  letter-spacing: 2px;
  color: var(--color-hud-cyan);
  border-bottom: 1px solid rgba(0, 240, 255, 0.15);
  padding-bottom: 5px;
  margin-bottom: 10px;
  font-weight: bold;
}

/* LEFT CAMERA FEED VIEWER */
.video-container {
  position: relative;
  justify-content: center;
  align-items: center;
  background-color: #010408;
}

#webcam {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.05);
}

#video-canvas {
  position: absolute;
  top: 12px;
  left: 12px;
  width: calc(100% - 24px);
  height: calc(100% - 24px);
  pointer-events: none;
  z-index: 5;
}

.video-grid-decor {
  position: absolute;
  top: 12px;
  left: 12px;
  width: calc(100% - 24px);
  height: calc(100% - 24px);
  background-image: 
    linear-gradient(rgba(0, 240, 255, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 240, 255, 0.015) 1px, transparent 1px);
  background-size: 30px 30px;
  pointer-events: none;
  z-index: 2;
}

/* ALARM OVERLAY (Aggressively blinking red screen cover) */
.hud-warning-overlay {
  position: absolute;
  top: 12px;
  left: 12px;
  width: calc(100% - 24px);
  height: calc(100% - 24px);
  background: rgba(255, 42, 42, 0.25);
  z-index: 10;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 4px;
  border: 2px solid var(--color-hud-red);
  box-shadow: inset 0 0 30px var(--color-hud-red);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.hud-warning-overlay.active {
  opacity: 1;
  animation: alarm-pulse-border 0.4s infinite alternate;
}

@keyframes alarm-pulse-border {
  from { background-color: rgba(255, 42, 42, 0.1); border-color: rgba(255, 42, 42, 0.5); }
  to { background-color: rgba(255, 42, 42, 0.35); border-color: var(--color-hud-red); }
}

.warning-box {
  background-color: rgba(0, 0, 0, 0.85);
  border: 2px solid var(--color-hud-red);
  padding: 20px 40px;
  text-align: center;
  box-shadow: 0 0 25px var(--color-hud-red);
  border-radius: 4px;
  animation: shake 0.3s infinite;
}

.warning-title {
  display: block;
  font-family: var(--font-hud);
  font-size: 2rem;
  color: var(--color-hud-red);
  text-shadow: 0 0 10px var(--color-hud-red);
  font-weight: 900;
  margin-bottom: 5px;
}

.warning-subtitle {
  font-size: 0.95rem;
  color: #fff;
  letter-spacing: 2px;
}

@keyframes shake {
  0% { transform: translate(1px, 1px) rotate(0deg); }
  10% { transform: translate(-1px, -2px) rotate(-1deg); }
  20% { transform: translate(-3px, 0px) rotate(1deg); }
  30% { transform: translate(0px, 2px) rotate(0deg); }
  40% { transform: translate(1px, -1px) rotate(1deg); }
  50% { transform: translate(-1px, 2px) rotate(-1deg); }
  60% { transform: translate(-3px, 1px) rotate(0deg); }
  70% { transform: translate(2px, 1px) rotate(-1deg); }
  80% { transform: translate(-1px, -1px) rotate(1deg); }
  90% { transform: translate(2px, 2px) rotate(0deg); }
  100% { transform: translate(1px, -2px) rotate(-1deg); }
}


/* RIGHT PANEL LAYOUT */
.analytics-container {
  display: flex;
  flex-direction: column;
  gap: 15px;
  min-height: 0;
}

/* REALTIME CHART */
.chart-panel {
  flex-grow: 1.1;
  min-height: 180px;
}

.chart-wrapper {
  flex-grow: 1;
  position: relative;
  width: 100%;
  height: 100%;
}

#ear-chart {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.chart-legend {
  display: flex;
  justify-content: center;
  gap: 20px;
  font-size: 0.75rem;
  color: #8bb2c2;
  margin-top: 5px;
}

.color-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
}
.left-dot { background-color: var(--color-hud-cyan); }
.right-dot { background-color: var(--color-hud-gold); }
.thresh-dot { background-color: var(--color-hud-red); }


/* METRICS GRID */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  flex-shrink: 0;
}

.metric-card {
  padding: 8px;
  text-align: center;
}

.metric-label {
  font-size: 0.65rem;
  color: #7296a8;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.metric-value {
  font-family: var(--font-hud);
  font-size: 1.1rem;
  font-weight: 800;
}

.text-green { color: var(--color-hud-green); text-shadow: 0 0 5px rgba(57, 255, 20, 0.4); }
.text-cyan { color: var(--color-hud-cyan); text-shadow: 0 0 5px rgba(0, 240, 255, 0.4); }
.text-red { color: var(--color-hud-red); text-shadow: 0 0 5px rgba(255, 42, 42, 0.4); }
.text-gold { color: var(--color-hud-gold); text-shadow: 0 0 5px rgba(255, 215, 0, 0.4); }


/* SETTINGS */
.settings-panel {
  flex-shrink: 0;
}

.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.control-group label {
  font-size: 0.75rem;
  color: var(--color-text-bright);
}

.slider-desc {
  font-size: 0.65rem;
  color: #5d7e8c;
}

/* Sliders styling */
.cyber-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 5px;
  background: rgba(0, 240, 255, 0.15);
  outline: none;
  border-radius: 3px;
}
.cyber-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-hud-cyan);
  cursor: pointer;
  box-shadow: 0 0 6px var(--color-hud-cyan);
}

/* Select element styling */
.cyber-select {
  background: rgba(1, 9, 21, 0.95);
  color: var(--color-hud-cyan);
  border: 1px solid var(--color-panel-border);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 6px;
  border-radius: 3px;
  outline: none;
}
.cyber-select:focus {
  border-color: #fff;
  box-shadow: 0 0 8px var(--color-hud-cyan);
}

.btn-group {
  display: flex;
  gap: 10px;
  margin-top: 5px;
}

/* Buttons styling */
.cyber-btn {
  flex: 1;
  background: transparent;
  border: none;
  font-family: var(--font-hud);
  font-size: 0.8rem;
  font-weight: bold;
  letter-spacing: 2px;
  padding: 10px;
  border-radius: 4px;
  cursor: pointer;
  outline: none;
  transition: all 0.2s;
}
.cyber-btn.primary {
  border: 1px solid var(--color-hud-cyan);
  background: rgba(0, 240, 255, 0.08);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
  color: #fff;
}
.cyber-btn.primary:hover {
  background: rgba(0, 240, 255, 0.2);
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.5);
}
.cyber-btn.secondary {
  border: 1px solid var(--color-hud-gold);
  background: rgba(255, 215, 0, 0.05);
  color: var(--color-hud-gold);
}
.cyber-btn.secondary:hover {
  background: rgba(255, 215, 0, 0.15);
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
}
.cyber-btn:active {
  transform: scale(0.98);
}


/* TERMINAL LOGGER */
.terminal-panel {
  flex-grow: 0.8;
  min-height: 100px;
  background: rgba(0,0,0,0.5);
}

.terminal-feed {
  flex-grow: 1;
  font-size: 0.7rem;
  line-height: 1.4;
  color: #00ccff;
  overflow-y: auto;
  word-break: break-all;
}


/* CALIBRATION MODAL */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(2,3,6,0.9);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 450px;
  background: rgba(1, 9, 22, 0.95);
  border: 1px solid var(--color-hud-cyan);
  border-radius: 8px;
  padding: 30px;
  box-shadow: 0 0 35px rgba(0, 240, 255, 0.25);
  text-align: center;
}

.modal-title {
  font-family: var(--font-hud);
  font-size: 1.25rem;
  color: #fff;
  text-shadow: 0 0 8px var(--color-hud-cyan);
  margin-bottom: 15px;
}

.modal-desc {
  font-size: 0.85rem;
  line-height: 1.5;
  color: #8bb2c2;
  margin-bottom: 20px;
}

.calibration-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 25px;
  text-align: left;
}

.step-indicator {
  font-size: 0.8rem;
  color: #5d7e8c;
  padding: 8px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(255,255,255,0.02);
}

.step-indicator.active {
  color: #fff;
  border-color: var(--color-hud-cyan);
  background: rgba(0, 240, 255, 0.05);
  box-shadow: 0 0 8px rgba(0,240,255,0.15);
}

.calibration-progress-container {
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  margin-bottom: 25px;
  overflow: hidden;
}

.calibration-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--color-hud-cyan);
  box-shadow: 0 0 8px var(--color-hud-cyan);
  transition: width 0.1s linear;
}


/* INITIAL SYSTEM ACCESS SCREEN */
#startup-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(10,24,45,0.96) 0%, rgba(2,3,6,0.99) 100%);
  backdrop-filter: blur(15px);
  z-index: 200;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: opacity 0.8s ease;
}

.startup-card {
  text-align: center;
  max-width: 550px;
  padding: 40px;
  background: rgba(1, 8, 20, 0.85);
  border: 1px solid var(--color-panel-border);
  border-radius: 10px;
  box-shadow: 0 0 40px rgba(0, 240, 255, 0.2);
}

.glow-text {
  font-family: var(--font-hud);
  font-size: 2.6rem;
  letter-spacing: 6px;
  color: #fff;
  text-shadow: 0 0 15px rgba(0, 240, 255, 0.6);
  margin-bottom: 5px;
}

.sub-text {
  font-family: var(--font-hud);
  font-size: 1.1rem;
  letter-spacing: 4px;
  color: var(--color-hud-cyan);
  margin-bottom: 25px;
}

.startup-desc {
  font-size: 0.9rem;
  line-height: 1.6;
  color: #8bb2c2;
  margin-bottom: 30px;
}

.glow-btn {
  background: transparent;
  color: #fff;
  font-family: var(--font-hud);
  font-size: 1rem;
  font-weight: bold;
  letter-spacing: 3px;
  padding: 15px 35px;
  border: 1px solid var(--color-hud-cyan);
  border-radius: 4px;
  cursor: pointer;
  outline: none;
  background: rgba(0, 240, 255, 0.08);
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.3);
  transition: all 0.3s ease;
}

.glow-btn:hover {
  background: rgba(0, 240, 255, 0.22);
  box-shadow: 0 0 25px rgba(0, 240, 255, 0.6);
  border-color: #fff;
}

.status-feed {
  margin-top: 25px;
  font-size: 0.8rem;
  color: #638594;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--color-hud-red);
  display: inline-block;
  margin-right: 6px;
  box-shadow: 0 0 5px var(--color-hud-red);
}

.status-dot.active {
  background-color: var(--color-hud-green);
  box-shadow: 0 0 8px var(--color-hud-green);
}
