/**
 * SIMULATTE CORE CSS
 * Unified design system for all simulations
 * Color palette: Black background, Magenta & Green accents
 */

/* ============================================
   CSS VARIABLES
   ============================================ */
:root {
  /* Colors - Base Palette */
  --bg-dark: #000000;
  --bg-medium: #0f0f0f;
  --bg-light: #1a1a1a;
  --text-primary: #ffffff;
  --text-secondary: #a0a0a0;
  --border: #555555;
  --border-light: #333333;

  /* Accent Colors - Magenta & Green Theme */
  --accent-primary: #ff00ff;        /* Magenta */
  --accent-secondary: #00ff00;      /* Green */
  --accent-tertiary: #00ffff;       /* Cyan */
  --accent-magenta-dim: #cc00cc;    /* Dimmed magenta */
  --accent-green-dim: #00cc00;      /* Dimmed green */
  --accent-orange: #ff9933;         /* Orange for warnings/special cases */
  --accent-red: #ff4444;            /* Red for errors/danger */

  /* Shadows & Glows */
  --glow-magenta: 0 0 10px rgba(255, 0, 255, 0.5);
  --glow-green: 0 0 10px rgba(0, 255, 0, 0.5);
  --glow-cyan: 0 0 10px rgba(0, 255, 255, 0.5);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 6px 20px rgba(0, 0, 0, 0.6);

  /* Typography */
  --font-mono: 'Courier New', 'Consolas', 'Monaco', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 20px;
  --space-xl: 30px;

  /* Borders */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;
}

/* ============================================
   RESET & BASE STYLES
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Performance optimizations */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.6;
  /* Hardware acceleration */
  transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  font-weight: 500;
  line-height: 1.2;
  margin-bottom: var(--space-md);
}

h1 {
  font-size: 2rem;
  color: var(--accent-primary);
}

h2 {
  font-size: 1.5rem;
  color: var(--accent-primary);
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--space-sm);
}

h3 {
  font-size: 1.2rem;
  color: var(--accent-secondary);
}

p {
  margin-bottom: var(--space-md);
  color: var(--text-secondary);
}

a {
  color: var(--accent-secondary);
  text-decoration: none;
  transition: opacity 0.2s ease;
}

a:hover {
  opacity: 0.8;
}

code, pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

pre {
  background: var(--bg-medium);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-md);
  overflow-x: auto;
  margin-bottom: var(--space-md);
}

/* ============================================
   BUTTONS
   ============================================ */
button, .btn {
  display: inline-block;
  padding: 10px 20px;
  background: var(--bg-medium);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95em;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  user-select: none;
  white-space: nowrap;
}

button:hover:not(:disabled), .btn:hover:not(:disabled) {
  background: var(--bg-light);
  border-color: var(--accent-primary);
  box-shadow: var(--glow-magenta);
}

button:active:not(:disabled), .btn:active:not(:disabled) {
  background: var(--bg-medium);
}

button:disabled, .btn:disabled {
  background: var(--bg-light);
  color: #666666;
  border-color: var(--border-light);
  cursor: not-allowed;
  opacity: 0.6;
}

/* Button Variants */
.btn-primary {
  background: var(--accent-primary);
  color: #000000;
  border: none;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-magenta-dim);
  box-shadow: var(--glow-magenta);
}

.btn-secondary {
  background: var(--accent-secondary);
  color: #000000;
  border: none;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--accent-green-dim);
  box-shadow: var(--glow-green);
}

.btn-danger {
  background: var(--accent-red);
  color: #ffffff;
  border: none;
  font-weight: 600;
}

.btn-danger:hover:not(:disabled) {
  background: #dd2222;
  box-shadow: 0 0 10px rgba(255, 68, 68, 0.5);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--accent-primary);
  color: var(--accent-primary);
}

.btn-outline:hover:not(:disabled) {
  background: var(--accent-primary);
  color: #000000;
}

.btn-block {
  display: block;
  width: 100%;
}

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

.btn-ghost:hover:not(:disabled) {
  border-color: var(--accent-tertiary);
  color: var(--accent-tertiary);
  box-shadow: var(--glow-cyan);
}

/* ============================================
   FORM ELEMENTS
   ============================================ */
label {
  display: block;
  margin-bottom: var(--space-sm);
  color: var(--text-secondary);
  font-size: 0.9em;
  font-weight: 500;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="search"],
textarea,
select {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-medium);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95em;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(255, 0, 255, 0.2);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

