/* DevForge — layout.css
   App shell: top bar, sidebar, workspace panes, dividers, responsive rules. */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ============ TOP BAR ============ */
.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  z-index: 30;
}
.icon-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  position: relative;
  transition:
    background 0.12s,
    color 0.12s;
}
.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.icon-btn.active {
  color: var(--accent-text);
  background: var(--accent-soft);
}
.icon-btn svg {
  width: 17px;
  height: 17px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.brand-mark {
  color: var(--accent);
  width: 19px;
  height: 19px;
}
.brand-name {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.2px;
  color: var(--accent-text);
}

.lang-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0 auto;
  flex-shrink: 0;
}
.lang-tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}
.lang-tab .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.lang-tab[data-lang='html'] .dot {
  background: var(--html-color);
}
.lang-tab[data-lang='css'] .dot {
  background: var(--css-color);
}
.lang-tab[data-lang='js'] .dot {
  background: var(--js-color);
}
.lang-tab.active {
  background: var(--accent-soft);
  color: var(--text-primary);
  border-color: var(--accent);
}
.lang-tab:not(.active):hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.auto-group {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-right: 8px;
  border-right: 1px solid var(--border);
  margin-right: 2px;
}
.switch {
  position: relative;
  width: 34px;
  height: 19px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch .track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s;
}
.switch .track::after {
  content: '';
  position: absolute;
  width: 15px;
  height: 15px;
  left: 2px;
  top: 2px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s;
}
.switch input:checked + .track {
  background: var(--accent);
}
.switch input:checked + .track::after {
  transform: translateX(15px);
}
/* The real <input> is opacity:0 (visually replaced by .track), which also
   hides any outline drawn on it directly — so the focus ring has to be
   drawn on the visible sibling instead, driven by the input's own
   focus-visible state. */
.switch input:focus-visible + .track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.auto-label {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.lesson-counter {
  font-size: 12px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  min-width: 34px;
  text-align: center;
}
.font-slider {
  width: 60px;
  accent-color: var(--accent);
  cursor: pointer;
}
.run-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: filter 0.12s;
}
.run-btn:hover {
  filter: brightness(1.1);
}
.run-btn:active {
  filter: brightness(0.95);
}
.run-btn svg {
  width: 13px;
  height: 13px;
}

/* ============ MAIN LAYOUT ============ */
.main {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* ---- Sidebar ---- */
.sidebar {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  transition: width 0.18s ease;
  overflow: hidden;
}
.sidebar.collapsed {
  width: 0;
  border-right-color: transparent;
}
.sidebar-inner {
  width: 280px;
  display: flex;
  flex-direction: column;
  height: 100%;
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px;
  flex-shrink: 0;
}
.sidebar-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.sidebar-search {
  padding: 0 14px 12px;
  flex-shrink: 0;
}
.sidebar-search input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px 7px 30px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}
.sidebar-search input:focus {
  border-color: var(--accent);
}
.sidebar-search-wrap {
  position: relative;
}
.sidebar-search-wrap svg {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-faint);
}

.curriculum {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 8px;
}
.playground-item {
  margin: 0 6px 10px;
}
.category {
  margin-bottom: 2px;
}
.category-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 8px;
  cursor: pointer;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  border-radius: var(--radius-sm);
  user-select: none;
}
.category-header:hover {
  color: var(--text-secondary);
}
.category-header svg {
  width: 11px;
  height: 11px;
  transition: transform 0.15s;
  flex-shrink: 0;
}
.category.collapsed .category-header svg {
  transform: rotate(-90deg);
}
.category.collapsed .category-items {
  display: none;
}
.lesson-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin: 1px 0;
  border: 1px solid transparent;
}
.lesson-item:hover {
  background: var(--bg-hover);
}
.lesson-item.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--border);
}
.status-dot.started {
  background: var(--warning);
}
.status-dot.complete {
  background: var(--success);
}
.lesson-item-text {
  flex: 1;
  min-width: 0;
}
.lesson-item-title {
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lesson-item-meta {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 1px;
}
.lesson-item-meta .tag-html {
  color: var(--html-color);
}
.lesson-item-meta .tag-css {
  color: var(--css-color);
}
.lesson-item-meta .tag-js {
  color: var(--js-color);
}
.no-results {
  padding: 20px 12px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}

.sidebar-footer {
  flex-shrink: 0;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.footer-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
}
.stat {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-secondary);
}
.stat b {
  color: var(--text-primary);
  font-weight: 700;
}
.footer-actions {
  display: flex;
  gap: 8px;
}
.footer-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  padding: 7px 0;
  cursor: pointer;
}
.footer-btn:hover {
  color: var(--text-primary);
  border-color: var(--text-faint);
}
.footer-btn svg {
  width: 12px;
  height: 12px;
}

/* ---- Workspace ---- */
.workspace {
  flex: 1;
  display: flex;
  min-width: 0;
}
.editor-col {
  flex: 1 1 50%;
  display: flex;
  flex-direction: column;
  min-width: 200px;
  background: var(--bg-editor);
}
.preview-col {
  flex: 1 1 50%;
  display: flex;
  flex-direction: column;
  min-width: 200px;
  background: var(--bg-panel);
}

.divider-v {
  width: 5px;
  flex-shrink: 0;
  cursor: col-resize;
  background: var(--border-soft);
  position: relative;
}
.divider-v:hover,
.divider-v.dragging {
  background: var(--accent);
}

.pane-header {
  height: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.pane-header-left {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-secondary);
}
.status-live {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}
.pane-header-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

@media (max-width: 820px) {
  .topbar {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }
  .brand,
  .icon-btn,
  .lang-tabs,
  .topbar-right,
  .run-btn {
    flex-shrink: 0;
  }
  .lang-tabs {
    margin: 0;
  }
  .workspace {
    flex-direction: column;
  }
  .divider-v {
    display: none;
  }
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    bottom: 0;
    left: 0;
    z-index: 40;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.4);
  }
}
