/**
 * Verisight Neural Interface
 * CSS Implementation for Nebula (dark) and Light Nebula mode
 * Based on Darkstar Deep Space theme
 */

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

/* ---------- Theme Variables ---------- */
:root {
  /* Default to nebula (dark) theme */
  --background: #0D0F18;
  --surface: #121525;
  --text: #E9EDF2;
  --text-secondary: #9EA4AD;
  --primary-accent: #5D87FF;
  --secondary-accent: #8A4DFF;
  --alert: #FF4D4D;
  --success: #4E9996;
  --border: #2A3048;
  --shadow: rgba(0, 10, 60, 0.18);
  --glow: rgba(77, 124, 255, 0.3);
  
  /* Typography */
  --font-primary: "Space Mono", monospace;
  --font-secondary: "Neurial Grotesk", sans-serif;
  
  /* Spacing */
  --spacing-quantum: 4px;
  --spacing-atomic: 8px;
  --spacing-molecular: 16px;
  --spacing-stellar: 24px;
  --spacing-nebular: 32px;
  --spacing-galactic: 64px;
  
  /* Borders */
  --radius-sharp: 0;
  --radius-minimal: 2px;
  --radius-standard: 4px;
  --radius-cosmic: 8px;
  --border-thin: 1px;
  --border-standard: 2px;
  --border-bold: 3px;
  
  /* Animations */
  --animation-fast: 150ms ease;
  --animation-standard: 300ms ease;
  --animation-slow: 500ms ease-in-out;
  
  /* Neural Grid */
  --neural-grid-size: 40px;
  --neural-grid-opacity: 0.1;
  --neural-grid-color: rgba(158, 164, 173, 0.4);
}

