/* =============================================================================
   EcrioniX Mini AI Accelerator Studio - Main Stylesheet
   Designed for Desktop, Tablet, and Mobile with Dark / Light Theme Support
   ============================================================================= */

:root, :root[data-theme="light"], html.light-theme {
  --studio-bg: #f8fafc;
  --studio-card-bg: #ffffff;
  --studio-card-border: rgba(15, 23, 42, 0.12);
  --studio-accent-cyan: #0284c7;
  --studio-accent-teal: #0d9488;
  --studio-accent-purple: #7e22ce;
  --studio-accent-amber: #d97706;
  --studio-accent-green: #059669;
  --studio-accent-red: #dc2626;
  --studio-text: #0f172a;
  --studio-text-muted: #475569;
  --studio-code-bg: #f1f5f9;
}

:root[data-theme="dark"], html.dark-theme {
  --studio-bg: #070b12;
  --studio-card-bg: #0c121d;
  --studio-card-border: rgba(255, 255, 255, 0.08);
  --studio-accent-cyan: #00e5ff;
  --studio-accent-teal: #14b8a6;
  --studio-accent-purple: #a855f7;
  --studio-accent-amber: #f59e0b;
  --studio-accent-green: #10b981;
  --studio-accent-red: #ef4444;
  --studio-text: #f8fafc;
  --studio-text-muted: #94a3b8;
  --studio-code-bg: #05080e;
}

.studio-page {
  background-color: var(--studio-bg);
  color: var(--studio-text);
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

/* Studio Hero */
.studio-hero {
  padding: 3.5rem 1.5rem 2.5rem;
  text-align: center;
  background: radial-gradient(ellipse at 50% 0%, rgba(0, 229, 255, 0.14) 0%, rgba(12, 18, 29, 0) 70%),
              linear-gradient(180deg, rgba(12, 18, 29, 0.8) 0%, var(--studio-bg) 100%);
  border-bottom: 1px solid var(--studio-card-border);
}
:root[data-theme="light"] .studio-hero {
  background: radial-gradient(ellipse at 50% 0%, rgba(2, 132, 199, 0.12) 0%, rgba(248, 250, 252, 0) 70%),
              linear-gradient(180deg, #ffffff 0%, var(--studio-bg) 100%);
}

.studio-hero-container {
  max-width: 1100px;
  margin: 0 auto;
}

.studio-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  background: rgba(0, 229, 255, 0.1);
  border: 1px solid rgba(0, 229, 255, 0.3);
  border-radius: 9999px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--studio-accent-cyan);
  margin-bottom: 1rem;
}
:root[data-theme="light"] .studio-badge {
  background: rgba(2, 132, 199, 0.1);
  border-color: rgba(2, 132, 199, 0.3);
  color: #0284c7;
}

.studio-title {
  font-family: 'Orbitron', 'Outfit', sans-serif;
  font-size: clamp(2rem, 4.5vw, 3.1rem);
  font-weight: 800;
  line-height: 1.2;
  margin: 0 0 1rem;
  letter-spacing: -0.5px;
}
.studio-title span {
  background: linear-gradient(135deg, #00e5ff 0%, #38bdf8 50%, #a855f7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
:root[data-theme="light"] .studio-title span {
  background: linear-gradient(135deg, #0284c7 0%, #4338ca 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.studio-subtitle {
  font-size: 1.1rem;
  color: var(--studio-text-muted);
  max-width: 820px;
  margin: 0 auto 2rem;
  line-height: 1.6;
}

/* Studio Navigation Tabs */
.studio-nav-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  max-width: 1100px;
  margin: 0 auto;
}
.studio-tab-btn {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--studio-card-border);
  color: var(--studio-text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  white-space: nowrap;
}
.studio-tab-btn:hover,
.studio-tab-btn.is-active {
  background: rgba(0, 229, 255, 0.15);
  border-color: var(--studio-accent-cyan);
  color: var(--studio-accent-cyan);
  transform: translateY(-1px);
}
:root[data-theme="light"] .studio-tab-btn {
  background: #ffffff;
  color: #475569;
}
:root[data-theme="light"] .studio-tab-btn:hover,
:root[data-theme="light"] .studio-tab-btn.is-active {
  background: rgba(2, 132, 199, 0.12);
  border-color: #0284c7;
  color: #0284c7;
}

/* Main Studio Layout */
.studio-main {
  max-width: 1360px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 5rem;
  display: flex;
  flex-direction: column;
  gap: 3.5rem;
  box-sizing: border-box;
}

/* Common Section Container */
.studio-section {
  background: var(--studio-card-bg);
  border: 1px solid var(--studio-card-border);
  border-radius: 18px;
  padding: 2rem;
  box-shadow: 0 4px 25px rgba(0, 0, 0, 0.25);
  box-sizing: border-box;
}
:root[data-theme="light"] .studio-section {
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.05);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  border-bottom: 1px solid var(--studio-card-border);
  padding-bottom: 1.25rem;
  margin-bottom: 1.75rem;
}
.section-head-left h2 {
  font-family: 'Orbitron', 'Outfit', sans-serif;
  font-size: 1.45rem;
  font-weight: 700;
  margin: 0 0 0.35rem;
}
.section-head-left p {
  color: var(--studio-text-muted);
  font-size: 0.95rem;
  margin: 0;
}

/* ═══════════════════════════════════════════════════════════════
   SECTION 1: CANVAS & PREPROCESSOR
   ═══════════════════════════════════════════════════════════════ */
.canvas-grid-layout {
  display: grid;
  grid-template-columns: 320px 1fr 280px;
  gap: 2rem;
  align-items: start;
}
@media (max-width: 1024px) {
  .canvas-grid-layout {
    grid-template-columns: 1fr;
  }
}

.canvas-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.drawing-canvas {
  width: 280px;
  height: 280px;
  background: #000000;
  border: 2px solid var(--studio-accent-cyan);
  border-radius: 12px;
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.2);
  cursor: crosshair;
  touch-action: none;
}
:root[data-theme="light"] .drawing-canvas {
  border-color: #0284c7;
  box-shadow: 0 4px 15px rgba(2, 132, 199, 0.2);
}

