/* ==========================================================================
   WEB SERIAL STUDIO - CYBERPUNK GLASSMORPHISM DESIGN SYSTEM
   100vh Single Screen Layout with Zero Page Scrolling
   ========================================================================== */

:root {
  --bg-core: #030712;
  --bg-surface: rgba(15, 23, 42, 0.75);
  --bg-surface-elevated: rgba(30, 41, 59, 0.7);
  --bg-glass-card: rgba(15, 23, 42, 0.65);
  --bg-terminal: #050811;

  --neon-cyan: #00f0ff;
  --neon-green: #10b981;
  --neon-purple: #b05cff;
  --neon-amber: #f59e0b;
  --neon-rose: #f43f5e;
  --neon-blue: #38bdf8;

  --border-glass: rgba(255, 255, 255, 0.08);
  --border-cyan-glow: rgba(0, 240, 255, 0.35);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --transition-smooth: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body.studio-app {
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  background-color: var(--bg-core);
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(0, 240, 255, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(176, 92, 255, 0.05) 0%, transparent 40%),
    linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 32px 32px, 32px 32px;
  color: var(--text-main);
  font-family: var(--font-display);
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   TOP NAVIGATION BAR
   ========================================================================== */
.studio-header {
  height: 58px;
  min-height: 58px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-glass);
  backdrop-filter: blur(16px);
  z-index: 100;
  flex-shrink: 0;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon-wrapper {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.2), rgba(176, 92, 255, 0.2));
  border: 1px solid var(--border-cyan-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--neon-cyan);
}

.logo-svg {
  width: 18px;
  height: 18px;
}

.brand-title {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.version-tag {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 240, 255, 0.15);
  border: 1px solid var(--neon-cyan);
  color: var(--neon-cyan);
}

.brand-subtitle {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 14px;
}

.step-control-group {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.35);
  padding: 4px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
}

.step-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--neon-cyan);
  color: #030712;
  font-size: 0.72rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
}

.device-pill {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid var(--border-glass);
}

.device-pill.connected {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.4);
  color: var(--neon-green);
}

.nav-control-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-dim);
}

.auto-badge {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--neon-green);
  border: 1px solid rgba(16, 185, 129, 0.4);
}

/* Status Pill */
.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 20px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid var(--border-glass);
  background: rgba(0, 0, 0, 0.4);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-disconnected .status-dot {
  background: var(--text-dim);
}
.status-connected {
  border-color: rgba(16, 185, 129, 0.4);
  color: var(--neon-green);
}
.status-connected .status-dot {
  background: var(--neon-green);
  box-shadow: 0 0 10px var(--neon-green);
}
.status-flashing {
  border-color: rgba(0, 240, 255, 0.4);
  color: var(--neon-cyan);
}
.status-flashing .status-dot {
  background: var(--neon-cyan);
  box-shadow: 0 0 10px var(--neon-cyan);
  animation: pulse-flash 1s infinite alternate;
}

@keyframes pulse-flash {
  from { opacity: 0.4; }
  to { opacity: 1; }
}

/* ==========================================================================
   WORKSPACE SPLIT PANE (50% / 50% NO SCROLL)
   ========================================================================== */
.studio-workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 460px 1fr;
  gap: 12px;
  padding: 12px;
  overflow: hidden;
}

