/* =============================================================
   layout.css — page structure & scaffolding.
   ============================================================= */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* page = sidebar + main. Sidebar slides in/out; main fills the rest. */
.page {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
}
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* --- Sidebar (history) --- */
.sidebar {
  width: 0;
  flex: none;
  overflow: hidden;
  background: var(--bg-sunk);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width var(--dur) var(--ease);
  /* Pin to the viewport, not the (tall) page. The history list scrolls
     internally; the footer stays put at the bottom of the screen. */
  position: sticky;
  top: 0;
  height: 100vh;
  align-self: flex-start;
}
.page.sidebar-open .sidebar { width: var(--sidebar-w); }
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 16px 8px;
  white-space: nowrap;
}
.sidebar-brand .btn-icon { margin-left: auto; }
.sidebar-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px 10px;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  white-space: nowrap;
}
.sidebar .history {
  flex: 1;
  overflow-y: auto;
  padding: 0 10px;
  display: block;
}
.sidebar-foot {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
/* Hide the hamburger while the sidebar is open. */
.page.sidebar-open #sidebarOpen { display: none; }

/* --- Top bar --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  gap: 16px;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; }
.topbar .spacer { flex: 1; }

/* --- Centered hero (home state) --- */
.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px 80px;
  gap: 26px;
  text-align: center;
}
.hero.compact {
  flex: none;
  justify-content: flex-start;
  padding: 8px 20px 20px;
}

.search-wrap { width: 100%; max-width: 720px; }

/* --- Results region --- */
.results {
  flex: 1;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 8px 20px 120px;
}

/* --- Tab bar --- */
.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  margin: 18px 0 22px;
}

/* --- Grid for image results --- */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

/* --- Footer --- */
.footer {
  padding: 20px 24px 34px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}

/* --- Advanced-params panel grid --- */
.adv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px 18px;
}

/* --- Settings page --- */
.settings-shell {
  width: 100%;
  max-width: 640px;
  margin: 20px auto 80px;
  padding: 0 20px;
}

/* --- Chat pane --- */
.chat-log {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 18px;
}
.chat-input-row { display: flex; gap: 10px; align-items: flex-end; }

@media (max-width: 560px) {
  .topbar { padding: 12px 16px; }
  .results { padding: 8px 14px 120px; }
  /* Sidebar overlays content on small screens instead of pushing it. */
  .sidebar { position: fixed; z-index: 40; top: 0; bottom: 0; box-shadow: var(--shadow-lg); }
}
