/* Layout & Components — n3xn VFS v2 */

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== AUTH ===== */
#auth-screen {
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #0c0c14 0%, #050508 70%);
}

.auth-container {
  width: 380px;
  padding: 36px 32px;
  text-align: center;
}

.logo {
  font-family: var(--font-pixel);
  font-size: 28px;
  letter-spacing: 2px;
  color: #fff;
  text-shadow: var(--glow-strong);
  margin-bottom: 4px;
}

.logo span {
  color: var(--text-dim);
}

.subtitle {
  color: var(--text-dim);
  font-size: 11px;
  margin-bottom: 28px;
  letter-spacing: 1px;
}

.auth-container .btn {
  width: 100%;
  margin-top: 8px;
}

/* ===== TOPBAR ===== */
.topbar {
  height: 42px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-shrink: 0;
  z-index: 10;
}

.brand {
  font-family: var(--font-pixel);
  font-size: 14px;
  color: #fff;
  text-shadow: 0 0 10px rgba(255,255,255,0.5);
  white-space: nowrap;
}

.brand span { color: var(--text-dim); }
.brand small { font-size: 10px; opacity: 0.6; margin-left: 4px; }

.path-bar {
  flex: 1;
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.user-area {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 12px;
  flex-shrink: 0;
}

/* ===== MAIN LAYOUT ===== */
/* Default: explorer fills the screen. When editing, switches to side-by-side. */
.main-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

/* Sidebar / File Explorer */
.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow: hidden;
  min-width: 0;
  transition: width 0.2s ease, flex 0.2s ease;
}

/* Full-screen explorer mode (no file open) */
.main-layout.explorer-mode .sidebar {
  flex: 1;
  width: 100%;
  border-right: none;
}

.main-layout.explorer-mode .editor-area {
  display: none;
}

/* Editing mode: sidebar narrow on the left */
.main-layout.editing-mode .sidebar {
  width: 260px;
  flex: 0 0 260px;
}

.main-layout.editing-mode .editor-area {
  display: flex;
  flex: 1;
  min-width: 0;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.sidebar-actions {
  display: flex;
  gap: 2px;
}

.file-tree {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 0;
  min-height: 0;
}

/* Explorer mode: richer file list */
.main-layout.explorer-mode .file-tree {
  padding: 12px 16px;
}

.main-layout.explorer-mode .tree-item {
  padding: 8px 12px;
  font-size: 13px;
  border-radius: var(--radius);
  margin-bottom: 2px;
}

.main-layout.explorer-mode .tree-item .icon {
  font-size: 16px;
}

.tree-item {
  display: flex;
  align-items: center;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 12px;
  gap: 8px;
  user-select: none;
  transition: background var(--transition);
}

.tree-item:hover {
  background: rgba(255,255,255,0.05);
}

.tree-item.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
  text-shadow: 0 0 6px rgba(255,255,255,0.3);
}

.tree-item .icon {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.8;
}

.tree-item .name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.tree-item .meta {
  font-size: 10px;
  color: var(--text-dim);
  flex-shrink: 0;
}

/* Editor area */
.editor-area {
  display: none;
  flex-direction: column;
  background: var(--bg);
  position: relative;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}

.editor-toolbar {
  display: flex;
  align-items: stretch;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 34px;
}

.tabs {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  flex: 1;
  min-width: 0;
}

.run-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  border-left: 1px solid var(--border);
  flex-shrink: 0;
}

.run-bar select {
  width: auto;
  min-width: 110px;
  padding: 4px 8px;
  font-size: 11px;
}

.tab {
  padding: 7px 14px;
  font-size: 12px;
  border-right: 1px solid var(--border);
  cursor: pointer;
  color: var(--text-dim);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--transition);
  flex-shrink: 0;
}

.tab:hover { color: var(--text); }
.tab.active {
  color: #fff;
  background: var(--bg);
  text-shadow: 0 0 6px rgba(255,255,255,0.3);
}

