/* layout.css — structural layout only. All colours and fonts are in brand.css. */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

/* sophia.css pads the body for its dashboard pages; Logos's shell fills the window. */
body {
  padding: 0;
  min-height: 0;
}

/* ---- App shell ---- */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 860px;
  margin: 0 auto;
}

/* ---- Header ---- */

.app-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}

.brand-logo {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.brand-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.lang-select {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  background: var(--input-bg);
  color: var(--input-text);
  font: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}

.lang-select:focus {
  border-color: var(--accent);
}

/* ---- Chat area ---- */

.chat {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 80%;
}

.message.user {
  align-self: flex-end;
  align-items: flex-end;
}

.message.assistant {
  align-self: flex-start;
  align-items: flex-start;
}

/* ---- Bubbles ---- */

.message-bubble {
  padding: 0.625rem 0.875rem;
  border-radius: 0.75rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9375rem;
}

.message.user .message-bubble {
  background: var(--user-bubble-bg);
  color: var(--user-bubble-text);
  border-bottom-right-radius: 0.2rem;
}

.message.assistant .message-bubble {
  background: var(--assistant-bubble-bg);
  color: var(--assistant-bubble-text);
  border-bottom-left-radius: 0.2rem;
}

/* A completed answer is rendered Markdown: paragraphs and lists instead of pre-wrapped text. */
.message-bubble.rendered { white-space: normal; }
.message-bubble.rendered p { margin: 0 0 0.6em; }
.message-bubble.rendered p:last-child { margin-bottom: 0; }
.message-bubble.rendered ol, .message-bubble.rendered ul { margin: 0.2em 0 0.6em; padding-left: 1.4em; }
.message-bubble.rendered li { margin: 0.25em 0; }
.message-bubble.rendered a { color: var(--accent); }

/* ---- Citations ---- */

.citations {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  max-width: 100%;
}

.citation {
  font-size: 0.75rem;
  padding: 0.3rem 0.6rem;
  border-left: 2px solid var(--accent);
  background: var(--citation-bg);
  color: var(--citation-text);
  border-radius: 0 0.25rem 0.25rem 0;
}

.citation-title {
  font-weight: 500;
}

.citation-meta {
  opacity: 0.7;
  margin-top: 0.1rem;
}

.citations-heading {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.7;
  margin-top: 0.3rem;
}

.citation-excerpt {
  margin-top: 0.2rem;
  font-style: italic;
  opacity: 0.85;
}

a.citation-title {
  color: inherit;
  text-decoration: none;
}

a.citation-title:hover {
  text-decoration: underline;
}

.clarify-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.3rem;
}

.clarify-option {
  font: inherit;
  font-size: 0.8rem;
  padding: 0.25rem 0.7rem;
  border: 1px solid var(--accent);
  border-radius: 1rem;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

/* ---- Typing indicator ---- */

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.75rem 0.875rem;
  background: var(--assistant-bubble-bg);
  border-radius: 0.75rem;
  border-bottom-left-radius: 0.2rem;
  width: fit-content;
}

.typing-dot {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--typing-dot);
  animation: typing-bounce 1.2s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.6; }
  30%           { transform: translateY(-5px); opacity: 1; }
}

/* ---- Input area ---- */

.input-area {
  flex-shrink: 0;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
}

.input-form {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.input-field {
  flex: 1;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: 0.625rem;
  font: inherit;
  font-size: 0.9375rem;
  line-height: 1.5;
  resize: none;
  outline: none;
  background: var(--input-bg);
  color: var(--input-text);
  transition: border-color 0.15s;
  max-height: 10rem;
  overflow-y: auto;
}

.input-field:focus {
  border-color: var(--accent);
}

.input-field::placeholder {
  color: var(--placeholder);
}

.send-btn {
  padding: 0.625rem 1.125rem;
  border: none;
  border-radius: 0.625rem;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s;
  line-height: 1.5;
}

.send-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.send-btn:not(:disabled):hover {
  opacity: 0.85;
}

/* ---- View switch (Ask / Navigate) ---- */

.app-nav {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
}

.app-nav a {
  padding: 0.3rem 0.6rem;
  border-radius: 0.4rem;
  font-size: 0.875rem;
  text-decoration: none;
  color: var(--text);
}

.app-nav a[aria-current="page"] {
  background: var(--accent);
  color: var(--accent-text);
}

/* ---- Navigator ---- */

.app-wide {
  max-width: 1200px;
}

.navigator-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.5rem;
  padding: 1rem 1.25rem;
  overflow: hidden;
  flex: 1;
  min-height: 0;
}

.navigator-tree,
.navigator-detail {
  overflow-y: auto;
  min-height: 0;
}

.navigator-detail {
  border-left: 1px solid var(--border);
  padding-left: 1.5rem;
}

.navigator-detail-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.navigator-detail-doc {
  font-size: 0.85rem;
  color: var(--placeholder);
  margin-bottom: 0.75rem;
}

.navigator-detail-open {
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  background: var(--input-bg);
  color: var(--input-text);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.navigator-detail-text {
  margin-top: 1rem;
  white-space: pre-wrap;
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.5;
}

@media (max-width: 720px) {
  .navigator-view {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  .navigator-detail {
    border-left: 0;
    border-top: 1px solid var(--border);
    padding: 1rem 0 0;
  }
}

/* ---- Language switcher (tools/pkg/i18n; styled by sophia.css) and theme toggle ---- */

.app-header .lang-switch {
  flex-wrap: nowrap;
}

.theme-toggle {
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  border-radius: 0.4rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 0.95rem;
  cursor: pointer;
}

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

@media (max-width: 720px) {
  .app-header {
    flex-wrap: wrap;
  }
}

/* ---- About ---- */

.about-view {
  padding: 1rem 1.25rem 2rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.about-section + .about-section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.about-section h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.about-section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 1.25rem 0 0.5rem;
}

.about-section p {
  line-height: 1.55;
  margin-bottom: 0.75rem;
}

.about-explain,
.about-note,
.about-document-meta {
  color: var(--placeholder);
  font-size: 0.9rem;
}

.about-figures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.about-figures div {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}

.about-figures dt {
  font-size: 0.8rem;
  color: var(--placeholder);
}

.about-figures dd {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0.15rem 0 0;
}

.about-documents {
  list-style: none;
  padding: 0;
}

.about-documents li {
  padding: 0.35rem 0;
}

.navigator-views {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.navigator-views button {
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  background: var(--input-bg);
  color: var(--input-text);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.navigator-views button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}