/* Range Sliders */
input[type="range"] {
  width: 100%;
  height: 8px;
  background: var(--border-light);
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--accent-primary);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--glow-magenta);
  transition: all 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: var(--glow-magenta), 0 0 15px rgba(255, 0, 255, 0.8);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--accent-primary);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--glow-magenta);
  transition: all 0.2s ease;
}

input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.2);
  box-shadow: var(--glow-magenta), 0 0 15px rgba(255, 0, 255, 0.8);
}

/* Checkboxes & Radio */
input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent-primary);
}

/* ============================================
   PANELS & CARDS
   ============================================ */
.panel, .card {
  background: var(--bg-medium);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
}

.panel h2, .card h2 {
  margin-top: 0;
}

.panel-header,
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border);
}

.card-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.stat-grid {
  display: grid;
  gap: var(--space-sm);
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.stat-card,
.stat-mini {
  background: var(--bg-dark);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  text-align: center;
}

.stat-label,
.stat-mini-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.08em;
}

.stat-value,
.stat-mini-value {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  color: var(--accent-primary);
}

.value-display {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent-secondary);
  margin-left: var(--space-xs);
}

/* ============================================
   TOGGLE GROUPS & CHIPS
   ============================================ */
.toggle-group {
  display: inline-flex;
  gap: var(--space-sm);
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: var(--space-xs);
}

.toggle-button,
.toggle {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s ease;
}

.toggle-button.active,
.toggle.active {
  background: linear-gradient(135deg, rgba(255, 0, 255, 0.18), rgba(0, 255, 136, 0.18));
  color: var(--accent-primary);
  box-shadow: var(--glow-magenta);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.chip:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  box-shadow: var(--glow-magenta);
}

.chip-label {
  font-weight: 600;
  color: var(--text-primary);
}

.chip-remove {
  display: inline-flex;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: transparent;
  color: var(--accent-red);
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease;
}

.chip-remove:hover {
  background: rgba(255, 68, 68, 0.2);
}

/* ============================================
   PROGRESS BARS
   ============================================ */
.progress-container {
  background: var(--bg-light);
  border-radius: var(--radius-md);
  height: 30px;
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000000;
  font-weight: 600;
  font-size: 0.85em;
  transition: width 0.3s ease;
  box-shadow: var(--glow-magenta);
}

.progress-text {
  color: var(--text-secondary);
  font-size: 0.9em;
  margin-top: var(--space-sm);
  text-align: center;
}

/* ============================================
   TABLES
   ============================================ */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-medium);
  border-radius: var(--radius-md);
  overflow: hidden;
}

thead {
  background: var(--bg-light);
}

th {
  padding: var(--space-md);
  text-align: left;
  font-weight: 600;
  color: var(--accent-primary);
  border-bottom: 2px solid var(--border);
}

td {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-light);
}

tr:hover {
  background: var(--bg-light);
}

tr:last-child td {
  border-bottom: none;
}

/* ============================================
   MODALS & OVERLAYS
   ============================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: var(--bg-medium);
  border: 2px solid var(--accent-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg), var(--glow-magenta);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
}

.modal-close:hover {
  color: var(--accent-red);
}

/* ============================================
   NOTIFICATIONS
   ============================================ */
.notification {
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-md);
  border-left: 4px solid;
  background: var(--bg-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
}

.notification-info {
  border-left-color: var(--accent-tertiary);
}

.notification-success {
  border-left-color: var(--accent-secondary);
}

.notification-warning {
  border-left-color: var(--accent-orange);
}

.notification-error {
  border-left-color: var(--accent-red);
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-muted {
  color: var(--text-secondary);
}

.text-magenta {
  color: var(--accent-primary);
}

.text-green {
  color: var(--accent-secondary);
}

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.ml-sm { margin-left: var(--space-sm); }
.ml-md { margin-left: var(--space-md); }
.mr-sm { margin-right: var(--space-sm); }
.mr-md { margin-right: var(--space-md); }

.p-sm { padding: var(--space-sm); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }

.flex {
  display: flex;
}

.flex-column {
  flex-direction: column;
}

.flex-center {
  justify-content: center;
  align-items: center;
}

.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  :root {
    font-size: 14px;
  }

  h1 {
    font-size: 1.5rem;
  }

  h2 {
    font-size: 1.25rem;
  }

  .panel, .card {
    padding: var(--space-md);
  }
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

.loading {
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.spinner {
  animation: spin 1s linear infinite;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.fade-in {
  animation: fadeIn 0.3s ease-in;
}
