/* ============================================================
   NEURAL NETWORK PLAYGROUND — STYLES
   ============================================================ */

/* --- CSS Variables --- */
:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: #1a2236;
  --bg-card-hover: #1e2844;
  --bg-input: #0f1626;
  --border-color: #2a3550;
  --border-glow: rgba(79, 195, 247, 0.25);

  --text-primary: #e8ecf4;
  --text-secondary: #8b9dc3;
  --text-muted: #5a6b8a;

  --accent-primary: #4fc3f7;
  --accent-secondary: #7c4dff;
  --accent-gradient: linear-gradient(135deg, #4fc3f7, #7c4dff);
  --accent-glow: rgba(79, 195, 247, 0.15);

  --danger: #ef5350;
  --warning: #ffb74d;
  --success: #66bb6a;

  --class-a: #4fc3f7;
  --class-b: #ef5350;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);

  --font-main: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", monospace;

  --header-height: 56px;
  --sidebar-width: 300px;
  --footer-height: 36px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

/* --- Reset --- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-main);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ============================================================
   HEADER
   ============================================================ */
.app-header {
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.logo i {
  font-size: 1.4rem;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo strong {
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.epoch-display,
.loss-display,
.accuracy-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.epoch-label,
.loss-label,
.accuracy-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 500;
}

.epoch-value,
.loss-value,
.accuracy-value {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent-primary);
}

.loss-value {
  color: var(--warning);
}

.accuracy-value {
  color: var(--success);
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.app-main {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* ============================================================
   SIDEBAR CONTROLS
   ============================================================ */
.controls-panel {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.control-group {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 14px;
  border: 1px solid var(--border-color);
  transition: border-color var(--transition-normal);
}

.control-group:hover {
  border-color: var(--border-glow);
}

.control-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-title i {
  color: var(--accent-primary);
  font-size: 0.85rem;
}

/* --- Buttons --- */
.btn-row {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-family: var(--font-main);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
  flex: 1;
  justify-content: center;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 2px 12px rgba(79, 195, 247, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 4px 20px rgba(79, 195, 247, 0.5);
  transform: translateY(-1px);
}

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

.btn-warning {
  background: rgba(255, 183, 77, 0.15);
  color: var(--warning);
  border: 1px solid rgba(255, 183, 77, 0.3);
}

.btn-warning:hover {
  background: rgba(255, 183, 77, 0.25);
}

.btn-warning:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-danger {
  background: rgba(239, 83, 80, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 83, 80, 0.3);
}

.btn-danger:hover {
  background: rgba(239, 83, 80, 0.25);
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.75rem;
  width: 100%;
  margin-top: 8px;
}

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

.btn-outline:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.btn-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* --- Speed control --- */
.speed-control {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  min-width: 0;
}

.speed-control label {
  min-width: 36px;
  flex-shrink: 0;
}

.speed-control input[type="range"] {
  flex: 1;
  min-width: 0;
}

.speed-control span {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  width: 90px;
  flex-shrink: 0;
  white-space: nowrap;
  text-align: right;
}

/* --- Dataset buttons --- */
.dataset-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.dataset-btn {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-secondary);
  padding: 8px 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 0.65rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  font-family: var(--font-main);
}

.dataset-btn svg {
  width: 32px;
  height: 32px;
}

.dataset-btn:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.dataset-btn.active {
  border-color: var(--accent-primary);
  background: var(--accent-glow);
  color: var(--accent-primary);
  box-shadow: 0 0 12px rgba(79, 195, 247, 0.15);
}

/* --- Form rows --- */
.form-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.form-row label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  min-width: 50px;
}

.form-row input[type="range"] {
  flex: 1;
}

.form-row span {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  min-width: 36px;
  text-align: right;
}

.form-row select {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 6px 8px;
  font-family: var(--font-main);
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.form-row select:hover,
.form-row select:focus {
  border-color: var(--accent-primary);
  outline: none;
}

/* --- Range slider styling --- */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--border-color);
  border-radius: 2px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
  box-shadow: 0 0 6px rgba(79, 195, 247, 0.4);
}

/* --- Layer config --- */
.layer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.layer-add-remove {
  display: flex;
  gap: 4px;
}

.layer-neurons-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.layer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  border: 1px solid var(--border-color);
}

.layer-row .layer-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  min-width: 55px;
  font-weight: 500;
}

.layer-row input[type="range"] {
  flex: 1;
}

.layer-row .neuron-count {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-primary);
  min-width: 20px;
  text-align: center;
}

/* ============================================================
   VISUALIZATION AREA
   ============================================================ */
.viz-area {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  overflow-y: auto;
}

.viz-row {
  display: flex;
  gap: 14px;
  flex: 1;
  min-height: 0;
}

.viz-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  transition: border-color var(--transition-normal);
}

.viz-card:hover {
  border-color: var(--border-glow);
}

.viz-card-wide {
  flex: none;
}

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