/* ---------- Global Styles ---------- */
body {
  font-family: var(--font-primary);
  color: var(--text);
  background-color: var(--background);
  line-height: 1.5;
  position: relative;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Neural Grid Background */
body::after {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    linear-gradient(to right, var(--neural-grid-color) 1px, transparent 1px),
    linear-gradient(to bottom, var(--neural-grid-color) 1px, transparent 1px);
  background-size: var(--neural-grid-size) var(--neural-grid-size);
  background-position: -1px -1px;
  opacity: var(--neural-grid-opacity);
  z-index: -1;
  pointer-events: none;
}

/* Light Nebula Theme */
body.light-nebula-mode {
  --background: #EAF0F7;
  --surface: #F5F8FC;
  --text: #1A2032;
  --text-secondary: #5B6278;
  --primary-accent: #3D5DD1;
  --secondary-accent: #6B45AB;
  --alert: #D63F3F;
  --success: #2B807D;
  --border: #D0D8E5;
  --shadow: rgba(59, 67, 113, 0.15);
  --glow: rgba(61, 93, 209, 0.25);
  --neural-grid-opacity: 0.04;
  --neural-grid-color: rgba(26, 32, 50, 0.4);
}

/* ---------- Layout Elements ---------- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--spacing-stellar);
}

header {
  margin-bottom: var(--spacing-nebular);
  text-align: center;
  position: relative;
  padding-bottom: var(--spacing-stellar);
}

header::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 25%;
  width: 50%;
  height: 1px;
  background: linear-gradient(90deg, 
    transparent, 
    var(--primary-accent), 
    transparent);
  opacity: 0.5;
}

.section-title {
  position: relative;
  font-size: 1.5rem;
  margin: var(--spacing-nebular) 0 var(--spacing-stellar);
  padding-bottom: var(--spacing-atomic);
  font-weight: 700;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

.section-title::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 80px;
  height: 2px;
  background: var(--primary-accent);
}

footer {
  margin-top: var(--spacing-galactic);
  padding: var(--spacing-stellar) 0;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  position: relative;
}

footer::before {
  content: "";
  position: absolute;
  top: 0;
  left: 25%;
  width: 50%;
  height: 1px;
  background: linear-gradient(90deg, 
    transparent, 
    var(--primary-accent), 
    transparent);
  opacity: 0.5;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 {
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: var(--spacing-molecular);
}

h1 {
  font-size: 2.5rem;
  margin-bottom: var(--spacing-atomic);
}

h2 {
  font-size: 2rem;
}

h3 {
  font-size: 1.5rem;
}

p {
  margin-bottom: var(--spacing-molecular);
}

.subtitle {
  font-size: 1.125rem;
  color: var(--text-secondary);
  font-weight: 400;
  letter-spacing: 0.5px;
}

/* ---------- Grid Layout ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--spacing-molecular);
  margin-bottom: var(--spacing-stellar);
}

.col-4 {
  grid-column: span 4;
}

.col-6 {
  grid-column: span 6;
}

.col-8 {
  grid-column: span 8;
}

.col-12 {
  grid-column: span 12;
}

/* ---------- Cards & Panels ---------- */
.card {
  background-color: var(--surface);
  border-radius: var(--radius-standard);
  padding: var(--spacing-stellar);
  margin-bottom: var(--spacing-stellar);
  position: relative;
  box-shadow: 0 var(--spacing-atomic) var(--spacing-stellar) var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

.inner-card {
  background-color: var(--background);
  border-radius: var(--radius-standard);
  padding: var(--spacing-molecular);
  margin-bottom: var(--spacing-molecular);
  position: relative;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
  border: 1px solid var(--border);
}

/* ---------- Neural Node ---------- */
.neural-node {
  width: 60px;
  height: 60px;
  position: relative;
  border-radius: 50%;
  background-color: var(--surface);
  box-shadow: 0 var(--spacing-atomic) var(--spacing-molecular) var(--shadow);
  border: 1px solid var(--text-secondary);
  margin: 0 auto;
  transition: all var(--animation-standard);
}

.neural-node.small {
  width: 40px;
  height: 40px;
}

.neural-node.large {
  width: 80px;
  height: 80px;
}

.neural-node .neural-core {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background-color: var(--text-secondary);
  transform: translate(-50%, -50%);
  opacity: 0.4;
  transition: all var(--animation-standard);
}

.neural-node.active {
  border-color: var(--primary-accent);
  box-shadow: 0 0 15px var(--glow), 0 var(--spacing-atomic) var(--spacing-molecular) var(--shadow);
}

.neural-node.active .neural-core {
  background-color: var(--primary-accent);
  opacity: 0.8;
  box-shadow: 0 0 10px var(--glow);
}

/* ---------- Quantum State Indicator ---------- */
.quantum-state {
  width: 120px;
  height: 120px;
  position: relative;
  border-radius: 50%;
  background-color: var(--surface);
  box-shadow: 0 var(--spacing-atomic) var(--spacing-molecular) var(--shadow);
  margin: 0 auto;
  padding: var(--spacing-atomic);
  overflow: hidden;
}

.quantum-state.small {
  width: 80px;
  height: 80px;
}

.quantum-state.large {
  width: 160px;
  height: 160px;
}

.quantum-state::before {
  content: "";
  position: absolute;
  top: 10%;
  left: 10%;
  width: 80%;
  height: 80%;
  border-radius: 50%;
  border: 1px solid var(--success);
  box-shadow: 0 0 10px rgba(78, 153, 150, 0.3);
  opacity: 0.6;
  animation: quantum-pulse 8s infinite ease-in-out;
}

.quantum-orbit {
  position: absolute;
  top: 15%;
  left: 15%;
  width: 70%;
  height: 70%;
  border-radius: 50%;
  border: 1px dashed var(--text-secondary);
  animation: quantum-orbit 8s infinite linear;
}

.quantum-particle {
  position: absolute;
  top: -5px;
  left: calc(50% - 5px);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.quantum-core {
  position: absolute;
  top: 40%;
  left: 40%;
  width: 20%;
  height: 20%;
  border-radius: 50%;
  background-color: var(--success);
  box-shadow: 0 0 15px var(--success);
}

/* Fluctuating state */
.quantum-state.fluctuating::before {
  border-color: #F9E589;
  box-shadow: 0 0 10px rgba(249, 229, 137, 0.3);
  animation: quantum-pulse 4s infinite ease-in-out;
}

.quantum-state.fluctuating .quantum-core {
  background-color: #F9E589;
  box-shadow: 0 0 15px rgba(249, 229, 137, 0.6);
}

.quantum-state.fluctuating .quantum-orbit {
  animation: quantum-orbit 4s infinite linear;
}

.quantum-state.fluctuating .quantum-particle {
  background-color: #F9E589;
  box-shadow: 0 0 8px rgba(249, 229, 137, 0.7);
}

/* Critical state */
.quantum-state.critical::before {
  border-color: var(--alert);
  box-shadow: 0 0 10px var(--alert);
  animation: quantum-pulse 1.5s infinite ease-in-out;
}

.quantum-state.critical .quantum-core {
  background-color: var(--alert);
  box-shadow: 0 0 15px var(--alert);
}

.quantum-state.critical .quantum-orbit {
  animation: quantum-orbit 1.5s infinite linear;
}

.quantum-state.critical .quantum-particle {
  background-color: var(--alert);
  box-shadow: 0 0 8px var(--alert);
}

/* Quantum animations */
@keyframes quantum-pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.6;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.3;
  }
}

@keyframes quantum-orbit {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* ---------- Constellation Map ---------- */
.constellation-map {
  width: 100%;
  height: 300px;
  position: relative;
  background-color: var(--background);
  border-radius: var(--radius-standard);
  box-shadow: 0 var(--spacing-atomic) var(--spacing-molecular) var(--shadow);
  overflow: hidden;
  border: 1px solid var(--border);
}

.constellation-grid {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    linear-gradient(to right, var(--neural-grid-color) 1px, transparent 1px),
    linear-gradient(to bottom, var(--neural-grid-color) 1px, transparent 1px);
  background-size: var(--neural-grid-size) var(--neural-grid-size);
  opacity: var(--neural-grid-opacity);
}

.constellation-node {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background-color: var(--text);
  box-shadow: 0 0 3px var(--text);
}

.constellation-line {
  position: absolute;
  height: 1px;
  background-color: var(--text-secondary);
  opacity: 0.4;
  transform-origin: 0 0;
}

/* ---------- Command Interface ---------- */
.command-interface {
  background-color: var(--background);
  color: var(--primary-accent);
  border: 1px solid var(--border);
  border-radius: var(--radius-standard);
  font-family: var(--font-primary);
  font-size: 14px;
  height: 200px;
  overflow: auto;
  position: relative;
  box-shadow: 0 var(--spacing-atomic) var(--spacing-molecular) var(--shadow);
}

.interface-header {
  height: 24px;
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}

.interface-content {
  padding: var(--spacing-molecular);
  position: relative;
  z-index: 0;
}

.command-line {
  margin-bottom: var(--spacing-atomic);
  opacity: 0;
  animation: fade-in 0.5s forwards;
}

.command-line::before {
  content: "> ";
  color: var(--primary-accent);
}

.command-cursor {
  display: inline-block;
  width: 8px;
  height: 14px;
  background-color: var(--primary-accent);
  animation: cursor-blink 1s step-end infinite;
  margin-left: 2px;
  vertical-align: middle;
}

@keyframes fade-in {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cursor-blink {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

/* ---------- Cosmic Data Panel ---------- */
.cosmic-panel {
  width: 100%;
  height: 300px;
  position: relative;
  background-color: var(--background);
  color: var(--text);
  border-radius: var(--radius-standard);
  box-shadow: 0 var(--spacing-atomic) var(--spacing-molecular) var(--shadow);
  overflow: hidden;
  border: 1px solid var(--border);
  padding: var(--spacing-molecular);
}

.panel-header {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-quantum) var(--spacing-atomic);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--spacing-atomic);
  z-index: 1;
}

.panel-title {
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
}

.panel-controls {
  display: flex;
  gap: var(--spacing-quantum);
}

.panel-content {
  position: relative;
  height: calc(100% - 40px);
  z-index: 1;
  overflow: auto;
}

.neural-grid-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    linear-gradient(to right, var(--neural-grid-color) 1px, transparent 1px),
    linear-gradient(to bottom, var(--neural-grid-color) 1px, transparent 1px);
  background-size: calc(var(--neural-grid-size) / 2) calc(var(--neural-grid-size) / 2);
  background-position: -1px -1px;
  opacity: var(--neural-grid-opacity);
  pointer-events: none;
  z-index: 0;
}

/* ---------- Elements ---------- */

/* Buttons */
.btn {
  position: relative;
  display: inline-block;
  padding: var(--spacing-atomic) var(--spacing-molecular);
  border-radius: var(--radius-minimal);
  border: none;
  font-family: var(--font-primary);
  font-weight: 400;
  font-size: 14px;
  cursor: pointer;
  transition: all var(--animation-standard);
  z-index: 1;
}

.btn-primary {
  background-color: var(--primary-accent);
  color: #ffffff;
  box-shadow: 0 var(--spacing-quantum) var(--spacing-molecular) var(--shadow);
}

.btn-primary:hover {
  box-shadow: 0 0 var(--spacing-molecular) var(--glow);
  transform: translateY(-2px);
}

.btn-secondary {
  background-color: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background-color: var(--surface);
  color: var(--text);
}

.btn-cosmic {
  background-color: var(--secondary-accent);
  color: #ffffff;
}

.btn-alert {
  background-color: var(--alert);
  color: #ffffff;
}

.button-group {
  display: flex;
  gap: var(--spacing-atomic);
  flex-wrap: wrap;
  margin-bottom: var(--spacing-molecular);
}

/* Form Elements */
.form-group {
  margin-bottom: var(--spacing-molecular);
}

label {
  display: block;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-atomic);
}

