/* Shared app-shell components mirrored from Orq OS (ChatSidebar / NewChatDialog / ChatWindow). */

.app {
  display: flex;
  height: 100dvh;
  overflow: hidden;
  background: rgb(var(--c-bg));
  color: rgb(var(--c-text));
}

/* ---------- Sidebar shell ---------- */

.sidebar {
  display: flex;
  flex-direction: column;
  width: 296px;
  flex-shrink: 0;
  background: rgb(var(--c-bg));
  border-right: 1px solid var(--ghost-border);
  overflow: hidden;
}

.sb-header { flex-shrink: 0; padding: 16px 20px 0; }

.sb-header-row { display: flex; align-items: center; justify-content: space-between; }

.wordmark {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: rgb(var(--c-text));
}
.wordmark em { font-style: normal; color: rgb(var(--c-accent-light)); }

.view-icons { display: flex; align-items: center; gap: 2px; }
.view-icon {
  display: flex; align-items: center; justify-content: center;
  height: 28px; width: 28px; border-radius: 8px;
  color: rgb(var(--c-faint));
  transition: color 0.15s, background 0.15s;
}
.view-icon:hover { background: rgb(var(--c-surface)); color: rgb(var(--c-muted)); }
.view-icon.active { color: rgb(var(--c-accent)); }
.view-icon svg { height: 16px; width: 16px; }

/* ---------- Search ---------- */

.sb-search { flex-shrink: 0; padding: 16px 20px 0; }
.sb-search-box {
  display: flex; align-items: center; gap: 8px; padding-bottom: 8px;
  border-bottom: 1px solid var(--ghost-border-strong);
}
.sb-search-box svg { height: 14px; width: 14px; flex-shrink: 0; color: rgb(var(--c-faint)); }
.sb-search-box input {
  min-width: 0; flex: 1; background: transparent; border: none;
  font-size: 13px; color: rgb(var(--c-text));
}
.sb-search-box input::placeholder { color: rgb(var(--c-faint)); }

/* ---------- Tabs row ---------- */

.sb-tabs { flex-shrink: 0; display: flex; align-items: center; gap: 16px; padding: 12px 20px 4px; }
.sb-eyebrow {
  font-size: 9.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.14em; color: rgb(var(--c-faint));
}
.sb-tab {
  padding-bottom: 4px; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: rgb(var(--c-faint)); transition: color 0.15s;
}
.sb-tab:hover { color: rgb(var(--c-muted)); }
.sb-tab.active { color: rgb(var(--c-text)); box-shadow: inset 0 -1px 0 rgb(var(--c-accent)); }
.sb-tab .count { margin-left: 4px; font-weight: 400; font-size: 10px; color: rgb(var(--c-faint)); }
.sb-tabs .spacer { flex: 1; }

/* ---------- Session list ---------- */

.sb-list { flex: 1; overflow-y: auto; padding: 8px; }

.session-item {
  position: relative; display: block; width: 100%;
  padding: 8px 12px; text-align: left;
  border-bottom: 1px solid var(--ghost-border);
  transition: background 0.15s;
}
.session-item:hover { background: rgb(var(--c-surface) / 0.6); }
.session-item.active {
  background: rgb(var(--c-surface));
  box-shadow: inset 2px 0 0 rgb(var(--c-accent));
}

.si-row1 { display: flex; align-items: baseline; gap: 8px; }
.si-title {
  min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 13px; color: rgb(var(--c-muted));
}
.session-item.active .si-title { font-weight: 500; color: rgb(var(--c-text)); }
.si-time { flex-shrink: 0; font-size: 10px; color: rgb(var(--c-faint)); }