.viz-card-header h2 {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.viz-card-header h2 i {
  color: var(--accent-primary);
}

.viz-card-actions {
  display: flex;
  gap: 12px;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  color: var(--text-muted);
  cursor: pointer;
}

.toggle-label input[type="checkbox"] {
  accent-color: var(--accent-primary);
}

.canvas-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  min-height: 0;
}

.canvas-wrap canvas {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius-sm);
}

.canvas-wrap-short {
  max-height: 200px;
}

/* ============================================================
   FOOTER
   ============================================================ */
.app-footer {
  height: var(--footer-height);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .app-main {
    flex-direction: column;
  }

  .controls-panel {
    width: 100%;
    min-width: 100%;
    max-height: 320px;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }

  .control-group {
    flex: 1;
    min-width: 200px;
  }

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

@media (max-width: 600px) {
  .header-right {
    gap: 10px;
  }

  .epoch-label,
  .loss-label,
  .accuracy-label {
    font-size: 0.6rem;
  }

  .epoch-value,
  .loss-value,
  .accuracy-value {
    font-size: 0.85rem;
  }

  .dataset-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .controls-panel {
    max-height: 400px;
  }
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes pulse-glow {
  0%,
  100% {
    box-shadow: 0 0 8px rgba(79, 195, 247, 0.2);
  }

  50% {
    box-shadow: 0 0 20px rgba(79, 195, 247, 0.45);
  }
}

.training-active .btn-primary {
  animation: pulse-glow 1.5s ease-in-out infinite;
}

/* --- CSV Custom Dataset styles --- */
.error-container {
  background: rgba(239, 83, 80, 0.08);
  border: 1px solid rgba(239, 83, 80, 0.25);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--danger);
  font-size: 0.75rem;
  margin-top: 10px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.35;
}

.error-container i {
  margin-top: 2px;
  flex-shrink: 0;
}

.success-container {
  background: rgba(102, 187, 106, 0.08);
  border: 1px solid rgba(102, 187, 106, 0.25);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--success);
  font-size: 0.75rem;
  margin-top: 10px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.35;
}

.success-container i {
  margin-top: 2px;
  flex-shrink: 0;
}

.disabled-row {
  opacity: 0.35;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.disabled-btn {
  opacity: 0.35;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

/* Accessibility: Respect user's reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  /* Disable decorative/infinite pulse on training button */
  .training-active .btn-primary {
    animation: none !important;
  }

  /* Disable opacity transitions on disabled state elements */
  .disabled-row,
  .disabled-btn {
    transition: none !important;
  }
}

/* ============================================================
   CUSTOM MULTI-LAYER PERCEPTRON (MLP) ENHANCEMENTS
   ============================================================ */

.gradient-display {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.gradient-label {
  font-size: 0.68rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.gradient-value {
  font-size: 0.85rem;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--success);
}

.section-title-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.badge-params {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  background: rgba(79, 195, 247, 0.12);
  color: var(--accent-primary);
  border: 1px solid rgba(79, 195, 247, 0.25);
}

.presets-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.presets-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.preset-chips {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.preset-chip {
  padding: 2px 7px;
  font-size: 0.7rem;
  font-weight: 500;
  border-radius: 4px;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.preset-chip:hover {
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

.preset-chip.active {
  background: rgba(79, 195, 247, 0.15);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  font-weight: 600;
}

.layer-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
}

.layer-label {
  font-size: 0.78rem;
  color: var(--text-primary);
  font-weight: 500;
  min-width: 65px;
}

.btn-layer-step {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  padding: 0;
}

.btn-layer-step:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--bg-card-hover);
}

.btn-layer-delete {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  padding: 0;
}

.btn-layer-delete:hover {
  color: var(--danger);
  border-color: rgba(239, 83, 80, 0.3);
  background: rgba(239, 83, 80, 0.08);
}

.architecture-summary {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  text-align: center;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--border-color);
}

.heatmap-legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding: 0 4px;
}

.legend-text {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.legend-bar {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, #0284c7 0%, #f8fafc 50%, #e11d48 100%);
  border: 1px solid var(--border-color);
}

.network-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 8px;
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.net-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot-pos {
  background: #4fc3f7;
  box-shadow: 0 0 4px rgba(79, 195, 247, 0.5);
}

.dot-neg {
  background: #ef5350;
  box-shadow: 0 0 4px rgba(239, 83, 80, 0.5);
}

.dot-pulse {
  background: #ffb74d;
  box-shadow: 0 0 6px #ffb74d;
}

.chart-dual-legend {
  display: flex;
  align-items: center;
  gap: 10px;
}

.legend-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  padding: 3px 9px;
  border-radius: var(--radius-sm);
}

.legend-loss {
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.dot-loss {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f59e0b;
  display: inline-block;
}

.legend-acc {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.dot-acc {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  display: inline-block;
}

.diagnostics-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-top: 12px;
}

.diagnostics-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--warning);
}

.diagnostics-header h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.diagnostics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.diagnostic-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.diag-label {
  font-size: 0.68rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.diag-val {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent-primary);
  font-family: var(--font-mono);
}

.diag-hint {
  font-size: 0.65rem;
  color: var(--text-muted);
}

