:root {
  /* --brand e a cor da marca: bordas, tints, foco. Nao carrega texto branco:
     #fff sobre ela da 2.85:1, abaixo do minimo de 4.5:1 da WCAG AA.
     --brand-ink e a versao que carrega texto branco (4.82:1).
     --brand-darker e o laranja para TEXTO sobre claro (6.51:1). */
  --brand: #e67e22;
  --brand-ink: #c04f00;
  --brand-dark: #d35400;
  --brand-darker: #a04000;
  --brand-soft: #fdf1e5;
  --bg: #f4f4f4;
  --panel: #ffffff;
  --panel-2: #fafafa;
  --line: #e3e3e3;
  --line-soft: #efefef;
  --text: #333333;
  --muted: #767676;
  --soft: #555555;
  --faint: #767676;
  --success: #146c3a;
  --success-soft: #e6f5ec;
  --danger: #c0392b;
  --danger-soft: #fdeceb;
  --radius-control: 8px;
  --radius-panel: 12px;
  --shadow-panel: 0 1px 2px rgba(0, 0, 0, .05), 0 8px 24px rgba(0, 0, 0, .05);
  --font-display: Archivo, ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  --font-body: "Public Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  overflow-x: hidden;
}

::selection { background: var(--brand); color: #fff; }
*:focus-visible { outline: 2px solid var(--brand-dark); outline-offset: 2px; }
button, input, textarea { font: inherit; }
h1, h2, p { margin: 0; }
a { color: var(--brand-darker); text-decoration: none; }
a:hover { color: #7d3200; }

.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;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}

/* ======================= LOGIN ======================= */

.login-body { background: var(--panel); }

.login {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.login-brand {
  background: var(--brand-ink);
  color: #fff;
  padding: 56px 52px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 40px;
}

.login-brand-top { display: flex; flex-direction: column; gap: 40px; }

.login-logo {
  width: 168px;
  height: 68px;
  background: #fff;
  border-radius: 10px;
  display: grid;
  place-items: center;
  padding: 10px;
}

.login-logo img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }

.login-pitch { display: flex; flex-direction: column; gap: 18px; max-width: 460px; }

.login-pitch h1 {
  font-family: var(--font-display);
  font-size: clamp(30px, 3.2vw, 44px);
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -.8px;
  text-wrap: pretty;
}

.login-pitch p { font-size: 17px; line-height: 1.6; color: #ffffff; }

.login-stats {
  display: flex;
  gap: 48px;
  border-top: 1px solid rgba(255, 255, 255, .28);
  padding-top: 24px;
}

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat strong { font-family: var(--font-display); font-size: 30px; font-weight: 700; }
.stat span { font-size: 13px; color: #ffffff; }

.login-form-area {
  display: grid;
  place-items: center;
  padding: 48px;
  background: var(--bg);
}

.login-form {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.login-heading { display: flex; flex-direction: column; gap: 8px; }

.login-heading h2 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -.3px;
}

.login-heading p { font-size: 15px; color: var(--muted); }

.login-erro {
  background: var(--danger-soft);
  border: 1px solid #f2c9c4;
  color: var(--danger);
  border-radius: var(--radius-control);
  padding: 11px 13px;
  font-size: 14px;
}

.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: 13px; font-weight: 500; color: var(--soft); }

.field input {
  height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--panel);
  color: var(--text);
  padding: 0 14px;
  font-size: 16px;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.field input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(230, 126, 34, .16);
}

.btn-primary {
  height: 50px;
  border: none;
  border-radius: var(--radius-control);
  background: var(--brand-ink);
  color: #fff;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease;
}

.btn-primary:hover { background: #a04000; }

.login-nota {
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; }
  .login-brand { padding: 32px 24px; gap: 28px; }
  .login-brand-top { gap: 24px; }
  .login-logo { width: 132px; height: 56px; }
  .login-pitch p { font-size: 15px; }
  .login-stats { gap: 32px; padding-top: 18px; }
  .stat strong { font-size: 24px; }
  .login-form-area { padding: 32px 24px 48px; }
}

/* ======================= CHAT ======================= */

.shell {
  width: min(1120px, 100%);
  height: 100dvh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--panel);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 26px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.page-title { min-width: 0; display: flex; align-items: center; gap: 14px; }

.page-mark {
  flex: 0 0 auto;
  width: 104px;
  height: 42px;
  border-radius: var(--radius-control);
  border: 1px solid var(--line);
  background: var(--panel);
  display: grid;
  place-items: center;
  padding: 6px;
}

.page-mark img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }

.topbar-divider { flex: 0 0 auto; width: 1px; height: 34px; background: var(--line); }

.page-title-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }

