/* ==========================================================================
   AIRCHAT NEXT-GEN — Futuristic Cyber-Acoustic Terminal Styling
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,300;0,400;0,700;1,400&family=Orbitron:wght@500;700;900&family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
  --bg-dark: #07090e;
  --bg-panel: rgba(14, 19, 31, 0.75);
  --bg-panel-solid: #0d121f;
  --bg-card: rgba(22, 30, 48, 0.6);
  --border-cyan: rgba(0, 240, 255, 0.25);
  --border-cyan-glow: rgba(0, 240, 255, 0.6);
  --cyan-primary: #00f0ff;
  --cyan-secondary: #00b8d4;
  --cyan-glow: rgba(0, 240, 255, 0.35);
  --purple-glow: rgba(139, 92, 246, 0.35);
  --accent-purple: #8b5cf6;
  --accent-pink: #ec4899;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --font-heading: 'Orbitron', -apple-system, sans-serif;
  --font-body: 'Space Grotesk', -apple-system, sans-serif;
  --font-code: 'JetBrains Mono', monospace;

  --shadow-hud: 0 8px 32px 0 rgba(0, 0, 0, 0.4), 0 0 15px rgba(0, 240, 255, 0.15);
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
}

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

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-body);
  overflow-x: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Background Cyber Grid & Scanline Effect */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: 
    linear-gradient(rgba(0, 240, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 240, 255, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

.scanlines {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  pointer-events: none;
  background: linear-gradient(
    rgba(18, 16, 16, 0) 50%, 
    rgba(0, 0, 0, 0.25) 50%
  );
  background-size: 100% 4px;
  z-index: 100;
  opacity: 0.4;
}

/* Ambient Radial Glows */
.glow-bg {
  position: fixed;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--cyan-glow) 0%, rgba(0,0,0,0) 70%);
  top: -200px;
  left: -200px;
  pointer-events: none;
  z-index: 0;
  opacity: 0.6;
}

.glow-bg-secondary {
  position: fixed;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--purple-glow) 0%, rgba(0,0,0,0) 70%);
  bottom: -150px;
  right: -150px;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
}

/* Main Container Layout */
#app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px;
}

/* HUD Top Header */
.hud-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-cyan);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-hud);
  margin-bottom: 20px;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  background: radial-gradient(circle, rgba(0,240,255,0.2) 0%, rgba(139,92,246,0.1) 100%);
  border: 1.5px solid var(--cyan-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px var(--cyan-glow);
  color: var(--cyan-primary);
}

.brand-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: 2px;
  background: linear-gradient(135deg, #ffffff 0%, var(--cyan-primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 20px rgba(0, 240, 255, 0.4);
}

.brand-tagline {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  font-family: var(--font-code);
}

/* Header Telemetry Status Controls */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hud-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  font-family: var(--font-code);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.led-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-dim);
}
.led-dot.active {
  background-color: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
  animation: pulse-led 1.5s infinite;
}
.led-dot.locked {
  background-color: var(--cyan-primary);
  box-shadow: 0 0 8px var(--cyan-primary);
  animation: pulse-led 0.8s infinite;
}

@keyframes pulse-led {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
  100% { opacity: 1; transform: scale(1); }
}

.btn-icon {
  background: rgba(0, 240, 255, 0.08);
  border: 1px solid var(--border-cyan);
  color: var(--cyan-primary);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-icon:hover {
  background: rgba(0, 240, 255, 0.2);
  border-color: var(--cyan-primary);
  box-shadow: 0 0 12px var(--cyan-glow);
  transform: translateY(-1px);
}

.badge-beta {
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid var(--accent-purple);
  color: #c084fc;
  font-family: var(--font-code);
  font-size: 0.72rem;
  padding: 4px 10px;
  border-radius: 4px;
  text-decoration: none;
  transition: all 0.2s ease;
}
.badge-beta:hover {
  background: var(--accent-purple);
  color: #fff;
  box-shadow: 0 0 10px var(--purple-glow);
}

/* Nav Tabs bar */
.nav-tabs {
  display: flex;
  gap: 8px;
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  padding: 6px;
  border: 1px solid var(--border-cyan);
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  overflow-x: auto;
}

.tab-btn {
  flex: 1;
  min-width: 140px;
  padding: 12px 16px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 1px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.25s ease;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(0, 240, 255, 0.05);
}

.tab-btn.active {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.2) 0%, rgba(139, 92, 246, 0.2) 100%);
  border: 1px solid var(--cyan-primary);
  color: #ffffff;
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.25);
}

