/*
  base.css — Global element styles and layout skeleton
  ─────────────────────────────────────────────────────
  Sets the page font, global text defaults, and defines the
  app shell layout: top header + content area (sidebar + main).
  No component-specific styling here.
*/

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text-primary);
  background-color: var(--surface-page);
  line-height: var(--line-height-base);
}

/* ── App Shell ──────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background-color: var(--surface-page);
}

/* ── Top Header ─────────────────────────────────── */
.app-header {
  height: var(--header-height);
  min-height: var(--header-height);
  background: var(--surface-header);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  gap: var(--space-4);
  flex-shrink: 0;
  z-index: var(--z-raised);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}

.header-divider {
  width: 1px;
  height: 20px;
  background: var(--border-color);
  flex-shrink: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.header-trust-badge {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

[data-theme="dark"] .header-trust-badge {
  background: rgba(22, 163, 74, 0.12);
  color: #4ade80;
  border-color: rgba(22, 163, 74, 0.25);
}

/* ── Workspace Context (header left, after brand) ── */
.workspace-context {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  animation: ctxFadeIn 200ms ease;
}

.workspace-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--border-radius-sm);
  background: var(--color-gray-100);
  color: var(--text-secondary);
  flex-shrink: 0;
}

[data-theme="dark"] .workspace-icon {
  background: rgba(255, 255, 255, 0.08);
}

.workspace-name {
  font-size: var(--text-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  white-space: nowrap;
}

@keyframes ctxFadeIn {
  from { opacity: 0; transform: translateX(-4px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Content Area (Sidebar + Main) ──────────────── */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ── Sidebar ────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--surface-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

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

/* ── Module Views ───────────────────────────────── */
.view {
  display: none;
  flex: 1;
  overflow: hidden;
  flex-direction: column;
  background-color: var(--surface-page);
}

.view.active {
  display: flex;
}

/* ── Page-level typography ──────────────────────── */
h1 { font-size: var(--text-xl); font-weight: var(--font-weight-bold); line-height: var(--line-height-tight); }
h2 { font-size: var(--text-lg); font-weight: var(--font-weight-semibold); line-height: var(--line-height-tight); }
h3 { font-size: var(--text-md); font-weight: var(--font-weight-semibold); }
h4 { font-size: var(--text-base); font-weight: var(--font-weight-semibold); }

code, pre {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

/* ── Scrollbars (webkit) ────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-gray-400); }

/* ── Utility classes ────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.grow { flex: 1; }
.overflow-auto { overflow: auto; }
.overflow-hidden { overflow: hidden; }
.relative { position: relative; }
.w-full { width: 100%; }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-muted { color: var(--text-secondary); }
.font-mono { font-family: var(--font-mono); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