.studio-pane {
  background: var(--bg-surface);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.pane-header {
  height: 44px;
  min-height: 44px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid var(--border-glass);
}

.pane-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pane-icon {
  width: 16px;
  height: 16px;
  color: var(--neon-cyan);
}

.pane-title {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.badge-client-only {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(176, 92, 255, 0.15);
  border: 1px solid rgba(176, 92, 255, 0.4);
  color: var(--neon-purple);
}

/* ==========================================================================
   LEFT PANE: DIRECT FLASHER
   ========================================================================== */
.flasher-body {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

.upload-dropzone {
  border: 2px dashed rgba(0, 240, 255, 0.3);
  border-radius: var(--radius-md);
  background: rgba(0, 240, 255, 0.02);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.upload-dropzone:hover, .upload-dropzone.dragover {
  border-color: var(--neon-cyan);
  background: rgba(0, 240, 255, 0.08);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.15);
}

.drop-icon svg {
  width: 36px;
  height: 36px;
  color: var(--neon-cyan);
  margin-bottom: 8px;
}

.dropzone-label {
  font-size: 0.82rem;
  color: var(--text-main);
}

.dropzone-sub {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 4px;
}

.link-button {
  background: none;
  border: none;
  color: var(--neon-cyan);
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
}

.selected-file-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(0, 240, 255, 0.06);
  border: 1px solid var(--border-cyan-glow);
  border-radius: var(--radius-md);
}

.selected-file-card.hidden {
  display: none;
}

.file-card-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.file-icon {
  width: 22px;
  height: 22px;
  color: var(--neon-cyan);
}

.file-name {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: #ffffff;
}

.file-size {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.flash-settings-card {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.setting-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.flash-hero-btn {
  width: 100%;
  padding: 12px 18px;
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, #00f0ff, #0077ff);
  color: #030712;
  border: 1px solid rgba(0, 240, 255, 0.8);
  border-radius: var(--radius-md);
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.4);
}

.flash-hero-btn:hover:not(:disabled) {
  box-shadow: 0 0 24px rgba(0, 240, 255, 0.7);
  transform: translateY(-1px);
}

.flash-progress-wrapper {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 10px 14px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  margin-bottom: 6px;
}

.progress-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #00f0ff, #10b981);
  transition: width 0.2s ease;
}

.hardware-tools-section {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border-glass);
}

.tools-heading {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tools-btn-row {
  display: flex;
  gap: 8px;
}

/* ==========================================================================
   RIGHT PANE: WEB SERIAL MONITOR TERMINAL
   ========================================================================== */
.studio-right-pane {
  display: flex;
  flex-direction: column;
}

.serial-header {
  padding: 0 12px;
}

.serial-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toolbar-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-dim);
}

.serial-terminal-wrapper {
  flex: 1;
  min-height: 0;
  background: var(--bg-terminal);
  padding: 12px;
  overflow: hidden;
  position: relative;
}

.terminal-screen {
  height: 100%;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.5;
  color: #e2e8f0;
  white-space: pre-wrap;
  word-break: break-all;
}

.terminal-welcome-msg {
  color: var(--text-dim);
  font-style: italic;
}

.terminal-prompt {
  color: var(--neon-cyan);
  font-weight: 700;
}

.term-log-cmd {
  color: var(--neon-purple);
  font-weight: 600;
}
.term-log-info {
  color: #e2e8f0;
}
.term-log-warn {
  color: var(--neon-amber);
}
.term-log-error {
  color: var(--neon-rose);
  font-weight: 600;
}
.term-log-success {
  color: var(--neon-green);
  font-weight: 600;
}

/* Console Input Bar */
.console-input-bar {
  height: 42px;
  min-height: 42px;
  background: rgba(0, 0, 0, 0.4);
  border-top: 1px solid var(--border-glass);
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-field-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
}

.input-prompt {
  color: var(--neon-cyan);
  font-family: var(--font-mono);
  font-weight: 700;
}

.terminal-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #ffffff;
}

.terminal-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.macro-bar {
  height: 32px;
  min-height: 32px;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--border-glass);
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
}

.macro-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-dim);
}

.macro-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.macro-chip:hover {
  background: rgba(0, 240, 255, 0.15);
  border-color: var(--neon-cyan);
  color: #ffffff;
}

/* ==========================================================================
   BUTTONS & INPUTS
   ========================================================================== */
.glass-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition-smooth);
}

.glass-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

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

.action-btn {
  font-family: var(--font-display);
  font-weight: 700;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: var(--transition-smooth);
  border: none;
}

.primary-glow-btn {
  background: linear-gradient(135deg, #00f0ff, #0077ff);
  color: #030712;
  border: 1px solid rgba(0, 240, 255, 0.8);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.35);
}

.primary-glow-btn:hover:not(:disabled) {
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.6);
  transform: translateY(-1px);
}

.sm-action-btn {
  padding: 5px 12px;
  font-size: 0.78rem;
}

.glass-select, .glass-input {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-glass);
  color: #ffffff;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 0.8rem;
  outline: none;
  transition: var(--transition-smooth);
}

.glass-select:focus, .glass-input:focus {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.2);
}

.sm-select, .sm-input {
  padding: 4px 8px;
  font-size: 0.75rem;
}

.glass-pill-toggle {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.glass-pill-toggle.active {
  background: rgba(0, 240, 255, 0.15);
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
}

.icon-svg {
  width: 14px;
  height: 14px;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}

.icon-btn:hover {
  color: #ffffff;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
}

.toast {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(12px);
  animation: slide-toast 0.2s ease-out;
}

.toast-success { border-color: var(--neon-green); color: var(--neon-green); }
.toast-error { border-color: var(--neon-rose); color: var(--neon-rose); }
.toast-info { border-color: var(--neon-cyan); color: var(--neon-cyan); }
.toast-warn { border-color: var(--neon-amber); color: var(--neon-amber); }

@keyframes slide-toast {
  from { transform: translateX(50px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
