/* ==========================================
   CSS VARIABLE TOKENS & RESET
   ========================================== */
:root {
  --bg-deep: #080a12;
  --bg-darker: #0d111d;
  --bg-panel: rgba(20, 26, 46, 0.65);
  --bg-panel-hover: rgba(28, 36, 62, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(0, 210, 255, 0.5);
  
  --accent-cyan: #00d2ff;
  --accent-blue: #0066ff;
  --accent-yellow: #ffe600;
  --accent-green: #00ff88;
  --accent-purple: #bd00ff;
  
  --text-main: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --text-dark: #090d16;
  
  --glow-cyan: 0 0 15px rgba(0, 210, 255, 0.4);
  --glow-cyan-strong: 0 0 25px rgba(0, 210, 255, 0.7);
  --glow-yellow: 0 0 15px rgba(255, 230, 0, 0.4);
  
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'Fira Code', source-code-pro, Menlo, Monaco, Consolas, monospace;
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
}

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

body {
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
  position: relative;
  line-height: 1.5;
}

/* ==========================================
   AMBIENT DECORATIVE BACKGROUNDS
   ========================================== */
.glow-bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(140px);
  z-index: -1;
  pointer-events: none;
  opacity: 0.2;
}

.orb-1 {
  width: 500px;
  height: 500px;
  background: var(--accent-cyan);
  top: -100px;
  right: -50px;
}

.orb-2 {
  width: 600px;
  height: 600px;
  background: var(--accent-purple);
  bottom: -200px;
  left: -100px;
}

/* ==========================================
   APPLICATION WRAPPER & HEADER
   ========================================== */
.app-container {
  width: 100%;
  max-width: 1400px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  gap: 1.5rem;
  flex-wrap: wrap;
}

.header-logo-area {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-icon {
  font-size: 2.5rem;
  text-shadow: var(--glow-cyan);
  animation: float 4s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

h1 {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 30%, var(--accent-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

#app-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 400;
}

.header-badge {
  display: flex;
  gap: 0.5rem;
}

.badge-chip {
  padding: 0.4rem 0.8rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chip-esp {
  background: rgba(255, 102, 0, 0.15);
  color: #ff6600;
  border: 1px solid rgba(255, 102, 0, 0.3);
}

.chip-oled {
  background: rgba(0, 210, 255, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 210, 255, 0.3);
  box-shadow: 0 0 10px rgba(0, 210, 255, 0.1);
}

/* ==========================================
   GLASSMORPHISM CARD STYLING
   ========================================== */
.glass-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 1.5rem;
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.glass-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

/* ==========================================
   GRID LAYOUT
   ========================================== */
.app-main-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 2rem;
  align-items: start;
}

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

/* ==========================================
   SIDEBAR: CONTROLS & SETTINGS
   ========================================== */
.sidebar-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-height: 85vh;
  overflow-y: auto;
  padding-right: 1.25rem;
}

/* Custom Scrollbar for Sidebar */
.sidebar-panel::-webkit-scrollbar {
  width: 6px;
}

.sidebar-panel::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.sidebar-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.section-title:first-of-type {
  margin-top: 0;
}

.step-num {
  width: 24px;
  height: 24px;
  background: var(--accent-cyan);
  color: var(--text-dark);
  font-weight: 700;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  box-shadow: var(--glow-cyan);
}

.section-title h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: -0.2px;
}

/* ==========================================
   FILE UPLOAD DROP ZONE
   ========================================== */
.upload-drop-zone {
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.2);
  transition: all var(--transition-normal);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  position: relative;
}

.upload-drop-zone:hover, .upload-drop-zone.dragover {
  border-color: var(--accent-cyan);
  background: rgba(0, 210, 255, 0.04);
  box-shadow: inset 0 0 15px rgba(0, 210, 255, 0.05);
}

.upload-drop-zone.dragover {
  transform: scale(0.98);
}

.upload-icon {
  font-size: 2.2rem;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.upload-drop-zone h3 {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-main);
}

