/* Online Web Editor — neon code editor theme */

:root {
  --bg-deep: #06060c;
  --bg-base: #0a0a12;
  --bg-panel: #0e0e18;
  --bg-elevated: #141422;
  --bg-hover: #1a1a2e;

  --border: rgba(255, 255, 255, 0.06);
  --border-glow: rgba(0, 245, 255, 0.15);

  --text: #e8e8f0;
  --text-muted: #7a7a9a;
  --text-dim: #4a4a6a;

  --neon-cyan: #00f5ff;
  --neon-magenta: #ff2d95;
  --neon-purple: #a855f7;
  --neon-green: #39ff14;
  --neon-orange: #ff6b35;

  --html: #ff6b6b;
  --css: #4ecdc4;
  --js: #ffe66d;

  --header-h: 56px;
  --toolbar-h: 44px;
  --status-h: 28px;
  --radius: 10px;
  --radius-sm: 6px;
  --font-ui: 'Outfit', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --glow-cyan: 0 0 20px rgba(0, 245, 255, 0.35);
  --glow-magenta: 0 0 20px rgba(255, 45, 149, 0.35);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-ui);
  background: var(--bg-deep);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* Ambient background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(0, 245, 255, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 90% 100%, rgba(255, 45, 149, 0.06), transparent),
    radial-gradient(ellipse 50% 30% at 50% 50%, rgba(168, 85, 247, 0.04), transparent);
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* ── Header ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: var(--header-h);
  padding: 0 1.25rem;
  background: rgba(10, 10, 18, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header__brand {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  min-width: 0;
}

.logo {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.logo__bracket {
  color: var(--neon-cyan);
  text-shadow: var(--glow-cyan);
}

.logo__core {
  background: linear-gradient(135deg, var(--neon-cyan), var(--neon-magenta));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header__tagline {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: none;
}

@media (min-width: 640px) {
  .header__tagline { display: block; }
}

.header__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn:hover {
  background: var(--bg-hover);
  border-color: rgba(255, 255, 255, 0.12);
}

.btn--ghost {
  background: transparent;
}

.btn--primary {
  background: linear-gradient(135deg, rgba(0, 245, 255, 0.15), rgba(255, 45, 149, 0.15));
  border-color: rgba(0, 245, 255, 0.3);
  color: var(--neon-cyan);
}

.btn--primary:hover {
  background: linear-gradient(135deg, rgba(0, 245, 255, 0.25), rgba(255, 45, 149, 0.25));
  box-shadow: var(--glow-cyan);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--neon-cyan);
}

@media (max-width: 480px) {
  .btn__label { display: none; }
  .btn { padding: 0.45rem 0.6rem; }
  .logo { font-size: 0.85rem; }
  .header__tagline { display: none !important; }
}

/* ── Workspace ── */
.workspace {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg-panel);
}

.panel--editor {
  flex: 1 1 50%;
}

.panel--preview {
  flex: 1 1 50%;
  border-left: none;
}

.panel__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  height: var(--toolbar-h);
  padding: 0 0.75rem;
  background: var(--bg-base);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel__toolbar--preview {
  padding: 0 1rem;
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 0.25rem;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.tab:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.tab--active {
  color: var(--text);
  background: var(--bg-elevated);
  border-color: var(--border);
}

.tab__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tab__dot--html { background: var(--html); box-shadow: 0 0 6px var(--html); }
.tab__dot--css  { background: var(--css);  box-shadow: 0 0 6px var(--css); }
.tab__dot--js   { background: var(--js);   box-shadow: 0 0 6px var(--js); }

/* ── Toggle ── */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle__track {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: var(--transition);
}

.toggle__thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: var(--transition);
}

.toggle input:checked + .toggle__track {
  background: rgba(0, 245, 255, 0.15);
  border-color: rgba(0, 245, 255, 0.4);
}

.toggle input:checked + .toggle__track .toggle__thumb {
  transform: translateX(16px);
  background: var(--neon-cyan);
  box-shadow: var(--glow-cyan);
}

.toggle__label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.toggle input:checked ~ .toggle__label {
  color: var(--neon-cyan);
}

/* ── Editors ── */
.editors {
  position: relative;
  flex: 1;
  min-height: 0;
}

.editor-wrap {
  position: absolute;
  inset: 0;
  display: none;
}

.editor-wrap--active {
  display: block;
}

.ace-editor {
  width: 100%;
  height: 100%;
  font-size: 14px !important;
}

/* Ace theme overrides */
.ace-neonpad .ace_gutter {
  background: var(--bg-base) !important;
  border-right: 1px solid var(--border) !important;
}

.ace-neonpad .ace_gutter-active-line {
  background: rgba(0, 245, 255, 0.05) !important;
}

.ace-neonpad .ace_marker-layer .ace_active-line {
  background: rgba(0, 245, 255, 0.04) !important;
}

.ace-neonpad .ace_cursor {
  color: var(--neon-cyan) !important;
}

.ace-neonpad .ace_selection {
  background: rgba(168, 85, 247, 0.25) !important;
}

/* ── Status bar ── */
.panel__status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: var(--status-h);
  padding: 0 1rem;
  background: var(--bg-base);
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  flex-shrink: 0;
}

