:root {
  --bg-dark: #090d16;
  --panel-bg: #1e293b;
  --panel-header: #0f172a;
  --panel-border: #334155;
  --sidebar-bg: #111827;
  
  --accent: #38b2ac;
  --accent-hover: #319795;
  --accent-glow: rgba(56, 178, 172, 0.15);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --tag-react-bg: rgba(97, 218, 251, 0.15);
  --tag-react-color: #61dafb;
  
  --tag-ai-bg: rgba(168, 85, 247, 0.15);
  --tag-ai-color: #c084fc;
  
  --tag-node-bg: rgba(34, 197, 94, 0.15);
  --tag-node-color: #4ade80;

  --tag-md-bg: rgba(56, 189, 248, 0.15);
  --tag-md-color: #38bdf8;

  --sidebar-width: 340px;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header Superior */
header {
  height: 54px;
  background: var(--panel-header);
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1rem;
}

.brand-icon {
  background: linear-gradient(135deg, #38b2ac, #319795);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(56, 178, 172, 0.25);
}

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

.brand-title .main-title {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
}

.brand-title .sub-title {
  font-size: 0.7rem;
  color: var(--accent);
  font-weight: 500;
}

.header-badges {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge-beca, .badge-module {
  background: rgba(233, 84, 32, 0.15);
  color: #fb923c;
  border: 1px solid rgba(251, 146, 60, 0.3);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge-module {
  background: rgba(56, 178, 172, 0.15);
  color: var(--accent);
  border-color: rgba(56, 178, 172, 0.3);
}

/* Layout Principal */
.app-container {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Sidebar de Navegación */
sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  user-select: none;
  z-index: 20;
}

.sidebar-header {
  padding: 14px;
  border-bottom: 1px solid var(--panel-border);
  background: #0f172a;
}

.sidebar-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.search-box {
  width: 100%;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text-main);
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-box:focus {
  border-color: var(--accent);
}

.tree-container {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

/* ÁRBOL DE ARCHIVOS Y PROYECTOS (TREE VIEW) */
.project-node {
  margin-bottom: 8px;
  border-radius: 6px;
  background: rgba(30, 41, 59, 0.3);
  border: 1px solid rgba(51, 65, 85, 0.5);
  overflow: hidden;
}

.project-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  background: #0f172a;
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 600;
  transition: background 0.15s;
}

.project-header:hover {
  background: #1e293b;
}

.project-header i.chevron {
  transition: transform 0.2s ease;
  color: var(--text-muted);
}

.project-node.collapsed .project-header i.chevron {
  transform: rotate(-90deg);
}

.project-files {
  padding: 4px 0 6px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.project-node.collapsed .project-files {
  display: none;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-family: 'JetBrains Mono', monospace;
  transition: all 0.15s;
  border: 1px solid transparent;
}

.file-item:hover {
  background: var(--panel-bg);
  color: var(--text-main);
}

.file-item.active {
  background: var(--accent-glow);
  color: var(--accent);
  border-color: rgba(56, 178, 172, 0.3);
  font-weight: 600;
}

.file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-badge {
  font-size: 0.58rem;
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 700;
  text-transform: uppercase;
}

/* Main Area - Playground Viewer & Terminal */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #020617;
  padding: 12px;
  overflow: hidden;
}

.browser-window {
  flex: 1;
  background: var(--bg-dark);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 30px -5px rgba(0, 0, 0, 0.6);
}

.browser-toolbar {
  height: 48px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 10px;
}

.window-dots {
  display: flex;
  gap: 5px;
}

.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot-red { background: #ef4444; }
.dot-yellow { background: #f59e0b; }
.dot-green { background: #10b981; }

.nav-btns {
  display: flex;
  gap: 4px;
}

.nav-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  border-radius: 4px;
  transition: all 0.15s;
}

.nav-btn:hover {
  background: var(--panel-border);
  color: var(--text-main);
}

.address-bar {
  flex: 1;
  min-width: 120px;
  background: #090d16;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  height: 28px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  gap: 6px;
  overflow: hidden;
}

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

.mode-tabs {
  display: flex;
  background: #090d16;
  padding: 2px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
}

.mode-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s;
}

.mode-tab.active {
  background: var(--panel-bg);
  color: var(--text-main);
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.toolbar-actions {
  display: flex;
  gap: 6px;
}

.btn-action {
  background: var(--panel-border);
  color: var(--text-main);
  border: 1px solid transparent;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-action:hover {
  background: #475569;
}

/* Workspace Layout */
.viewport-container {
  flex: 1;
  position: relative;
  background: #090d16;
  overflow: hidden;
}

iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #ffffff;
}

.code-viewer-pane {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #090d16;
  overflow: auto;
  padding: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.84rem;
  line-height: 1.6;
  color: #e2e8f0;
  display: none;
}

.code-viewer-pane pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.terminal-pane {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #030712;
  display: flex;
  flex-direction: column;
  font-family: 'JetBrains Mono', monospace;
  display: none;
}

.terminal-header {
  height: 34px;
  background: #0b101d;
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
  user-select: none;
}

.terminal-title {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #4ade80;
  font-weight: 600;
}

.terminal-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  font-size: 0.82rem;
  color: #cbd5e1;
  line-height: 1.5;
}

.log-line {
  margin-bottom: 4px;
  word-break: break-word;
  display: flex;
  gap: 8px;
}

.log-line.log { color: #f8fafc; }
.log-line.info { color: #38bdf8; }
.log-line.warn { color: #fbbf24; }
.log-line.error { color: #f87171; font-weight: 600; }
.log-line.system { color: #94a3b8; font-style: italic; }

.log-prompt {
  color: #10b981;
  user-select: none;
}

/* Markdown & Demo Showcase Reader */
.markdown-pane {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  overflow-y: auto;
  padding: 20px 24px;
  background: #090d16;
  color: #e2e8f0;
  line-height: 1.7;
  display: none;
}

.markdown-pane h1 { font-size: 1.5rem; color: #f8fafc; margin-bottom: 0.8rem; border-bottom: 1px solid #334155; padding-bottom: 0.4rem; }
.markdown-pane h2 { font-size: 1.25rem; color: var(--accent); margin-top: 1.2rem; margin-bottom: 0.6rem; }
.markdown-pane h3 { font-size: 1.05rem; color: #cbd5e1; margin-top: 1rem; margin-bottom: 0.4rem; }
.markdown-pane p { margin-bottom: 0.8rem; color: #94a3b8; font-size: 0.9rem; }
.markdown-pane ul, .markdown-pane ol { margin-left: 1.2rem; margin-bottom: 0.8rem; color: #94a3b8; font-size: 0.9rem; }
.markdown-pane code { background: #1e293b; padding: 2px 5px; border-radius: 4px; font-family: 'JetBrains Mono', monospace; font-size: 0.82em; color: #38b2ac; }
.markdown-pane pre { background: #030712; padding: 12px; border-radius: 8px; border: 1px solid #334155; overflow-x: auto; margin-bottom: 0.8rem; }
.markdown-pane pre code { background: transparent; padding: 0; color: #e2e8f0; }

.screenshot-card {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
}

.screenshot-card img {
  width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid #1e293b;
}

/* Footer Informativo */
.info-footer {
  height: 32px;
  background: var(--panel-bg);
  border-top: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
}

/* BARRA DE NAVEGACIÓN INFERIOR MÓVIL (4 FOCOS) */
.mobile-bottom-nav {
  display: none;
  height: 56px;
  background: #0f172a;
  border-top: 1px solid var(--panel-border);
  z-index: 40;
}

.mobile-bottom-nav .nav-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
}

.mobile-bottom-nav .nav-tab.active {
  color: var(--accent);
  background: rgba(56, 178, 172, 0.08);
}

.nav-badge {
  position: absolute;
  top: 5px;
  right: 15%;
  background: #10b981;
  color: #000;
  font-size: 0.6rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 10px;
}

/* RESPONSIVE DESIGN TELÉFONOS MÓVILES */
@media (max-width: 768px) {
  .header-badges {
    display: none;
  }

  .mobile-bottom-nav {
    display: flex;
  }

  main {
    padding: 0;
  }

  .browser-window {
    border-radius: 0;
    border: none;
  }

  .window-dots, .address-bar, .mode-tabs {
    display: none;
  }

  .browser-toolbar {
    padding: 0 8px;
    height: 42px;
    justify-content: space-between;
  }

  /* SISTEMA DE 4 FOCOS MÓVILES */
  .focus-topics sidebar { display: flex; width: 100%; height: 100%; border-right: none; }
  .focus-topics main { display: none; }

  .focus-preview sidebar { display: none; }
  .focus-preview main { display: flex; }
  .focus-preview .viewport-container iframe { display: block; }
  .focus-preview .code-viewer-pane, .focus-preview .terminal-pane, .focus-preview .markdown-pane { display: none; }

  .focus-code sidebar { display: none; }
  .focus-code main { display: flex; }
  .focus-code .viewport-container iframe, .focus-code .terminal-pane, .focus-code .markdown-pane { display: none; }
  .focus-code .code-viewer-pane { display: block; }

  .focus-terminal sidebar { display: none; }
  .focus-terminal main { display: flex; }
  .focus-terminal .viewport-container iframe, .focus-terminal .code-viewer-pane, .focus-terminal .markdown-pane { display: none; }
  .focus-terminal .terminal-pane { display: flex; }
}