.upload-drop-zone p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.file-input-hidden {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* ==========================================
   INPUTS, SELECTS & SLIDERS
   ========================================== */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.row-inputs {
  display: flex;
  flex-direction: row;
  gap: 0.75rem;
}

.row-inputs > * {
  flex: 1;
}

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

select, input[type="text"], input[type="number"] {
  width: 100%;
  padding: 0.6rem 0.8rem;
  background: var(--bg-darker);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  outline: none;
  transition: all var(--transition-fast);
}

select:focus, input[type="text"]:focus, input[type="number"]:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 8px rgba(0, 210, 255, 0.2);
}

/* Custom Checkbox */
.checkbox-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

.checkbox-field input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--bg-darker);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  display: grid;
  place-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.checkbox-field input[type="checkbox"]:checked {
  background: var(--accent-cyan);
  border-color: var(--accent-cyan);
  box-shadow: var(--glow-cyan);
}

.checkbox-field input[type="checkbox"]::before {
  content: "✓";
  font-size: 11px;
  color: var(--text-dark);
  font-weight: 800;
  transform: scale(0);
  transition: transform var(--transition-fast);
}

.checkbox-field input[type="checkbox"]:checked::before {
  transform: scale(1);
}

.checkbox-field label {
  cursor: pointer;
  font-size: 0.88rem;
}

.inline-checkbox {
  align-self: flex-end;
  height: 38px;
}

/* Custom Sliders */
.slider-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.slider-label-area {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.slider-val {
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: var(--accent-cyan);
  background: rgba(0, 210, 255, 0.1);
  padding: 1px 6px;
  border-radius: 4px;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: var(--bg-darker);
  border-radius: 3px;
  outline: none;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

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

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* ==========================================
   BUTTONS
   ========================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-normal);
  border: 1px solid transparent;
  outline: none;
}

.btn-primary {
  background: var(--accent-cyan);
  color: var(--text-dark);
  box-shadow: var(--glow-cyan);
}

.btn-primary:hover {
  background: #33e0ff;
  box-shadow: var(--glow-cyan-strong);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.05);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.btn-sm {
  padding: 0.5rem 0.9rem;
  font-size: 0.85rem;
}

.btn-md {
  padding: 0.7rem 1.4rem;
  font-size: 0.95rem;
}

/* ==========================================
   RIGHT CONTENT: PREVIEW & CODE PANELS
   ========================================== */
.main-preview-area {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* PREVIEW TABS */
.preview-tabs {
  padding: 0;
  overflow: hidden;
}

.tab-header {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.15);
}

.tab-btn {
  padding: 1rem 1.5rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
  background: rgba(0, 210, 255, 0.03);
}

.tab-content {
  display: none;
  padding: 2rem;
}

.tab-content.active {
  display: block;
}

/* ==========================================
   PHYSICAL OLED SCREEN EMULATOR
   ========================================== */
.oled-emulator-casing {
  background: linear-gradient(135deg, #181c2b 0%, #0c0f1a 100%);
  border: 4px solid #23293f;
  box-shadow: 
    0 15px 35px rgba(0,0,0,0.5), 
    inset 0 2px 5px rgba(255,255,255,0.05),
    0 0 0 2px #0a0c14;
  border-radius: var(--radius-md);
  padding: 1.5rem;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

/* Top Pins of OLED module board */
.oled-top-pins {
  display: flex;
  gap: 1.2rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 0.5rem;
  width: 100%;
  justify-content: center;
}

.oled-top-pins span {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  position: relative;
}

.oled-top-pins span::before {
  content: "";
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 5px;
  height: 5px;
  background: #b58900;
  border-radius: 1px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

/* Glass Screen Bezel */
.oled-screen-frame {
  background: #020205;
  border: 10px solid #0b0e17;
  border-radius: 8px;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.9);
  padding: 12px;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* OLED Glowing Panel */
.oled-glass {
  background-color: #000000;
  border: 1px solid #111;
  width: 320px;
  height: 160px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.95);
}

.oled-glass canvas {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(0 0 2px rgba(0, 210, 255, 0.85));
}

.scanlines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    rgba(18, 16, 16, 0) 50%, 
    rgba(0, 0, 0, 0.25) 50%
  ), linear-gradient(
    90deg,
    rgba(255, 0, 0, 0.03),
    rgba(0, 255, 0, 0.01),
    rgba(0, 0, 255, 0.03)
  );
  background-size: 100% 4px, 6px 100%;
  pointer-events: none;
  z-index: 2;
}