.canvas-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  width: 100%;
}
.btn-studio {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.6rem 1.1rem;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
  border: none;
}
.btn-studio-cyan {
  background: linear-gradient(135deg, #00e5ff, #0284c7);
  color: #070b12;
  font-weight: 700;
}
.btn-studio-cyan:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 229, 255, 0.4);
}
.btn-studio-secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--studio-card-border);
  color: var(--studio-text);
}
.btn-studio-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--studio-accent-cyan);
}

/* Quick MNIST Sample Buttons */
.samples-card {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.samples-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
}
.sample-digit-btn {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--studio-card-border);
  border-radius: 8px;
  color: var(--studio-text);
  font-family: 'Orbitron', monospace;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}
.sample-digit-btn:hover,
.sample-digit-btn.is-active {
  background: rgba(0, 229, 255, 0.2);
  border-color: var(--studio-accent-cyan);
  color: var(--studio-accent-cyan);
  transform: scale(1.05);
}

/* Live Prediction Banner */
.prediction-box {
  background: rgba(0, 229, 255, 0.05);
  border: 1px solid rgba(0, 229, 255, 0.25);
  border-radius: 14px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.pred-digit-display {
  font-family: 'Orbitron', monospace;
  font-size: 3.5rem;
  font-weight: 800;
  line-height: 1;
  color: var(--studio-accent-cyan);
  margin: 0.5rem 0;
  text-shadow: 0 0 20px rgba(0, 229, 255, 0.5);
}
.pred-label {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--studio-text-muted);
}
.confidence-bar-wrap {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 0.5rem;
}
.confidence-bar-fill {
  height: 100%;
  background: var(--studio-accent-cyan);
  width: 0%;
  transition: width 0.3s ease;
}

/* ═══════════════════════════════════════════════════════════════
   SECTION 2: PIXEL MATRIX EXPLORER
   ═══════════════════════════════════════════════════════════════ */
.pixel-explorer-layout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2rem;
}
@media (max-width: 900px) {
  .pixel-explorer-layout {
    grid-template-columns: 1fr;
  }
}

.pixel-grid-container {
  display: inline-grid;
  grid-template-columns: repeat(28, 10px);
  grid-template-rows: repeat(28, 10px);
  gap: 1px;
  background: rgba(255, 255, 255, 0.15);
  padding: 2px;
  border-radius: 6px;
  border: 1px solid var(--studio-card-border);
}
.pixel-cell {
  width: 10px;
  height: 10px;
  background-color: #000;
  cursor: pointer;
  transition: transform 0.1s;
}
.pixel-cell:hover {
  transform: scale(1.6);
  z-index: 10;
  outline: 1px solid var(--studio-accent-cyan);
}

.pixel-info-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  justify-content: center;
}
.pixel-info-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.85rem;
}
.stat-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--studio-card-border);
  border-radius: 10px;
  padding: 0.85rem;
}
.stat-box-label {
  font-size: 0.75rem;
  color: var(--studio-text-muted);
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}
.stat-box-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--studio-accent-cyan);
}

/* ═══════════════════════════════════════════════════════════════
   SECTION 3: NEURAL NETWORK ARCHITECTURE
   ═══════════════════════════════════════════════════════════════ */