.tab .close {
  opacity: 0.4;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
}
.tab .close:hover { opacity: 1; color: var(--error); }

.editor-split {
  flex: 1;
  display: flex;
  flex-direction: row;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

#monaco-container {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  position: relative;
}

.editor-split.has-preview #monaco-container,
#monaco-container.preview-split {
  flex: 1 1 50%;
  max-width: 50%;
  border-right: 1px solid var(--border);
}

#preview-container {
  flex: 1 1 50%;
  max-width: 50%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  min-height: 0;
  min-width: 0;
}

#preview-container.hidden {
  display: none !important;
  flex: 0;
  max-width: 0;
  width: 0;
  border: none;
}

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-dim);
}

.preview-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-actions {
  display: flex;
  gap: 4px;
}

.preview-body {
  flex: 1;
  overflow: auto;
  min-height: 0;
  position: relative;
}

.preview-iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  background: #000;
  /* fill parent for games / fullscreen */
}

.preview-image-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  min-height: 100%;
}

.preview-image {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  box-shadow: var(--glow);
  border-radius: 4px;
}

.preview-meta {
  margin-top: 12px;
  font-size: 11px;
  color: var(--text-dim);
}

.md-preview {
  padding: 20px 24px;
  max-width: 720px;
  line-height: 1.6;
  color: var(--text);
}

.md-preview h1, .md-preview h2, .md-preview h3 {
  color: #fff;
  margin: 1em 0 0.4em;
  text-shadow: 0 0 8px rgba(255,255,255,0.2);
}

.md-preview code {
  background: #1a1a28;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.9em;
}

.md-preview pre.md-code {
  background: #0a0a12;
  border: 1px solid var(--border);
  padding: 12px;
  overflow-x: auto;
  border-radius: var(--radius);
  margin: 12px 0;
}

.md-preview a { color: #aaf; }

.json-preview, .text-preview {
  padding: 16px;
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.json-key { color: #9cf; }
.json-string { color: #c9a; }
.json-number { color: #8c8; }
.json-bool { color: #f96; }
.json-null { color: #888; }
.json-preview.error { color: var(--error); }

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  pointer-events: none;
}

.empty-state .hint {
  font-size: 11px;
  margin-top: 8px;
  opacity: 0.6;
}

/* ===== TERMINAL (collapsible, bottom panel) ===== */
.terminal-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  overflow: hidden;
  transition: height 0.2s ease;
  height: 220px;
}

.terminal-panel.collapsed {
  height: 32px;
}

.terminal-panel.collapsed .terminal-output,
.terminal-panel.collapsed .terminal-input-row {
  display: none;
}

.terminal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  flex-shrink: 0;
  height: 32px;
  cursor: pointer;
  user-select: none;
}

.terminal-header:hover {
  color: #fff;
}

.terminal-header-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

.terminal-output {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 12px;
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
  min-height: 0;
}

.terminal-output .cmd { color: #fff; }
.terminal-output .out { color: var(--text-dim); }
.terminal-output .err { color: var(--error); }
.terminal-output .ok  { color: var(--success); }

.terminal-input-row {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.prompt {
  color: #fff;
  margin-right: 8px;
  text-shadow: 0 0 6px rgba(255,255,255,0.4);
  white-space: nowrap;
}

#terminal-input {
  border: none;
  background: transparent;
  padding: 0;
  flex: 1;
  font-size: 12px;
  box-shadow: none !important;
  min-width: 0;
}

/* Status bar */
.statusbar {
  height: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 12px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  width: 420px;
  max-width: 90vw;
  padding: 24px;
}

.modal h3 {
  margin-bottom: 16px;
  font-size: 14px;
  color: #fff;
  text-shadow: 0 0 8px rgba(255,255,255,0.3);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* Responsive */
@media (max-width: 700px) {
  .main-layout.editing-mode .sidebar {
    width: 180px;
    flex: 0 0 180px;
  }
  .terminal-panel {
    height: 160px;
  }
}
