/* NEXUSCODE - Core Layout */

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

/* TOP BAR */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-height);
  padding: 0 var(--sp-3);
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border-subtle);
  z-index: var(--z-topbar);
  flex-shrink: 0;
  gap: var(--sp-2);
  user-select: none;
  position: relative;
}

.topbar::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--neon-cyan-dim) 20%, var(--neon-magenta-dim) 80%, transparent 100%);
  opacity: 0.4;
}

.topbar-left, .topbar-center, .topbar-right {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.topbar-left { flex: 1; min-width: 0; }
.topbar-center { flex-shrink: 0; }
.topbar-right { flex: 1; justify-content: flex-end; min-width: 0; }

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 1px;
  font-family: var(--font-mono);
  font-size: var(--text-md);
  font-weight: 700;
  letter-spacing: -0.5px;
  white-space: nowrap;
  animation: neonFlicker 8s ease-in-out infinite;
}

.logo-bracket { color: var(--text-muted); }
.logo-text { color: var(--text-primary); }
.logo-accent {
  color: var(--neon-cyan);
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}

/* Topbar Divider */
.topbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border-default);
  flex-shrink: 0;
}

/* Project Name */
.project-name {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: all var(--duration-normal) var(--ease-out);
}

.project-name:hover {
  border-color: var(--border-default);
  color: var(--text-primary);
}

.project-name:focus {
  outline: none;
  border-color: var(--neon-cyan);
  background: var(--bg-surface);
  color: var(--text-primary);
}

/* Save Indicator */
.save-indicator {
  font-size: var(--text-xs);
  color: var(--neon-green);
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-out);
}

.save-indicator.visible { opacity: 1; }

/* View Toggle Buttons */
.view-toggles {
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
}

.view-btn {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 4px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  white-space: nowrap;
}

.view-btn:hover { color: var(--text-secondary); background: var(--bg-elevated); }
.view-btn.active {
  color: var(--neon-cyan);
  background: var(--neon-cyan-ghost);
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.15);
}

/* Responsive Toggle */
.responsive-toggle {
  display: flex;
  align-items: center;
  gap: 2px;
}

.resp-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.resp-btn:hover { color: var(--text-secondary); background: var(--bg-surface); }
.resp-btn.active { color: var(--neon-cyan); background: var(--neon-cyan-ghost); }

/* Topbar Buttons */
.topbar-btn {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 5px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
  white-space: nowrap;
}

.topbar-btn:hover {
  border-color: var(--border-default);
  color: var(--text-primary);
  background: var(--bg-surface);
}

.topbar-btn svg { flex-shrink: 0; }

/* WORKSPACE */
.workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* EDITOR AREA */
.editor-area {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 300px;
  overflow: hidden;
}

/* DIVIDER */
.divider {
  position: relative;
  z-index: var(--z-divider);
  flex-shrink: 0;
}

.vertical-divider {
  width: var(--divider-size);
  cursor: col-resize;
  background: var(--border-subtle);
  transition: background var(--duration-fast) var(--ease-out);
  display: flex;
  align-items: center;
  justify-content: center;
}

.vertical-divider:hover,
.vertical-divider.dragging {
  background: var(--neon-cyan-dim);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

.divider-grip {
  width: 2px;
  height: 24px;
  border-radius: 1px;
  background: var(--text-muted);
  opacity: 0.5;
  transition: opacity var(--duration-fast);
}

.vertical-divider:hover .divider-grip { opacity: 1; }

/* Horizontal divider for console */
.horizontal-divider {
  height: var(--divider-size);
  cursor: row-resize;
  background: var(--border-subtle);
  flex-shrink: 0;
}

.horizontal-divider:hover {
  background: var(--neon-cyan-dim);
}

/* PREVIEW AREA */
.preview-area {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 300px;
  overflow: hidden;
  background: var(--bg-base);
}

/* BOTTOM BAR */
.bottombar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--bottombar-height);
  padding: 0 var(--sp-3);
  background: var(--bg-deep);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
  user-select: none;
  font-size: var(--text-xs);
  color: var(--text-muted);
  position: relative;
}

.bottombar::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--neon-magenta-dim) 30%, var(--neon-cyan-dim) 70%, transparent 100%);
  opacity: 0.3;
}

.bottombar-left, .bottombar-center, .bottombar-right {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.bottombar-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  transition: color var(--duration-fast);
}

.bottombar-divider {
  color: var(--border-default);
}

.shortcut-hint {
  opacity: 0.6;
}

/* Console Toggle in Bottombar */
.console-toggle {
  cursor: pointer;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
}

.console-toggle:hover { color: var(--neon-cyan); }

.console-badge {
  background: var(--neon-red);
  color: white;
  padding: 0 5px;
  border-radius: var(--radius-full);
  font-size: 9px;
  font-weight: 600;
  line-height: 16px;
}

/* ═══════════════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(6, 6, 11, 0.8);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn var(--duration-normal) var(--ease-out);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-subtle);
}

.modal-header h2 {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--duration-fast);
}

.modal-close:hover { background: var(--bg-surface); color: var(--text-primary); }

/* Command Palette */
.command-palette {
  width: 560px;
  max-width: 90vw;
  max-height: 70vh;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6), var(--glow-subtle);
  animation: slideUp var(--duration-slow) var(--ease-spring);
}