.input-field {
  display: block;
  width: 100%;
  padding: var(--spacing-molecular);
  font-family: var(--font-primary);
  font-size: 14px;
  color: var(--text);
  background-color: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius-minimal);
  transition: all var(--animation-standard);
}

.input-field:focus {
  outline: none;
  border-color: var(--primary-accent);
  box-shadow: 0 0 var(--spacing-molecular) var(--glow);
}

/* Badges */
.badge {
  display: inline-block;
  padding: var(--spacing-quantum) var(--spacing-atomic);
  border-radius: var(--radius-minimal);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-right: var(--spacing-atomic);
}

.badge-status {
  background-color: rgba(var(--primary-accent-rgb), 0.1);
  color: var(--primary-accent);
  border: 1px solid rgba(var(--primary-accent-rgb), 0.3);
}

.badge-warning {
  background-color: rgba(249, 229, 137, 0.1);
  color: #F9E589;
  border: 1px solid rgba(249, 229, 137, 0.3);
}

.badge-alert {
  background-color: rgba(var(--alert-rgb), 0.1);
  color: var(--alert);
  border: 1px solid rgba(var(--alert-rgb), 0.3);
}

.badge-success {
  background-color: rgba(var(--success-rgb), 0.1);
  color: var(--success);
  border: 1px solid rgba(var(--success-rgb), 0.3);
}

