/* ==========================================================================
   ChromaMesh • Estúdio de Mesh Gradients & Formas Orgânicas
   Design System: Artes do Sul Cyber-Dark & Glassmorphism
   ========================================================================== */

:root {
  --bg-primary: #050608;
  --bg-secondary: #0c0e14;
  --bg-card: rgba(18, 22, 32, 0.7);
  --bg-glass: rgba(15, 18, 26, 0.85);
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-active: rgba(0, 240, 255, 0.4);
  --border-glow: rgba(0, 240, 255, 0.2);

  --accent-cyan: #00f0ff;
  --accent-magenta: #ff007f;
  --accent-purple: #9d00ff;
  --accent-amber: #ffaa00;
  --accent-emerald: #00ff88;

  --text-main: #f0f4f8;
  --text-muted: #8a99ad;
  --text-dim: #4e5d73;

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Bricolage Grotesque', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --sidebar-width: 380px;
  --header-height: 56px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* Typography Utilities */
.font-mono { font-family: var(--font-mono); }
.text-xs { font-size: 11px; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--text-muted); }

/* App Container */
#app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  background: var(--bg-primary);
}

/* Header */
.app-header {
  height: var(--header-height);
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  z-index: 50;
  gap: 1rem;
}

.brand-group {
  display: flex;
  align-items: center;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand-logo-gem {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-magenta));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.4);
}

.chroma-orb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: inset 0 0 4px rgba(0,0,0,0.5);
  animation: pulseOrb 3s infinite ease-in-out;
}

@keyframes pulseOrb {
  0%, 100% { transform: scale(0.85); opacity: 0.9; }
  50% { transform: scale(1.15); opacity: 1; filter: drop-shadow(0 0 6px #fff); }
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.04em;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.badge-mesh {
  color: var(--accent-cyan);
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.6);
}

.brand-sub {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

/* Header Presets */
.header-presets {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  overflow-x: auto;
  padding: 0.25rem 0;
}

.preset-label {
  font-size: 10px;
  color: var(--text-dim);
  margin-right: 0.25rem;
}

.btn-preset {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  padding: 0.3rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.btn-preset:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-preset.active {
  background: rgba(0, 240, 255, 0.12);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.25);
}

/* Header Right */
.header-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.network-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.6rem;
  background: rgba(0, 255, 136, 0.06);
  border: 1px solid rgba(0, 255, 136, 0.2);
  border-radius: 999px;
  font-size: 10px;
  color: var(--accent-emerald);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 6px var(--accent-emerald);
}

.btn-icon {
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
}

.btn-action-glow {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.15), rgba(157, 0, 255, 0.15));
  border: 1px solid var(--accent-cyan);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  padding: 0.35rem 0.85rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.2);
}

.btn-action-glow:hover {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.3), rgba(157, 0, 255, 0.3));
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.4);
  transform: translateY(-1px);
}

/* Workspace Layout */
.app-workspace {
  display: flex;
  flex: 1;
  height: calc(100vh - var(--header-height));
  position: relative;
  overflow: hidden;
}

/* Canvas Viewport */
.canvas-viewport {
  flex: 1;
  position: relative;
  background: #020305;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#mesh-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Nodes Overlay Layer */
.nodes-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

.node-handle {
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  transform: translate(-50%, -50%);
  cursor: grab;
  pointer-events: auto;
  box-shadow: 0 0 16px rgba(0,0,0,0.6), inset 0 0 4px rgba(0,0,0,0.4);
  transition: transform 0.1s ease, box-shadow 0.2s ease;
}

.node-handle:hover, .node-handle.active {
  transform: translate(-50%, -50%) scale(1.25);
  box-shadow: 0 0 24px rgba(255, 255, 255, 0.8), 0 0 12px var(--handle-color);
}

.node-handle:active {
  cursor: grabbing;
}

/* Viewport HUD */
.viewport-hud {
  position: absolute;
  bottom: 1.25rem;
  left: 1.25rem;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0.4rem 0.8rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 11px;
  color: var(--text-muted);
  z-index: 20;
}

.hud-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.hud-label {
  color: var(--text-dim);
}

.hud-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}

.hud-checkbox-label input {
  accent-color: var(--accent-cyan);
}

/* Sidebar */
.control-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 30;
}

.sidebar-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.sidebar-badge {
  font-size: 10px;
  padding: 0.2rem 0.5rem;
  background: rgba(0, 240, 255, 0.08);
  border: 1px solid var(--border-glow);
  color: var(--accent-cyan);
  border-radius: 4px;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Controls */
.control-group {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.group-label {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.group-header-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mode-toggle-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.25rem;
  border-radius: 6px;
}

.btn-mode {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  padding: 0.4rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-mode:hover {
  color: #fff;
}

.btn-mode.active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--accent-cyan);
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

/* Color Nodes List */
.nodes-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 180px;
  overflow-y: auto;
}

.node-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.2);
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
}

.node-item-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.node-color-input {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  background: transparent;
}

.node-color-input::-webkit-color-swatch-wrapper { padding: 0; }
.node-color-input::-webkit-color-swatch { border: 1px solid rgba(255,255,255,0.4); border-radius: 50%; }

.node-actions {
  display: flex;
  gap: 0.3rem;
}

.btn-tiny {
  width: 22px;
  height: 22px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: #fff;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s ease;
}

.btn-tiny:hover {
  background: rgba(0, 240, 255, 0.2);
  border-color: var(--accent-cyan);
}

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

.slider-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-main);
}

.slider-value {
  font-size: 11px;
  color: var(--accent-cyan);
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}

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

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

.color-picker-input {
  width: 32px;
  height: 24px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
}

/* Export Section */
.export-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.btn-export {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.btn-export:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.primary-export {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.2), rgba(157, 0, 255, 0.2));
  border-color: var(--accent-cyan);
  color: #fff;
}

.primary-export:hover {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.35), rgba(157, 0, 255, 0.35));
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.3);
}

.code-preview-block {
  margin-top: 0.5rem;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  overflow: hidden;
}

.code-header {
  padding: 0.4rem 0.6rem;
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.btn-link {
  background: transparent;
  border: none;
  color: var(--accent-cyan);
  cursor: pointer;
}

.code-box {
  padding: 0.6rem;
  font-size: 10px;
  color: #a5b4fc;
  max-height: 90px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: rgba(12, 16, 24, 0.95);
  border: 1px solid var(--accent-cyan);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.3);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 6px;
  font-size: 12px;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 999;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Mobile Responsive */
@media (max-width: 900px) {
  .app-workspace {
    flex-direction: column;
    overflow-y: auto;
  }
  .canvas-viewport {
    height: 55vh;
    flex: none;
  }
  .control-sidebar {
    width: 100%;
    height: auto;
  }
  .header-presets {
    display: none;
  }
}
