/* CSV-SAAS-V1.2 — investor demo styles.
   Plain CSS, system fonts only. No Tailwind, no external fonts/CDN, no remote
   assets. Per-tenant branding is driven solely by the --accent variables set
   inline on .app from typed presentation config. */

:root {
  --accent: #334155;
  --accent-soft: #eef2f6;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --ink: #0f172a;
  --ink-soft: #475569;
  --ink-faint: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --danger: #b42318;
  --danger-soft: #fef3f2;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06);
  --maxw: 1080px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Visible keyboard focus everywhere. */
a:focus-visible,
button:focus-visible,
select:focus-visible,
textarea:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---- App shell ---------------------------------------------------------- */
.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app__main {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px 20px 12px;
}

.app__footer {
  max-width: var(--maxw);
  width: 100%;
  margin: 0 auto;
  padding: 14px 20px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--ink-faint);
  font-size: 13px;
}

/* ---- Header ------------------------------------------------------------- */
.header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
}

.header__identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-badge {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.5px;
  display: grid;
  place-items: center;
  font-size: 15px;
}

.header__titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.header__product {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
}

.header__tenant {
  color: var(--ink-soft);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 40vw;
}

.demo-badge {
  flex: none;
  margin-left: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fffbe6;
  color: #8a6d00;
  border: 1px solid #f2d675;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
}

.header__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

/* Language selector */
.lang {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  overflow: hidden;
}

.lang__btn {
  border: none;
  background: var(--surface);
  color: var(--ink-soft);
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.lang__btn[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
}

/* Tenant switcher */
.switcher {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.switcher__label {
  font-size: 12px;
  color: var(--ink-faint);
}

.switcher__select {
  font: inherit;
  font-size: 13px;
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  max-width: 200px;
}

/* Buttons */
.btn {
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease,
    transform 0.05s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn--accent {
  background: var(--accent);
  color: #fff;
}

.btn--accent:hover {
  filter: brightness(0.94);
}

.btn--accent:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn--ghost {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
}

.btn--ghost:hover {
  background: var(--surface-2);
}

/* ---- Intro state -------------------------------------------------------- */
.intro {
  max-width: 720px;
  margin: 24px auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.intro__title {
  margin: 0 0 8px;
  font-size: 24px;
  line-height: 1.25;
}

.intro__body {
  margin: 0 0 14px;
  color: var(--ink-soft);
}

.intro__synthetic {
  margin: 0 0 22px;
  padding: 10px 14px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-size: 13.5px;
}

.intro__suggestions-title {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--ink-faint);
}

.suggestion-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.suggestion-list--inline {
  flex-direction: row;
  flex-wrap: wrap;
  margin-top: 10px;
}

.suggestion {
  font: inherit;
  text-align: left;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
  color: var(--ink);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.suggestion:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.suggestion--small {
  width: auto;
  padding: 8px 12px;
  font-size: 13px;
}

/* ---- Timeline ----------------------------------------------------------- */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 8px 0 16px;
}

.message {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 760px;
}

.message--user {
  align-self: flex-end;
  align-items: flex-end;
}

.message--assistant {
  align-self: flex-start;
  width: 100%;
}

.message__role {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.message__text {
  margin: 0;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message--user .message__text {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  border-bottom-right-radius: 4px;
}

.message--assistant .message__text {
  border-bottom-left-radius: 4px;
}

/* Loading dots */
.thinking {
  margin: 0;
  padding: 14px 16px;
  display: inline-flex;
  gap: 5px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.thinking__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-faint);
  animation: blink 1.2s infinite ease-in-out both;
}

.thinking__dot:nth-child(2) {
  animation-delay: 0.18s;
}

.thinking__dot:nth-child(3) {
  animation-delay: 0.36s;
}

@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.25;
  }
  40% {
    opacity: 1;
  }
}

/* ---- Recommendations / product cards ----------------------------------- */
.recs {
  margin-top: 6px;
}

.recs__title {
  margin: 4px 0 12px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--ink-faint);
}

.recs__grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.card {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.card__media {
  height: 96px;
  display: grid;
  place-items: center;
  position: relative;
}

.card__media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.22),
    rgba(0, 0, 0, 0.12)
  );
}

