/* =========================================================================
   Helper — internal team docs UI
   Editorial / refined aesthetic. Two-column. Dark accents on cream paper.
   ========================================================================= */

:root {
  --bg: #f6f4ee;
  --bg-elev: #fdfcf8;
  --ink: #1a1816;
  --ink-soft: #4a4540;
  --ink-faint: #8a8480;
  --line: #e5dfd2;
  --accent: #c54a1a;      /* warm 5DayDeal-ish vermillion */
  --accent-soft: #fce8db;
  --highlight: #fff3a3;
  --user-bg: #eee6d4;
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --radius: 10px;
  --radius-sm: 6px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.app {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: 100vh;
  background: var(--bg);
}

/* ============ SIDEBAR ============ */

.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 22px 22px 18px;
  border-bottom: 1px solid var(--line);
}

.brand__mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.brand__mark svg {
  width: 22px;
  height: 22px;
}

.brand__text h1 {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.brand__text p {
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin-top: 3px;
}

.stats {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.stats__loading {
  color: var(--ink-faint);
  font-style: italic;
}

.stats__row {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
}

.stats__row strong {
  font-family: var(--serif);
  font-weight: 600;
  color: var(--ink);
}

.stats__row span {
  color: var(--ink-soft);
}

.topics {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px 12px;
}

.topics h2 {
  font-family: var(--serif);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  margin: 0 8px 10px;
}

.topics ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.topics li button {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  transition: background 120ms;
}

.topics li button:hover {
  background: var(--accent-soft);
}

.topics li button .count {
  color: var(--ink-faint);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.sidebar__footer {
  padding: 14px 22px 18px;
  border-top: 1px solid var(--line);
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
}

.link-btn:hover {
  text-decoration: underline;
}

.legal {
  font-size: 10px;
  color: var(--ink-faint);
  margin-top: 10px;
  letter-spacing: 0.04em;
}

/* ============ CHAT ============ */

.chat {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.chat__welcome {
  max-width: 640px;
  margin: 12vh auto 0;
  padding: 0 40px;
  text-align: center;
}

.chat__welcome h2 {
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 14px;
}

.chat__welcome > p {
  color: var(--ink-soft);
  font-size: 15px;
  margin-bottom: 32px;
  line-height: 1.6;
}

.examples {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  text-align: left;
}

.example-q {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-family: var(--serif);
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  transition: all 150ms;
  line-height: 1.4;
}

.example-q:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 32px 0;
}

.messages:empty {
  display: none;
}

.messages:not(:empty) ~ .composer {
  border-top: 1px solid var(--line);
}

body.has-messages .chat__welcome {
  display: none;
}

.msg {
  max-width: 720px;
  margin: 0 auto 28px;
  padding: 0 40px;
  animation: slideIn 240ms cubic-bezier(0.2, 0, 0.2, 1);
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg__role {
  font-family: var(--serif);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 8px;
}

.msg--user .msg__role { color: var(--accent); }

.msg__content {
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink);
}

.msg--user .msg__content {
  background: var(--user-bg);
  padding: 14px 18px;
  border-radius: var(--radius);
  font-family: var(--serif);
}

.msg__content p { margin: 0 0 12px; }
.msg__content p:last-child { margin-bottom: 0; }

.msg__content code {
  font-family: var(--mono);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.88em;
}

.msg__content .ref {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 5px;
  background: var(--accent);
  color: #fff;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  border-radius: 3px;
  margin: 0 2px;
  text-decoration: none;
  vertical-align: 1px;
  transition: background 120ms;
}

.msg__content .ref:hover { background: var(--ink); }

.msg__citations {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
}

.msg__citations:empty { display: none; }

.citation {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--ink);
  font-size: 13px;
  transition: all 150ms;
}

.citation:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.citation__num {
  display: grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  background: var(--ink);
  color: #fff;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}

.citation:hover .citation__num { background: var(--accent); }

.citation__body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.citation__title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.citation__time {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-faint);
  margin-top: 1px;
}

/* Loading dots */
.thinking {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}

.thinking span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-faint);
  animation: bounce 1.2s infinite;
}

.thinking span:nth-child(2) { animation-delay: 0.15s; }
.thinking span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

/* ============ COMPOSER ============ */

.composer {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 16px 40px 24px;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

.composer textarea {
  flex: 1;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  resize: none;
  outline: none;
  max-height: 200px;
  transition: border-color 120ms;
}

.composer textarea:focus {
  border-color: var(--accent);
}

.composer textarea::placeholder {
  color: var(--ink-faint);
}

#send {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: all 150ms;
}

#send:hover {
  background: var(--ink);
  transform: translateY(-1px);
}

#send:disabled {
  background: var(--ink-faint);
  cursor: not-allowed;
  transform: none;
}

#send svg {
  width: 18px;
  height: 18px;
}

/* ============ RESPONSIVE ============ */

@media (max-width: 720px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--line);
    max-height: 50vh;
  }
  .examples {
    grid-template-columns: 1fr;
  }
  .chat__welcome {
    margin-top: 6vh;
    padding: 0 24px;
  }
  .chat__welcome h2 { font-size: 24px; }
  .msg { padding: 0 24px; }
  .composer { padding: 12px 24px 20px; }
}

/* Embedded in tools.5daydeal.com iframe — no scroll inside iframe */
body.embedded .sidebar { display: none; }
body.embedded .app { grid-template-columns: 1fr; }