/* Bezel screen reflections */
.oled-glass::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 50%;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0) 100%);
  pointer-events: none;
  z-index: 3;
}

.oled-placeholder-message {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.5rem;
  color: #12213a;
  z-index: 1;
}

.oled-placeholder-message span {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 1px;
}

.oled-placeholder-message small {
  font-size: 0.7rem;
  max-width: 200px;
}

.oled-bottom-branding {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin-top: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.oled-type-lbl {
  font-weight: 600;
}

/* ==========================================
   PLAYBACK BAR CONTROLS
   ========================================== */
.playback-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  width: 100%;
  max-width: 480px;
  margin-top: 1.5rem;
  border: 1px solid var(--border-color);
  transition: opacity var(--transition-normal);
}

.playback-bar.disabled {
  opacity: 0.3;
  pointer-events: none;
}

.ctrl-btn {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: background var(--transition-fast);
}

.ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.playback-slider-container {
  flex: 1;
  display: flex;
  align-items: center;
}

.frame-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 75px;
}

#frame-counter {
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: var(--accent-cyan);
}

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

/* ==========================================
   COMPARISON SCREEN TAB
   ========================================== */
.comparison-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

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

.compare-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.compare-card h3 {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.compare-container {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  aspect-ratio: 2 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0.5rem;
}

.compare-container img, .compare-container canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.compare-placeholder {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ==========================================
   CODE EXPORT PANEL
   ========================================== */
.code-export-panel {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.code-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.file-name-tab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent-cyan);
}

.code-actions {
  display: flex;
  gap: 0.5rem;
}

.code-block-wrapper {
  padding: 1.25rem;
  background: #04060b;
  overflow: auto;
  max-height: 420px;
}

pre {
  margin: 0;
}

code {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
  color: #c9d1d9;
  display: block;
}

/* Code syntax highlighting colors */
.cpp-comment { color: #8b949e; font-style: italic; }
.cpp-directive { color: #ff7b72; font-weight: 500; }
.cpp-keyword { color: #ff7b72; font-weight: 600; }
.cpp-type { color: #79c0ff; font-weight: 500; }
.cpp-number { color: #79c0ff; }
.cpp-string { color: #a5d6ff; }
.cpp-literal { color: #d2a8ff; }
.cpp-ident { color: #ffa657; }

/* ==========================================
   FOOTER
   ========================================== */
.app-footer {
  text-align: center;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border-color);
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ==========================================
   VIDEO PROGRESS INDICATOR & VIDEO CONFIG
   ========================================== */
.oled-progress-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(8, 10, 18, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  z-index: 10;
}

.progress-title {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-cyan);
  text-shadow: var(--glow-cyan);
  letter-spacing: 1px;
}

.progress-bar {
  width: 70%;
  height: 8px;
  background: var(--bg-deep);
  border: 1px solid rgba(0, 210, 255, 0.3);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.5);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background-color: var(--accent-cyan);
  box-shadow: var(--glow-cyan);
  transition: width 0.05s ease-out;
}

.progress-percent {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent-cyan);
  text-shadow: var(--glow-cyan);
}

#video-config {
  transition: all var(--transition-normal);
}

#video-config label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

#video-config input[type="number"], #video-config select {
  font-size: 0.85rem;
  padding: 0.45rem 0.6rem;
}