.card__initials {
  position: relative;
  z-index: 1;
  color: #fff;
  font-weight: 800;
  font-size: 28px;
  letter-spacing: 1px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.card__body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card__name {
  margin: 0;
  font-size: 15.5px;
  line-height: 1.3;
}

.card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.card__chip {
  font-size: 12px;
  color: var(--ink-soft);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 3px 10px;
}

.card__chip-label {
  color: var(--ink-faint);
}

.card__price {
  margin: 0;
  font-weight: 700;
  font-size: 16px;
  color: var(--ink);
}

.card__desc {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink-soft);
}

.card__tags {
  list-style: none;
  margin: 2px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  font-size: 11.5px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}

.tag--attr {
  background: var(--surface-2);
}

/* ---- No results --------------------------------------------------------- */
.no-results {
  margin-top: 10px;
  padding: 14px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.no-results__title {
  margin: 0 0 4px;
  font-weight: 700;
}

.no-results__body {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
}

/* ---- Error -------------------------------------------------------------- */
.error-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border: 1px solid #f0c4bf;
  background: var(--danger-soft);
  border-radius: var(--radius);
}

.error-banner__text {
  margin: 0;
  color: var(--danger);
  font-weight: 600;
}

/* ---- Composer ----------------------------------------------------------- */
.composer {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 12px 20px;
}

.composer__row {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.composer__input {
  flex: 1;
  font: inherit;
  resize: vertical;
  min-height: 46px;
  max-height: 180px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
}

.composer__input[aria-invalid="true"] {
  border-color: var(--danger);
}

.composer__send {
  flex: none;
  min-width: 110px;
  height: 46px;
}

.composer__hint {
  max-width: var(--maxw);
  margin: 6px auto 0;
  font-size: 12px;
  color: var(--ink-faint);
}

.composer__error {
  color: var(--danger);
  font-weight: 600;
}

/* ---- Contact panel ------------------------------------------------------ */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(15, 23, 42, 0.45);
  display: grid;
  place-items: center;
  padding: 16px;
}

.contact {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  max-height: 90vh;
  overflow: auto;
}

.contact__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.contact__title {
  margin: 0;
  font-size: 19px;
}

.contact__close {
  padding: 6px 10px;
  line-height: 1;
}

.contact__body {
  margin: 12px 0 8px;
  color: var(--ink-soft);
}

.contact__notice {
  margin: 0 0 16px;
  padding: 10px 12px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--ink-soft);
}

.contact__form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}

.field__input {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
}

.contact__submitted {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13.5px;
  font-weight: 600;
}

/* ---- Unrecognized host (fail-closed) ------------------------------------ */
.host-unrecognized {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.host-unrecognized__card {
  max-width: 460px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
}

.host-unrecognized__card h1 {
  margin: 16px 0 8px;
  font-size: 22px;
}

.host-unrecognized__card p {
  margin: 0 0 16px;
  color: var(--ink-soft);
}

.host-unrecognized__card .brand-badge {
  margin: 0 auto;
}

.host-unrecognized__hosts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.host-unrecognized__hosts code {
  display: inline-block;
  padding: 6px 10px;
  background: var(--surface-2);
  border-radius: 6px;
  font-size: 13px;
}

/* ---- Responsive --------------------------------------------------------- */
@media (max-width: 640px) {
  .header {
    padding: 10px 14px;
  }

  .header__controls {
    width: 100%;
    justify-content: space-between;
  }

  .header__tenant {
    max-width: 60vw;
  }

  .app__main {
    padding: 16px 14px 8px;
  }

  .intro {
    padding: 20px;
  }

  .composer {
    padding: 10px 14px;
  }

  .composer__send {
    min-width: 92px;
  }

  .message--user,
  .message {
    max-width: 100%;
  }
}

@media (max-width: 380px) {
  .recs__grid {
    grid-template-columns: 1fr;
  }

  .switcher__label {
    display: none;
  }

  .demo-badge {
    font-size: 10px;
    padding: 3px 8px;
  }
}

/* ---- Reduced motion ----------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- Dark mode ---------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --surface: #111827;
    --surface-2: #1e293b;
    --ink: #f1f5f9;
    --ink-soft: #cbd5e1;
    --ink-faint: #94a3b8;
    --line: #243044;
    --line-strong: #334155;
    --danger: #fca5a5;
    --danger-soft: #2a1414;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  }

  .demo-badge {
    background: #2a2410;
    color: #ffd966;
    border-color: #5c4d12;
  }
}
