/* ═══════════════════════════════════════════════════════
   Layout — Hero, Header, Sidebar, Main Content
   ═══════════════════════════════════════════════════════ */

/* ── Hero ── */
.hero {
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  position: relative;
  overflow: hidden;
}

/* Subtle radial glow behind hero */
.hero::before {
  content: "";
  position: absolute;
  top: -40%;
  right: -10%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
  pointer-events: none;
  opacity: 0.6;
}

.hero-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 40px 32px 36px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  align-items: center;
  position: relative;
  animation: fadeUp 0.5s ease-out;
}

.hero-text h2 {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 400;
  line-height: 1.35;
  margin-bottom: 14px;
  letter-spacing: -0.01em;
}

.hero-text p {
  font-size: 0.86rem;
  line-height: 1.7;
  color: var(--text-secondary);
  max-width: 540px;
  margin-bottom: 20px;
}

.hero-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.hero-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #0c1021;
  transition: all 0.15s;
  letter-spacing: 0.02em;
}

.hero-btn:hover {
  background: var(--accent-hover);
  color: #0c1021;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--accent-glow);
}

.hero-btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.hero-btn-outline:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: none;
}

/* Pipeline diagram */
.hero-pipeline {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  justify-content: center;
}

.pipeline-step {
  flex: 1;
  text-align: center;
  max-width: 160px;
}

.pipeline-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--accent);
  transition: all 0.2s;
}

.pipeline-step:hover .pipeline-icon {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: 0 0 16px var(--accent-glow);
}

.pipeline-label {
  font-family: var(--font-body);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  letter-spacing: 0.01em;
}

.pipeline-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.pipeline-arrow {
  color: var(--accent);
  font-size: 1.1rem;
  margin-top: 12px;
  flex-shrink: 0;
  opacity: 0.5;
}

/* Section title above runs table */
.section-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 400;
  margin-bottom: 16px;
  color: var(--text);
  letter-spacing: 0.005em;
}

/* ── Header (used by run.html) ── */
.header {
  padding: 0 32px;
  height: 56px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.header::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.6;
}

.header h1 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 400;
  letter-spacing: 0.01em;
}

.header h1 span { color: var(--accent); }
.header h1 a { color: inherit; text-decoration: none; }
.header h1 a:hover { color: inherit; }

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-right a {
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.15s;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.header-right a:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
}

/* ── App Layout ── */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 200;
  transition: width 0.2s ease;
  overflow: hidden;
}

.sidebar-header {
  padding: 10px 10px 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  height: 48px;
  position: relative;
}

.sidebar-header::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0.5;
}

.sidebar-header h1 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-header h1 span {
  color: var(--accent);
}

.sidebar-logo-icon {
  color: var(--accent);
  opacity: 0.6;
  flex-shrink: 0;
}

.sidebar.collapsed .sidebar-logo-icon {
  display: none;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
  margin-left: auto;
}

.sidebar-toggle:hover {
  color: var(--accent);
  background: var(--accent-dim);
}

.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 12px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.84rem;
  font-weight: 500;
  line-height: 1;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-item:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.sidebar-item.active {
  color: var(--accent);
  background: var(--accent-dim);
}

.sidebar-item svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-item.active svg {
  opacity: 1;
}

.sidebar-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Sidebar chat history ── */
.sidebar-chat-history {
  padding: 4px 8px;
  overflow-y: auto;
  max-height: 40vh;
  border-top: 1px solid var(--border);
}

.sidebar-chat-history:empty {
  display: none;
}

.sidebar-history-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 8px 12px 4px;
}

.sidebar-history-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.sidebar-history-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.sidebar-history-item.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.sidebar-history-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-history-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  opacity: 0;
  transition: all 0.15s;
}

.sidebar-history-item:hover .sidebar-history-delete {
  opacity: 1;
}

.sidebar-history-delete:hover {
  color: var(--red);
  background: rgba(248, 113, 113, 0.1);
}

.sidebar.collapsed .sidebar-chat-history {
  display: none;
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  flex-wrap: nowrap;
}

.sidebar-footer a,
.sidebar-footer button {
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.15s;
  font-weight: 500;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.sidebar-footer a img,
.sidebar-footer a svg {
  flex-shrink: 0;
}

.sidebar-footer a:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
}

/* Resize handle */
.sidebar-resize {
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
  cursor: col-resize;
  z-index: 10;
  transition: background 0.15s;
}

.sidebar-resize:hover {
  background: var(--accent);
  opacity: 0.4;
}

/* ── Collapsed sidebar ── */
.sidebar.collapsed {
  width: 56px !important;
}

.sidebar.collapsed .sidebar-header h1,
.sidebar.collapsed .sidebar-label,
.sidebar.collapsed .sidebar-footer a span,
.sidebar.collapsed .sidebar-footer a {
  opacity: 0;
  width: 0;
  overflow: hidden;
  padding: 0;
  margin: 0;
  border: none;
}

.sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: 10px 8px;
}

.sidebar.collapsed .sidebar-item {
  justify-content: center;
  padding: 0;
  gap: 0;
}

.sidebar.collapsed .sidebar-footer {
  justify-content: center;
  padding: 12px 8px;
  gap: 0;
}

.sidebar.collapsed .sidebar-footer a {
  display: none;
}

.sidebar.collapsed .sidebar-resize {
  display: none;
}

.sidebar.collapsed .theme-toggle {
  margin-left: 0;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.8rem;
  transition: all 0.15s;
  flex-shrink: 0;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

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

.main-topbar {
  height: 48px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  flex-shrink: 0;
  position: relative;
}

.main-topbar::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.4;
}


.main-topbar-title {
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.01em;
}

.main-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px 28px;
  animation: fadeUp 0.4s ease-out;
}

/* When chat tab is active, main-body becomes a flex container */
.main-body:has(#tab-chat.active) {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 0;
}

#tab-chat.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ── Container (legacy, used inside tab panes) ── */
.container {
  max-width: 1440px;
  margin: 0 auto;
}

/* ── Breadcrumb ── */
.breadcrumb {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  font-weight: 400;
  letter-spacing: 0.01em;
}

.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent); }