.si-meta {
  margin-top: 4px; display: flex; align-items: center; gap: 6px;
  font-size: 10px; color: rgb(var(--c-faint));
  min-width: 0;
}
.si-meta .dim { opacity: 0.4; }
.si-meta .truncate { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* status dot (SessionBadge) */
.sdot { position: relative; display: inline-flex; height: 8px; width: 8px; flex-shrink: 0; align-self: center; }
.sdot i { position: absolute; inset: 0; border-radius: 9999px; }
.sdot .ring { animation: pingRing 1.2s cubic-bezier(0, 0, 0.2, 1) infinite; }
.sdot.live i, .sdot.idle i { background: rgb(var(--c-success)); }
.sdot.processing i { background: rgb(var(--c-accent)); }
.sdot.initializing i, .sdot.migrating i { background: rgb(var(--c-warning)); }
.sdot.errored i { background: rgb(var(--c-danger)); }
.sdot.terminated i, .sdot.migrated i { background: rgb(var(--c-faint)); }

/* server health dot */
.hdot { display: inline-block; height: 6px; width: 6px; border-radius: 9999px; flex-shrink: 0; }
.hdot.online { background: rgb(var(--c-success)); }
.hdot.offline { background: rgb(var(--c-danger)); }

/* provider glyph — tiny brand-tinted tile */
.pglyph {
  display: inline-flex; align-items: center; justify-content: center;
  height: 14px; width: 14px; border-radius: 3px; flex-shrink: 0;
  font-size: 8px; font-weight: 700;
}
.pglyph.claude { color: #d97757; background: rgba(217, 119, 87, 0.14); }
.pglyph.codex { color: rgb(var(--brand-codex)); background: rgb(var(--brand-codex) / 0.12); }
.pglyph.gemini { color: rgb(var(--brand-gemini)); background: rgb(var(--brand-gemini) / 0.14); }
.pglyph.cursor { color: rgb(var(--brand-cursor)); background: rgb(var(--brand-cursor) / 0.12); }
.pglyph.glm { color: #8a8069; background: rgba(212, 197, 171, 0.25); }

/* server avatar — deterministic hue tile (matches ServerSwitcher) */
.savatar {
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; border-radius: 8px; font-weight: 600;
}
.savatar.md { height: 28px; width: 28px; font-size: 11px; }
.savatar.sm { height: 20px; width: 20px; font-size: 8px; border-radius: 6px; }
.savatar.xs { height: 14px; width: 14px; font-size: 7px; border-radius: 4px; }

/* section divider */
.sb-divider { margin: 6px 12px; border-top: 1px solid var(--ghost-border); }

/* group header inside the list */
.sb-group-h {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px 4px;
  font-size: 9.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.14em; color: rgb(var(--c-faint));
}

/* ---------- Sidebar footer ---------- */

.sb-footer { flex-shrink: 0; border-top: 1px solid var(--ghost-border-strong); padding-bottom: 8px; }

.meters { padding: 12px 20px 0; }
.meters-title {
  margin-bottom: 6px; font-size: 9px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.16em; color: rgb(var(--c-faint));
}
.meter-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.meter-label { width: 48px; flex-shrink: 0; font-size: 10px; color: rgb(var(--c-muted)); white-space: nowrap; }
.meter-track {
  height: 2px; min-width: 0; flex: 1; overflow: hidden; border-radius: 9999px;
  background: rgb(var(--c-surface-high));
}
.meter-fill { display: block; height: 100%; border-radius: 9999px; background: rgb(var(--c-text)); }
.meter-fill.warn { background: rgb(var(--c-warning)); }
.meter-fill.danger { background: rgb(var(--c-danger)); }
.meter-pct { width: 32px; flex-shrink: 0; text-align: right; font-size: 10px; color: rgb(var(--c-faint)); }

.sb-toolbar {
  display: flex; align-items: center; gap: 6px; padding: 10px 12px 4px;
  font-size: 10px; color: rgb(var(--c-muted));
}
.sb-toolbar .brand { font-weight: 600; }
.sb-toolbar .spacer { flex: 1; }
.tb-btn {
  display: flex; align-items: center; gap: 6px; border-radius: 6px;
  padding: 2px 6px; font-size: 10px; font-weight: 500; color: rgb(var(--c-muted));
  transition: background 0.15s;
}
.tb-btn:hover { background: rgb(var(--c-surface-high)); }
.tb-btn svg { height: 13px; width: 13px; }

/* ---------- Main pane ---------- */

.main { display: flex; flex: 1; flex-direction: column; overflow: hidden; background: rgb(var(--c-bg)); }

.main-toolbar {
  position: sticky; top: 0; z-index: 40; display: flex; min-height: 64px; flex-shrink: 0;
  align-items: center; gap: 10px; padding: 8px 16px;
  background: rgb(var(--c-surface) / 0.95); backdrop-filter: blur(4px);
  border-bottom: 1px solid var(--ghost-border);
}
.main-title { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main-chip {
  font-size: 10px; color: rgb(var(--c-faint));
  border: 1px solid var(--ghost-border); border-radius: 6px; padding: 2px 6px;
}
.icon-btn {
  display: flex; height: 30px; width: 30px; flex-shrink: 0; align-items: center; justify-content: center;
  border-radius: 8px; border: 1px solid rgb(var(--c-border));
  background: rgb(var(--c-surface-high)); color: rgb(var(--c-faint));
  transition: border-color 0.15s, color 0.15s;
}
.icon-btn:hover { border-color: rgb(var(--c-accent) / 0.5); color: rgb(var(--c-text)); }
.icon-btn svg { height: 16px; width: 16px; }

.main-body { flex: 1; overflow-y: auto; padding: 24px; }
.msg { max-width: 660px; margin: 0 auto 16px; }
.msg .who { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: rgb(var(--c-faint)); margin-bottom: 4px; }
.msg .bubble {
  border-radius: 12px; padding: 12px 14px; font-size: 13.5px; line-height: 1.55;
  color: rgb(var(--c-muted));
}
.msg.user .bubble { background: rgb(var(--c-surface-high)); }
.msg.assistant .bubble { background: rgb(var(--c-elevated)); border: 1px solid var(--ghost-border); }

.composer {
  flex-shrink: 0; margin: 0 24px 20px; border-radius: 14px; padding: 12px 14px;
  background: rgb(var(--c-elevated)); border: 1px solid rgb(var(--c-border) / 0.65);
  box-shadow: var(--composer-shadow);
  display: flex; align-items: center; gap: 10px; max-width: 660px; width: calc(100% - 48px);
  align-self: center;
}
.composer .hint { flex: 1; font-size: 13.5px; color: rgb(var(--c-faint)); }
.composer svg { height: 16px; width: 16px; flex-shrink: 0; color: rgb(var(--c-faint)); }

/* ---------- Dialog ---------- */

.dialog-backdrop {
  position: fixed; inset: 0; z-index: 60; display: none;
  align-items: center; justify-content: center; padding: 16px;
  background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(12px);
  animation: fadeIn 0.15s ease;
}
.dialog-backdrop.open { display: flex; }

.dialog {
  display: flex; max-height: calc(100dvh - 32px); width: 100%; max-width: 896px;
  flex-direction: column; overflow: hidden; border-radius: 8px;
  background: rgb(var(--c-shell));
  border: 1px solid var(--ghost-border);
  box-shadow: 0 0 24px rgb(var(--c-accent) / 0.12);
  animation: dialogScaleIn 0.2s ease;
}

.dlg-header {
  display: flex; flex-shrink: 0; align-items: center; justify-content: space-between;
  padding: 12px 20px; border-bottom: 1px solid var(--ghost-border);
}
.dlg-header h2 { font-size: 18px; font-weight: 600; }
.dlg-header p { margin-top: 2px; font-size: 12px; color: rgb(var(--c-faint)); }
.dlg-close {
  border-radius: 8px; padding: 6px; color: rgb(var(--c-faint));
  transition: background 0.15s, color 0.15s;
}
.dlg-close:hover { background: rgb(var(--c-surface-high)); color: rgb(var(--c-text)); }
.dlg-close svg { height: 16px; width: 16px; }

.dlg-body {
  display: flex; min-height: 0; flex: 1; gap: 16px; overflow-y: auto; padding: 16px 20px;
}
.dlg-col-l { flex: 55; min-width: 0; }
.dlg-col-r { flex: 45; min-width: 0; }
.dlg-vr { width: 1px; flex-shrink: 0; background: rgb(var(--c-border) / 0.2); }

.dlg-label {
  display: block; margin-bottom: 6px; font-size: 12px; font-weight: 500; color: rgb(var(--c-faint));
}
.dlg-eyebrow {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
  font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em;
  color: rgb(var(--c-faint));
}

.dlg-section { margin-bottom: 20px; }

/* backend cards */
.backend-grid { display: grid; gap: 6px; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); }
.backend-card {
  min-height: 60px; border-radius: 8px; border: 1px solid rgb(var(--c-border) / 0.3);
  background: rgb(var(--c-surface-high) / 0.3); padding: 6px 10px; text-align: left;
  transition: all 0.2s;
}
.backend-card:hover { border-color: rgb(var(--c-border)); }
.backend-card .bc-label { font-size: 14px; font-weight: 500; color: rgb(var(--c-text)); }
.backend-card .bc-desc { margin-top: 2px; font-size: 11px; color: rgb(var(--c-faint)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.backend-card.sel-claude { border-color: rgba(249, 115, 22, 0.4); background: rgba(249, 115, 22, 0.1); }
.backend-card.sel-codex { border-color: rgba(34, 197, 94, 0.4); background: rgba(34, 197, 94, 0.1); }
.backend-card.sel-hybrid { border-color: rgba(249, 115, 22, 0.4); background: linear-gradient(to bottom right, rgba(249, 115, 22, 0.1), rgba(34, 197, 94, 0.1)); }
.backend-card.sel-gemini { border-color: rgb(var(--c-accent) / 0.4); background: rgb(var(--c-accent) / 0.1); }

.dlg-select {
  width: 100%; border-radius: 8px; border: 1px solid rgb(var(--c-border) / 0.3);
  background: rgb(var(--c-surface-high) / 0.5); padding: 8px 12px; font-size: 14px;
  color: rgb(var(--c-text)); cursor: pointer;
}
.dlg-select:focus { border-color: rgb(var(--c-accent) / 0.5); box-shadow: 0 0 0 1px rgb(var(--c-accent) / 0.3); }

.dlg-footer {
  display: flex; flex-shrink: 0; align-items: center; justify-content: flex-end; gap: 12px;
  padding: 12px 20px; border-top: 1px solid var(--ghost-border);
}
.btn-ghost {
  border-radius: 8px; padding: 8px 16px; font-size: 14px; color: rgb(var(--c-faint));
  transition: background 0.15s, color 0.15s;
}
.btn-ghost:hover { background: rgb(var(--c-surface-high)); color: rgb(var(--c-text)); }
.btn-create { border-radius: 8px; padding: 8px 20px; font-size: 14px; }

/* server usage chips (text style, from ServerSwitcher UsageChips) */
.uchips { display: flex; flex-wrap: wrap; gap: 0 6px; font-size: 9px; font-weight: 500; }
.uchips span { color: rgb(var(--c-faint)); }
.uchips span.warn { color: rgb(var(--c-warning)); }
.uchips span.danger { color: rgb(var(--c-danger)); }

/* generic pill */
.pill {
  display: inline-flex; align-items: center; gap: 4px; border-radius: 9999px;
  padding: 2px 8px; font-size: 10px; font-weight: 500;
}

/* ---------- Variant switcher bar (mockup chrome, not part of the design) ---------- */

.variant-bar {
  position: fixed; bottom: 14px; right: 14px; z-index: 100;
  display: flex; align-items: center; gap: 4px;
  border-radius: 10px; padding: 6px 8px;
  background: rgb(var(--c-elevated) / 0.96); border: 1px solid var(--ghost-border-strong);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
  font-size: 11px;
}
.variant-bar a, .variant-bar button {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; height: 24px; border-radius: 6px; padding: 0 5px;
  color: rgb(var(--c-faint)); text-decoration: none; font-weight: 600; font-size: 10.5px;
  transition: background 0.15s, color 0.15s;
}
.variant-bar a:hover, .variant-bar button:hover { background: rgb(var(--c-surface-high)); color: rgb(var(--c-text)); }
.variant-bar a.current { background: rgb(var(--c-accent)); color: rgb(var(--c-accent-fg)); }
.variant-bar .vb-sep { width: 1px; height: 16px; background: var(--ghost-border-strong); margin: 0 3px; }
.variant-bar svg { height: 14px; width: 14px; }

@media (max-width: 900px) {
  .dlg-body { flex-direction: column; }
  .dlg-vr { display: none; }
}