.nn-vis-wrap {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.nn-layers-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.5rem;
}
.nn-layer-column {
  flex: 1;
  min-width: 220px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--studio-card-border);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.nn-layer-title {
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
}
.neuron-pills-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.35rem;
}
.neuron-pill {
  height: 26px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-family: 'JetBrains Mono', monospace;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.neuron-pill:hover,
.neuron-pill.is-selected {
  background: var(--studio-accent-cyan);
  color: #070b12;
  font-weight: 700;
  transform: scale(1.1);
}

.receptive-field-box {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--studio-card-border);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.weight-heatmap-canvas {
  width: 140px;
  height: 140px;
  border-radius: 8px;
  image-rendering: pixelated;
  border: 1px solid var(--studio-card-border);
}

/* ═══════════════════════════════════════════════════════════════
   SECTION 4: HARDWARE MICROARCHITECTURE
   ═══════════════════════════════════════════════════════════════ */
.arch-diagram-wrap {
  width: 100%;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}
.arch-svg {
  width: 100%;
  min-width: 800px;
  max-width: 1100px;
  margin: 0 auto;
  display: block;
}
.arch-block {
  cursor: pointer;
  transition: opacity 0.2s, filter 0.2s;
}
.arch-block:hover {
  filter: drop-shadow(0 0 10px rgba(0, 229, 255, 0.6));
}

.block-detail-modal {
  display: none;
  background: var(--studio-code-bg);
  border: 1px solid var(--studio-accent-cyan);
  border-radius: 12px;
  padding: 1.25rem;
  margin-top: 1.25rem;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════════════════════════
   SECTION 5: LIVE HARDWARE SIMULATION & CYCLE STEPPER
   ═══════════════════════════════════════════════════════════════ */
.stepper-dashboard {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.stepper-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--studio-card-border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
}
.stepper-btn-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}
.telemetry-card {
  background: var(--studio-code-bg);
  border: 1px solid var(--studio-card-border);
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.telemetry-label {
  font-size: 0.75rem;
  color: var(--studio-text-muted);
  text-transform: uppercase;
  font-weight: 600;
}
.telemetry-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--studio-accent-cyan);
}
.telemetry-val.highlight-acc {
  color: var(--studio-accent-amber);
}

/* Simulation Console Output */
.sim-console-output {
  background: #000000;
  color: #38bdf8;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  line-height: 1.45;
  padding: 1rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ═══════════════════════════════════════════════════════════════
   SECTION 6: VCD WAVEFORM VIEWER
   ═══════════════════════════════════════════════════════════════ */
.waveform-section-wrap {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.waveform-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  background: var(--studio-code-bg);
  border: 1px solid var(--studio-card-border);
  border-radius: 8px;
}
.waveform-viewport {
  position: relative;
  width: 100%;
  height: 380px;
  background: #04070d;
  border: 1px solid var(--studio-card-border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
}
.wave-names-panel {
  width: 180px;
  height: 100%;
  background: #080d17;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  overflow-y: hidden;
  flex-shrink: 0;
}
.wave-name-row {
  height: 32px;
  line-height: 32px;
  padding: 0 0.75rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.76rem;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.wave-canvas-scroll {
  flex: 1;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  cursor: crosshair;
}
#waveCanvas {
  display: block;
}

/* ═══════════════════════════════════════════════════════════════
   SECTION 7: RTL SOURCE CODE EXPLORER
   ═══════════════════════════════════════════════════════════════ */
.rtl-explorer-wrap {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.rtl-tabs-bar {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}
.rtl-tab-btn {
  padding: 0.45rem 0.85rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--studio-card-border);
  border-radius: 6px;
  color: var(--studio-text-muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
}
.rtl-tab-btn.is-active {
  background: rgba(0, 229, 255, 0.15);
  border-color: var(--studio-accent-cyan);
  color: var(--studio-accent-cyan);
  font-weight: 600;
}

.code-viewer-container {
  position: relative;
  background: var(--studio-code-bg);
  border: 1px solid var(--studio-card-border);
  border-radius: 10px;
  overflow: hidden;
}
.code-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--studio-card-border);
}
.code-viewer-pre {
  margin: 0;
  padding: 1rem;
  max-height: 480px;
  overflow: auto;
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 0.84rem;
  line-height: 1.5;
  color: #e2e8f0;
}

/* ═══════════════════════════════════════════════════════════════
   SECTION 8: GUIDED ARCHITECTURE LESSONS
   ═══════════════════════════════════════════════════════════════ */
.lessons-accordion {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.lesson-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--studio-card-border);
  border-radius: 10px;
  overflow: hidden;
}
.lesson-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  cursor: pointer;
  font-weight: 600;
  user-select: none;
}
.lesson-card-header:hover {
  color: var(--studio-accent-cyan);
}
.lesson-card-body {
  display: none;
  padding: 1.25rem;
  border-top: 1px solid var(--studio-card-border);
  color: var(--studio-text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
}
.lesson-card.is-open .lesson-card-body {
  display: block;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .studio-section {
    padding: 1.25rem;
  }
  .drawing-canvas {
    width: 240px;
    height: 240px;
  }
}