/* Content Layout Grid */
.terminal-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  flex: 1;
}

@media (max-width: 1024px) {
  .terminal-grid {
    grid-template-columns: 1fr;
  }
}

/* Main View Panel Container */
.view-panel {
  display: none;
  flex-direction: column;
  gap: 20px;
}
.view-panel.active {
  display: flex;
}

/* Glass Panel Card */
.hud-card {
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-cyan);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-hud);
  position: relative;
  overflow: hidden;
}

.hud-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; width: 100%; height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan-primary), transparent);
  opacity: 0.5;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.card-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--cyan-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-tag {
  font-family: var(--font-code);
  font-size: 0.7rem;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.04);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

/* Input Fields & Buttons */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.input-label {
  font-family: var(--font-code);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.hud-input {
  width: 100%;
  padding: 14px 16px;
  background: rgba(5, 8, 15, 0.8);
  border: 1px solid rgba(0, 240, 255, 0.2);
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font-code);
  font-size: 0.95rem;
  outline: none;
  transition: all 0.2s ease;
}

.hud-input:focus {
  border-color: var(--cyan-primary);
  box-shadow: 0 0 12px var(--cyan-glow);
  background: rgba(5, 8, 15, 0.95);
}

.btn-primary {
  width: 100%;
  padding: 14px 20px;
  background: linear-gradient(135deg, var(--cyan-primary) 0%, var(--cyan-secondary) 100%);
  border: none;
  border-radius: var(--radius-sm);
  color: #04070d;
  font-family: var(--font-heading);
  font-size: 0.88rem;
  font-weight: 900;
  letter-spacing: 1.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.4);
  transition: all 0.25s ease;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.7);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-danger {
  padding: 14px 20px;
  background: linear-gradient(135deg, var(--accent-red) 0%, #b91c1c 100%);
  border: none;
  border-radius: var(--radius-sm);
  color: #ffffff;
  font-family: var(--font-heading);
  font-size: 0.88rem;
  font-weight: 900;
  letter-spacing: 1.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
  transition: all 0.25s ease;
}

.btn-danger:hover:not(:disabled) {
  box-shadow: 0 0 25px rgba(239, 68, 68, 0.7);
}
.btn-danger:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-row {
  display: flex;
  gap: 12px;
  margin-top: 10px;
}

/* Readouts Grid */
.readout-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.readout-item {
  background: rgba(5, 8, 15, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

.readout-label {
  font-family: var(--font-code);
  font-size: 0.68rem;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.readout-value {
  font-family: var(--font-code);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}
.readout-value.highlight {
  color: var(--cyan-primary);
  text-shadow: 0 0 8px var(--cyan-glow);
}
.readout-value.amber {
  color: var(--accent-amber);
}

/* Bitstream Display Box */
.bitstream-box {
  background: rgba(4, 6, 12, 0.9);
  border: 1px solid rgba(0, 240, 255, 0.2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: var(--font-code);
  font-size: 0.85rem;
  color: var(--cyan-primary);
  letter-spacing: 2px;
  word-break: break-all;
  max-height: 80px;
  overflow-y: auto;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
}

/* Received Message Display Box */
.msg-display {
  background: rgba(4, 6, 12, 0.85);
  border: 1px dashed rgba(0, 240, 255, 0.3);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: var(--font-code);
  font-size: 1rem;
  color: #ffffff;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.msg-display.empty {
  color: var(--text-dim);
  font-style: italic;
}
.msg-display.received {
  border: 1.5px solid var(--accent-green);
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.25);
  animation: glow-pulse-green 1.5s ease-out;
}

@keyframes glow-pulse-green {
  0% { box-shadow: 0 0 30px rgba(16, 185, 129, 0.8); }
  100% { box-shadow: 0 0 15px rgba(16, 185, 129, 0.25); }
}

/* Signal Strength Bar & Meters */
.meter-container {
  width: 100%;
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 5px;
  overflow: hidden;
  margin-top: 6px;
  position: relative;
}

.meter-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--cyan-secondary), var(--cyan-primary), var(--accent-green));
  transition: width 0.1s ease;
  box-shadow: 0 0 10px var(--cyan-glow);
}

/* Pipeline Stage Stepper */
.pipeline-flow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin: 16px 0;
  overflow-x: auto;
  padding-bottom: 6px;
}

