/* ── Loading Screen ──────────────────────────────────────────────────────── */
.loading-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-base);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  z-index: var(--z-loading);
}

.loading-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}

.loading-logo i { font-size: 2rem; }

.loading-bar {
  width: 200px;
  height: 3px;
  background: var(--bg-elevated);
  border-radius: 99px;
  overflow: hidden;
}

.loading-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--purple));
  border-radius: 99px;
  animation: loadingFill 1.5s ease forwards;
  width: 0;
}

.loading-text {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ── Auth Gate ───────────────────────────────────────────────────────────── */
.auth-gate {
  position: fixed;
  inset: 0;
  background: var(--bg-base);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-loading);
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 48px 40px;
  text-align: center;
  border-radius: var(--radius-xl);
}

.auth-logo {
  width: 72px;
  height: 72px;
  background: var(--accent-soft);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--accent);
  margin: 0 auto 24px;
}

.auth-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 36px;
}

.auth-form { text-align: left; display: flex; flex-direction: column; gap: 4px; }
.auth-error {
  text-align: center;
  color: var(--red);
  font-size: 0.875rem;
  margin-top: 12px;
}

/* ── App Shell ───────────────────────────────────────────────────────────── */
.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width var(--t-slow);
  overflow: hidden;
  z-index: var(--z-overlay);
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-header {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-logo i { font-size: 1.25rem; flex-shrink: 0; }

.sidebar-title {
  transition: opacity var(--t-slow), width var(--t-slow);
}

.sidebar.collapsed .sidebar-title { opacity: 0; width: 0; }
.sidebar.collapsed .nav-label { opacity: 0; width: 0; }
.sidebar.collapsed .nav-section-label { opacity: 0; }
.sidebar.collapsed .nav-badge { display: none; }
.sidebar.collapsed .sidebar-accounts { opacity: 0; pointer-events: none; }

.sidebar-toggle-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: color var(--t-base), transform var(--t-slow);
  flex-shrink: 0;
}

.sidebar.collapsed .sidebar-toggle-btn { transform: rotate(180deg); }
.sidebar-toggle-btn:hover { color: var(--text-primary); }

.sidebar-nav {
  flex: 1;
  padding: 16px 8px;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-section { margin-bottom: 24px; }

.nav-section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-disabled);
  padding: 0 10px;
  display: block;
  margin-bottom: 6px;
  white-space: nowrap;
  transition: opacity var(--t-slow);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--t-base);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.nav-item:hover { background: var(--bg-elevated); color: var(--text-primary); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item.active .nav-icon { color: var(--accent); }

.nav-icon { font-size: 1rem; flex-shrink: 0; width: 20px; text-align: center; }
.nav-label { transition: opacity var(--t-slow), width var(--t-slow); }

.nav-badge {
  margin-left: auto;
  background: var(--orange);
  color: #000;
  font-size: 0.625rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 99px;
}

/* Sidebar Accounts */
.sidebar-accounts {
  padding: 16px 8px;
  border-top: 1px solid var(--border);
  transition: opacity var(--t-slow);
}

.account-list { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }

.account-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}

.account-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.account-name { color: var(--text-secondary); font-weight: 500; }
.account-count { margin-left: auto; color: var(--text-muted); font-size: 0.75rem; }

/* ── Main Wrapper ────────────────────────────────────────────────────────── */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Topbar ──────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  gap: 16px;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 8px;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  transition: color var(--t-base);
}

.hamburger:hover { color: var(--text-primary); }

.breadcrumb { display: flex; align-items: center; gap: 8px; }
.breadcrumb-item {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.breadcrumb-item.active { color: var(--text-primary); }
.breadcrumb-sep { color: var(--text-disabled); font-size: 0.75rem; }

.topbar-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: color var(--t-base), background var(--t-base);
}

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

.topbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  transition: border-color var(--t-base);
}

.topbar-search:focus-within { border-color: var(--accent); }
.topbar-search i { color: var(--text-muted); font-size: 0.875rem; }

.topbar-search input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.875rem;
  width: 200px;
}

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

.topbar-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-online { background: var(--green); box-shadow: 0 0 8px var(--green); }
.status-offline { background: var(--red); }
.status-loading { background: var(--orange); animation: pulse 1s infinite; }

/* ── Main Content ────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ── Pages ───────────────────────────────────────────────────────────────── */
.page { padding: 32px; animation: pageIn 0.25s ease; }

.page-header { margin-bottom: 28px; }
.page-title { font-size: 1.75rem; font-weight: 700; line-height: 1.2; }
.page-subtitle { color: var(--text-muted); margin-top: 4px; font-size: 0.9rem; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 32px 0 16px;
}

.section-title { font-size: 1.125rem; font-weight: 600; }

/* ── Editor Layout ───────────────────────────────────────────────────────── */
.editor-layout {
  display: flex;
  height: calc(100vh - var(--topbar-height));
  height: calc(100dvh - var(--topbar-height));
  overflow: hidden;
  background: var(--bg-base);
}