.status-sep {
  opacity: 0.4;
}

.status-saved {
  margin-left: auto;
  color: var(--neon-green);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.status-saved--visible {
  opacity: 1;
}

/* ── Resizer ── */
.resizer {
  flex: 0 0 5px;
  cursor: col-resize;
  background: var(--bg-base);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  transition: background var(--transition);
  position: relative;
  z-index: 2;
}

.resizer::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 3px;
  height: 32px;
  border-radius: 2px;
  background: linear-gradient(to bottom, var(--neon-cyan), var(--neon-magenta));
  opacity: 0.4;
  transition: opacity var(--transition);
}

.resizer:hover,
.resizer:focus-visible,
.resizer--dragging {
  background: rgba(0, 245, 255, 0.08);
}

.resizer:hover::after,
.resizer:focus-visible::after,
.resizer--dragging::after {
  opacity: 1;
}

.resizer:focus-visible {
  outline: 2px solid var(--neon-cyan);
  outline-offset: -2px;
}

/* ── Preview ── */
.preview-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}

.preview-label__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--neon-green);
  box-shadow: 0 0 8px var(--neon-green);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.preview-actions {
  display: flex;
  gap: 0.25rem;
}

.preview-frame-wrap {
  flex: 1;
  min-height: 0;
  padding: 0.75rem;
  background:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 20px 20px;
  background-color: var(--bg-deep);
}

#preview {
  width: 100%;
  height: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  box-shadow:
    0 0 0 1px rgba(0, 245, 255, 0.05),
    0 8px 32px rgba(0, 0, 0, 0.4);
}

/* ── Fullscreen preview ── */
.app--preview-fullscreen .panel--editor,
.app--preview-fullscreen .resizer {
  display: none;
}

.app--preview-fullscreen .panel--preview {
  flex: 1 1 100%;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  padding: 0.65rem 1.25rem;
  background: var(--bg-elevated);
  border: 1px solid rgba(0, 245, 255, 0.3);
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--text);
  box-shadow: var(--glow-cyan);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s ease;
  pointer-events: none;
  z-index: 100;
}

.toast--visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ── Responsive: stack vertically on mobile ── */
@media (max-width: 768px) {
  .workspace {
    flex-direction: column;
  }

  .panel--editor {
    flex: 1 1 55%;
    border-right: none;
    border-bottom: none;
  }

  .panel--preview {
    flex: 1 1 45%;
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .resizer {
    flex: 0 0 5px;
    width: 100%;
    height: 5px;
    cursor: row-resize;
    border-left: none;
    border-right: none;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
  }

  .resizer::after {
    width: 32px;
    height: 3px;
    background: linear-gradient(to right, var(--neon-cyan), var(--neon-magenta));
  }
}

@media (max-width: 768px) {
  .header {
    padding: 0 0.75rem;
  }

  .logo {
    font-size: 1rem;
  }
}