/* Progress Bars */
.progress-container {
  height: 8px;
  background-color: var(--background);
  border-radius: 0px;
  overflow: hidden;
  margin: var(--spacing-molecular) 0;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.progress-bar {
  height: 100%;
  background: var(--primary-accent);
  transition: width 0.5s ease;
}

.progress-status {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: var(--spacing-quantum);
}

/* Alerts */
.alert {
  padding: var(--spacing-molecular);
  border-radius: var(--radius-standard);
  margin-bottom: var(--spacing-molecular);
  position: relative;
  display: flex;
  align-items: center;
  border: 1px solid;
  background-color: rgba(var(--background-rgb), 0.3);
}

.alert-content {
  flex: 1;
}

.alert-title {
  font-weight: 700;
  margin-bottom: var(--spacing-quantum);
}

.alert-message {
  font-size: 14px;
}

.alert-info {
  border-color: var(--secondary-accent);
}

.alert-info .alert-title {
  color: var(--secondary-accent);
}

.alert-warning {
  border-color: #F9E589;
}

.alert-warning .alert-title {
  color: #F9E589;
}

.alert-danger {
  border-color: var(--alert);
}

.alert-danger .alert-title {
  color: var(--alert);
}

.alert-success {
  border-color: var(--success);
}

.alert-success .alert-title {
  color: var(--success);
}

/* Data List */
.data-list {
  list-style: none;
}

.data-item {
  padding: var(--spacing-molecular);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background-color 0.2s ease;
}

.data-item:hover {
  background-color: rgba(var(--background-rgb), 0.3);
}

.data-item:last-child {
  border-bottom: none;
}

.item-title {
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}

.item-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
}

.item-value {
  font-weight: 700;
  color: var(--primary-accent);
}

/* Theme toggle */
.theme-toggle {
  position: fixed;
  top: var(--spacing-molecular);
  right: var(--spacing-molecular);
  background-color: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: var(--spacing-atomic) var(--spacing-molecular);
  border-radius: var(--radius-standard);
  font-family: var(--font-primary);
  font-size: 14px;
  cursor: pointer;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: var(--spacing-atomic);
  transition: all var(--animation-standard);
}

.theme-toggle:hover {
  box-shadow: 0 0 var(--spacing-molecular) var(--glow);
}

.theme-toggle-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--background) 50%, var(--text) 50%);
  transform: rotate(0deg);
  transition: transform var(--animation-standard);
}

.light-nebula-mode .theme-toggle-icon {
  transform: rotate(180deg);
}

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

  .col-8, .col-4, .col-6, .col-12 {
    grid-column: 1 / -1;
  }
  
  .container {
    padding: var(--spacing-molecular);
  }
  
  h1 {
    font-size: 2rem;
  }
}

/* ---------- Helper Color Variables for RGBA ---------- */
/* Because we need RGB formats for transparent backgrounds */
:root {
  --primary-accent-rgb: 93, 135, 255;
  --secondary-accent-rgb: 138, 77, 255;
  --alert-rgb: 255, 77, 77;
  --success-rgb: 78, 153, 150;
  --background-rgb: 13, 15, 24;
}

body.light-nebula-mode {
  --primary-accent-rgb: 61, 93, 209;
  --secondary-accent-rgb: 107, 69, 171;
  --alert-rgb: 214, 63, 63;
  --success-rgb: 43, 128, 125;
  --background-rgb: 234, 240, 247;
}