.page-title-text strong {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.2px;
}

.eyebrow { color: var(--muted); font-size: 12.5px; }

.topbar-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 12px; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
}

.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }

.btn-ghost {
  display: inline-grid;
  place-items: center;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--panel);
  color: var(--soft);
  font-size: 13.5px;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease;
}

.btn-ghost:hover { border-color: var(--brand); color: var(--brand-darker); }

.chat {
  overflow-y: auto;
  padding: 24px 26px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--bg);
  scroll-behavior: smooth;
}

.msg { display: flex; flex-direction: column; max-width: 640px; gap: 12px; }
.msg.agent { align-self: flex-start; }
.msg.user { align-self: flex-end; align-items: flex-end; max-width: 480px; }
.msg.wide { max-width: 100%; width: 100%; }

.bubble {
  padding: 13px 16px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg.agent .bubble {
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}

.msg.user .bubble {
  background: var(--brand-ink);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg.error .bubble {
  background: var(--danger-soft);
  border: 1px solid #f2c9c4;
  color: var(--danger);
  font-size: 14px;
}

.retry {
  align-self: flex-start;
  border: 1px solid var(--danger);
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--danger);
  min-height: 32px;
  padding: 0 12px;
  font-size: 13px;
  cursor: pointer;
}

.retry:hover { background: var(--danger); color: #fff; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; max-width: 640px; }

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--soft);
  min-height: 36px;
  padding: 0 14px;
  font-size: 13.5px;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}

.chip:hover { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-darker); }

/* Indicador de digitacao */
.typing { display: inline-flex; align-items: center; gap: 5px; padding: 16px; }

.typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted);
  animation: typing-bounce 1.2s infinite ease-in-out;
}

.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .45; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---- Cards de produto ---- */

.products {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.product {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.product:hover { border-color: var(--brand); box-shadow: var(--shadow-panel); }

.product-media {
  height: 140px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line-soft);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.product-media img { width: 100%; height: 100%; object-fit: contain; padding: 10px; }

.product-fallback {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: #c9c9c9;
}

.product-body {
  padding: 13px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
}

.product-brand {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--muted);
}

.product-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  margin: 0;
  text-wrap: pretty;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-price { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }

.price-now {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
}

.price-old { font-size: 13px; color: var(--faint); text-decoration: line-through; }

.badge {
  align-self: flex-start;
  font-size: 11.5px;
  font-weight: 500;
  border-radius: 999px;
  padding: 4px 9px;
}

.badge.on { color: var(--success); background: var(--success-soft); }
.badge.off { color: var(--muted); background: var(--line-soft); }

.product-variations { font-size: 12px; color: var(--muted); }

.product-spacer { flex-grow: 1; }

.product-link {
  height: 38px;
  border: 1px solid var(--brand);
  border-radius: var(--radius-control);
  color: var(--brand-darker);
  font-size: 13.5px;
  font-weight: 500;
  display: grid;
  place-items: center;
  transition: background .15s ease, color .15s ease;
}

.product-link:hover { background: var(--brand-ink); color: #fff; }

/* ---- Composer ---- */

.composer-area {
  padding: 14px 26px 18px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.composer { display: flex; align-items: flex-end; gap: 10px; }

.composer textarea {
  flex-grow: 1;
  min-height: 50px;
  max-height: 140px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--panel-2);
  color: var(--text);
  padding: 14px 16px;
  font-size: 15px;
  line-height: 1.4;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.composer textarea:focus {
  outline: none;
  background: var(--panel);
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(230, 126, 34, .14);
}

.composer textarea:disabled { opacity: .6; }

.btn-send {
  flex: 0 0 auto;
  width: 50px;
  height: 50px;
  border: none;
  border-radius: var(--radius-panel);
  background: var(--brand-ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .15s ease;
}

.btn-send:hover:not(:disabled) { background: #a04000; }
.btn-send:disabled { background: #dcdcdc; cursor: default; }

.btn-send svg {
  width: 21px; height: 21px;
  fill: none; stroke: #fff; stroke-width: 1.9;
  stroke-linecap: round; stroke-linejoin: round;
}

.composer-nota { font-size: 12px; color: var(--faint); }

@media (max-width: 820px) {
  .products { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .msg { max-width: 88%; }
  .msg.user { max-width: 88%; }
}

@media (max-width: 560px) {
  .topbar { padding: 11px 16px; gap: 10px; }
  .page-mark { width: 78px; height: 34px; }
  .topbar-divider { display: none; }
  .eyebrow { display: none; }
  .status-pill { display: none; }
  .chat { padding: 18px 16px; }
  .composer-area { padding: 12px 16px 16px; }
  .products { grid-template-columns: 1fr; }
}