.pipe-node {
  flex: 1;
  min-width: 65px;
  background: rgba(5, 8, 15, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 8px 4px;
  text-align: center;
  transition: all 0.2s ease;
}

.pipe-node .pipe-lbl {
  font-family: var(--font-code);
  font-size: 0.6rem;
  color: var(--text-dim);
  display: block;
}

.pipe-node .pipe-val {
  font-family: var(--font-code);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

.pipe-arrow {
  color: var(--text-dim);
  font-size: 0.75rem;
}

.pipe-node.active {
  border-color: var(--cyan-primary);
  background: rgba(0, 240, 255, 0.15);
  box-shadow: 0 0 10px var(--cyan-glow);
}
.pipe-node.active .pipe-val {
  color: var(--cyan-primary);
}

/* Canvas Oscilloscope / Spectrogram Canvas */
.canvas-box {
  width: 100%;
  height: 120px;
  background: rgba(4, 6, 12, 0.95);
  border: 1px solid rgba(0, 240, 255, 0.2);
  border-radius: var(--radius-sm);
  margin-top: 12px;
  position: relative;
  overflow: hidden;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Chat Feed Component */
.chat-feed {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 320px;
  overflow-y: auto;
  padding: 12px;
  background: rgba(4, 6, 12, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.chat-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  line-height: 1.4;
  position: relative;
}

.chat-bubble.outgoing {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.25) 0%, rgba(139, 92, 246, 0.25) 100%);
  border: 1px solid var(--border-cyan);
  border-bottom-right-radius: 2px;
  color: #fff;
}

.chat-bubble.incoming {
  align-self: flex-start;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom-left-radius: 2px;
  color: #e2e8f0;
}

.chat-meta {
  font-family: var(--font-code);
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-top: 4px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

/* Event Log Sidebar Container */
.sidebar-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.event-log {
  background: rgba(4, 6, 12, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  height: 280px;
  overflow-y: auto;
  padding: 10px;
  font-family: var(--font-code);
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.log-entry {
  padding: 2px 4px;
  border-left: 2px solid var(--text-dim);
}
.log-entry.info { border-color: var(--cyan-primary); color: #cbd5e1; }
.log-entry.rx { border-color: var(--accent-green); color: #a7f3d0; }
.log-entry.tx { border-color: var(--accent-purple); color: #e9d5ff; }
.log-entry.warn { border-color: var(--accent-amber); color: #fde68a; }
.log-entry.error { border-color: var(--accent-red); color: #fca5a5; }

/* Range Sliders */
.hud-slider {
  width: 100%;
  accent-color: var(--cyan-primary);
  cursor: pointer;
  margin: 8px 0;
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.open {
  display: flex;
}

.modal-content {
  background: var(--bg-panel-solid);
  border: 1px solid var(--cyan-primary);
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 500px;
  padding: 24px;
  box-shadow: 0 0 30px var(--cyan-glow);
}

/* Footer */
footer {
  margin-top: auto;
  padding-top: 24px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-dim);
  font-family: var(--font-code);
}
footer a {
  color: var(--cyan-primary);
  text-decoration: none;
}
footer a:hover {
  text-decoration: underline;
}

/* Responsive Touch Adjustments */
@media (max-width: 768px) {
  #app {
    padding: 10px;
  }
  .hud-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .header-actions {
    width: 100%;
    justify-content: space-between;
  }
  .nav-tabs {
    position: sticky;
    top: 10px;
    z-index: 50;
  }
}