.file-explorer {
  width: 296px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  overflow: hidden;
  min-height: 480px;
}

.explorer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.explorer-title {
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.explorer-controls { display: flex; gap: 2px; }

/* Account / repo context — shown as a connected, labeled stack instead of
   two bare dropdowns so the active path is always legible at a glance. */
.explorer-repo-selector {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.explorer-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.explorer-field-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-disabled);
  padding: 0 2px;
}

/* Active path breadcrumb — sits above the file tree so the current
   account/repo context never scrolls out of view. */
.explorer-path {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 13px 14px;
  min-height: 44px;
  font-size: 0.8125rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  background: var(--bg-base);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  white-space: nowrap;
  flex-shrink: 0;
  scrollbar-width: none;
}

.explorer-path::-webkit-scrollbar { display: none; }
.explorer-path i { color: var(--text-disabled); font-size: 0.7rem; }
.explorer-path .path-account { color: var(--accent); font-weight: 600; }
.explorer-path .path-sep { color: var(--text-disabled); }
.explorer-path .path-repo { color: var(--text-primary); font-weight: 500; }
.explorer-path.is-empty { color: var(--text-disabled); font-style: italic; }

.explorer-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 12px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  flex-shrink: 0;
  transition: border-color var(--t-fast);
}

.explorer-search:focus-within { border-color: var(--accent); }
.explorer-search i { color: var(--text-muted); font-size: 0.8rem; }
.explorer-search input { flex: 1; background: none; border: none; outline: none; color: var(--text-primary); font-size: 0.8rem; }

.file-tree {
  flex: 1;
  overflow-y: auto;
  padding: 6px 6px 16px;
}

.tree-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 200px;
  color: var(--text-muted);
  font-size: 0.825rem;
  text-align: center;
  padding: 20px;
}

.tree-empty i { font-size: 1.75rem; color: var(--text-disabled); }

.editor-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-base);
}

/* Open-file tab strip — shown only when a file is open; replaces the
   awkward "select a file" placeholder block that used to live here. */
.editor-tabs {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0;
  min-height: 40px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}

.editor-tabs::-webkit-scrollbar { display: none; }
.editor-tabs:empty,
.editor-tabs:has(.editor-no-file) { min-height: 0; border-bottom: none; }

.editor-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 0 14px;
  height: 40px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  background: transparent;
  border-right: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background var(--t-fast), color var(--t-fast);
}

.editor-tab:hover { color: var(--text-secondary); background: var(--bg-elevated); }

.editor-tab.active {
  color: var(--text-primary);
  background: var(--bg-base);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.editor-tab i.tab-file-icon { font-size: 0.8rem; color: var(--text-muted); }
.editor-tab i.tab-file-icon.fa-js { color: #f0db4f; }
.editor-tab i.tab-file-icon.fa-html5 { color: #e34c26; }
.editor-tab i.tab-file-icon.fa-css3-alt { color: #2965f1; }
.editor-tab i.tab-file-icon.fa-react { color: #61dafb; }
.editor-tab i.tab-file-icon.fa-python { color: #4b8bbe; }
.editor-tab i.tab-file-icon.fa-php { color: #8993be; }
.editor-tab i.tab-file-icon.fa-java { color: #e76f00; }
.editor-tab i.tab-file-icon.fa-database { color: var(--blue); }
.editor-tab i.tab-file-icon.fa-lock { color: var(--red); }
.editor-tab .tab-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--orange);
  flex-shrink: 0;
  display: none;
}

.editor-tab.modified .tab-dot { display: block; }
.editor-tab .tab-close {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-size: 0.7rem;
  color: var(--text-disabled);
}

.editor-tab .tab-close:hover { background: var(--bg-overlay); color: var(--text-primary); }

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
}

.editor-file-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  min-width: 0;
  overflow: hidden;
}

.editor-file-info i { color: var(--text-muted); flex-shrink: 0; }
#current-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-actions { display: flex; gap: 8px; flex-shrink: 0; }

.editor-no-file {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 14px;
  color: var(--text-muted);
  padding: 40px 20px;
}

.editor-no-file i { font-size: 2.25rem; color: var(--text-disabled); }
.editor-no-file p { font-size: 0.875rem; max-width: 280px; text-align: center; line-height: 1.5; }

.monaco-container {
  flex: 1;
  min-height: 0;
  position: relative;
  margin: 12px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}

/* Monaco mounts its own canvas-based editor; this skeleton is shown while
   the loader script + model are still initializing so the panel never
   looks like a dead gray box. */
.monaco-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--bg-base);
  color: var(--text-disabled);
  font-size: 0.8125rem;
  z-index: 1;
}

.monaco-loading i { font-size: 1.5rem; color: var(--text-muted); }

/* Mobile overlay */
.mobile-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: calc(var(--z-overlay) - 1);
  backdrop-filter: blur(4px);
}