.cmd-search-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.cmd-search-bar input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: var(--text-md);
}

.cmd-search-bar input::placeholder { color: var(--text-muted); }

.cmd-results {
  max-height: calc(70vh - 52px);
  overflow-y: auto;
  padding: var(--sp-2);
}

.cmd-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--duration-fast);
}

.cmd-item:hover, .cmd-item.active { background: var(--neon-cyan-ghost); }
.cmd-item-label { color: var(--text-primary); font-size: var(--text-sm); }
.cmd-item-shortcut {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Templates Modal */
.templates-modal {
  width: 700px;
  max-width: 90vw;
  max-height: 80vh;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  animation: slideUp var(--duration-slow) var(--ease-spring);
}

.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--sp-3);
  padding: var(--sp-4);
  max-height: calc(80vh - 60px);
  overflow-y: auto;
}

.template-card {
  display: flex;
  flex-direction: column;
  padding: var(--sp-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
}

.template-card:hover {
  border-color: var(--neon-cyan);
  background: var(--neon-cyan-ghost);
  box-shadow: var(--glow-subtle);
  transform: translateY(-2px);
}

.template-card-icon {
  font-size: 1.5rem;
  margin-bottom: var(--sp-2);
}

.template-card-name {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--text-primary);
  margin-bottom: var(--sp-1);
}

.template-card-desc {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.4;
}

/* Share Modal */
.share-modal {
  width: 520px;
  max-width: 90vw;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  animation: slideUp var(--duration-slow) var(--ease-spring);
}

.share-content {
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

.share-option label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--sp-2);
}

.share-url-row {
  display: flex;
  gap: var(--sp-2);
}

.share-url-input {
  flex: 1;
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  outline: none;
}

.share-copy-btn {
  padding: var(--sp-2) var(--sp-3);
  background: var(--neon-cyan-ghost);
  border: 1px solid var(--neon-cyan);
  border-radius: var(--radius-sm);
  color: var(--neon-cyan);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--duration-fast);
}

.share-copy-btn:hover { background: rgba(0, 240, 255, 0.2); }
.share-copy-btn.copied { background: var(--neon-green); border-color: var(--neon-green); color: #000; }

.share-embed-input {
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  outline: none;
  resize: vertical;
  margin-bottom: var(--sp-2);
}

.share-note {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--sp-1);
}

/* Export Modal */
.export-modal {
  width: 480px;
  max-width: 90vw;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  animation: slideUp var(--duration-slow) var(--ease-spring);
}

.export-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-3);
  padding: var(--sp-5);
}

.export-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-5) var(--sp-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-family: var(--font-ui);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
}

.export-option:hover {
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  background: var(--neon-cyan-ghost);
  transform: translateY(-2px);
  box-shadow: var(--glow-subtle);
}

.export-option span {
  font-size: var(--text-sm);
  font-weight: 600;
}

.export-option small {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Theme Modal */
.theme-modal {
  width: 600px;
  max-width: 90vw;
  max-height: 80vh;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  animation: slideUp var(--duration-slow) var(--ease-spring);
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--sp-3);
  padding: var(--sp-4);
  max-height: calc(80vh - 60px);
  overflow-y: auto;
}

.theme-card {
  padding: var(--sp-3);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
  text-align: center;
}

.theme-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.theme-card.active { border-color: var(--neon-cyan); box-shadow: var(--glow-subtle); }

.theme-card-preview {
  height: 40px;
  border-radius: var(--radius-sm);
  margin-bottom: var(--sp-2);
  overflow: hidden;
}

.theme-card-name {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-primary);
}

/* Shortcuts Modal */
.shortcuts-modal {
  width: 560px;
  max-width: 90vw;
  max-height: 80vh;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  animation: slideUp var(--duration-slow) var(--ease-spring);
}

.shortcuts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-1);
  padding: var(--sp-4);
  max-height: calc(80vh - 60px);
  overflow-y: auto;
}

.shortcut-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
}

.shortcut-item:hover { background: var(--bg-surface); }

.shortcut-label {
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.shortcut-keys {
  display: flex;
  gap: 3px;
}

kbd {
  display: inline-block;
  padding: 2px 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ═══════════════════════════════════════════════════════
   RESPONSIVE DESIGN
   ═══════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .topbar { padding: 0 var(--sp-2); }
  .topbar-btn span { display: none; }
  .view-btn span { display: none; }
  .logo { font-size: var(--text-sm); }
  .project-name { max-width: 100px; }

  .workspace { flex-direction: column; }
  .editor-area { min-width: unset; min-height: 200px; }
  .preview-area { min-width: unset; min-height: 200px; }

  .vertical-divider {
    width: 100%;
    height: var(--divider-size);
    cursor: row-resize;
  }

  .bottombar { font-size: 10px; padding: 0 var(--sp-2); }
  .bottombar-center { display: none; }
  .shortcut-hint { display: none; }
}

@media (max-width: 480px) {
  .topbar-center { display: none; }
  .responsive-toggle { display: none; }
  .templates-grid { grid-template-columns: 1fr; }
  .export-options { grid-template-columns: 1fr; }
}
