/* ═══════════════════════════════════════════════════════════════════
   Atendimento AI - app interno do painel RR.
   Entrada: escolha entre aprendizado e conversas de produção.
   ═══════════════════════════════════════════════════════════════════ */

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background-color: #0a0a0b;
  color: #ededeb;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body { min-height: 100vh; display: flex; flex-direction: column; }
body[data-aai-view="conversations"] {
  height: 100dvh;
  overflow: hidden;
}

/* ─── Entrada ──────────────────────────────────────────────────── */
.aai-home {
  flex: 1;
  min-height: calc(100vh - 76px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background:
    linear-gradient(180deg, rgba(201, 162, 79, 0.05), transparent 34%),
    #0a0a0b;
}
.aai-home-inner {
  width: min(920px, 100%);
}
.aai-home-head {
  margin-bottom: 22px;
}
.aai-home-head h1 {
  margin: 8px 0 0;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
  letter-spacing: 0;
}
.aai-home-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.aai-home-card {
  min-height: 190px;
  padding: 22px;
  text-align: left;
  background: rgba(255, 255, 255, 0.028);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: inherit;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}
.aai-home-card:hover {
  transform: translateY(-2px);
  border-color: rgba(201, 162, 79, 0.35);
  background: rgba(201, 162, 79, 0.055);
}
.aai-home-card-kicker {
  font-size: 11px;
  font-weight: 800;
  color: #c9a24f;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.aai-home-card strong {
  font-size: 22px;
  line-height: 1.15;
}
.aai-home-card span:last-child {
  max-width: 360px;
  font-size: 13px;
  line-height: 1.45;
  color: rgba(237, 237, 235, 0.58);
}

/* ─── Cérebro da IA ────────────────────────────────────────────── */
.aai-brain-view {
  flex: 1;
  min-height: calc(100vh - 76px);
  background: #0a0a0b;
  display: flex;
  flex-direction: column;
}
.aai-brain-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 28px 32px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}
.aai-brain-head h2 {
  margin: 6px 0 0;
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: 0;
}
.aai-brain-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 32px 36px;
}
.aai-brain-intro {
  max-width: 820px;
  margin-bottom: 18px;
}
.aai-brain-intro h3 {
  margin: 0 0 6px;
  font-size: 18px;
  letter-spacing: 0;
}
.aai-brain-intro p {
  margin: 0;
  color: rgba(237, 237, 235, 0.56);
  font-size: 13.5px;
  line-height: 1.55;
}
.aai-brain-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  max-width: 1180px;
}
.aai-brain-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 16px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
}
.aai-brain-field:nth-child(n + 3) {
  grid-column: span 2;
}
.aai-brain-field span {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #c9a24f;
  text-transform: uppercase;
}
.aai-brain-field textarea {
  width: 100%;
  min-height: 132px;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: #ededeb;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 21px;
  outline: none;
  resize: vertical;
}
.aai-brain-field textarea:focus {
  border-color: rgba(201, 162, 79, 0.55);
}
.aai-brain-actions {
  grid-column: span 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0 0;
}
.aai-brain-actions span {
  color: rgba(237, 237, 235, 0.48);
  font-size: 12.5px;
}

/* ─── Fluxo lógico ─────────────────────────────────────────────── */
.aai-flow-view {
  flex: 1;
  min-height: calc(100vh - 76px);
  background: #0a0a0b;
  display: flex;
  flex-direction: column;
}
.aai-flow-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 26px 32px 38px;
}
.aai-flow-map {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  max-width: 1180px;
}
.aai-flow-step {
  position: relative;
  min-height: 168px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 8px;
}
.aai-flow-step span {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(201, 162, 79, 0.12);
  color: #c9a24f;
  font-size: 12px;
  font-weight: 900;
  border: 1px solid rgba(201, 162, 79, 0.28);
}
.aai-flow-step strong {
  font-size: 16px;
  color: #ededeb;
}
.aai-flow-step p {
  margin: 0;
  color: rgba(237, 237, 235, 0.56);
  font-size: 12.5px;
  line-height: 1.48;
}

/* ─── Layout principal ──────────────────────────────────────────── */
.aai-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 240px 1fr 1fr;
  gap: 0;
  min-height: calc(100vh - 76px);
}

.aai-products,
.aai-context,
.aai-chat {
  background: #0d0d10;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: calc(100vh - 76px);
}
.aai-chat { border-right: none; }

.aai-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}
.aai-col-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.aai-eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #c9a24f;
}

.aai-btn-icon {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(237, 237, 235, 0.7);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.aai-btn-icon:hover {
  background: rgba(201, 162, 79, 0.10);
  border-color: rgba(201, 162, 79, 0.40);
  color: #c9a24f;
}

/* ─── Coluna 1: Produtos ────────────────────────────────────────── */
.aai-product-list {
  list-style: none;
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  flex: 1;
}
.aai-product-empty {
  padding: 24px 12px;
  color: rgba(237, 237, 235, 0.40);
  font-size: 13px;
  text-align: center;
}
.aai-product-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: rgba(237, 237, 235, 0.75);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
  transition: background 0.15s, color 0.15s;
}
.aai-product-item:hover {
  background: rgba(255, 255, 255, 0.03);
  color: #ededeb;
}
.aai-product-item[aria-current="true"] {
  background: rgba(201, 162, 79, 0.10);
  color: #c9a24f;
  box-shadow: inset 0 0 0 1px rgba(201, 162, 79, 0.30);
}
.aai-product-item .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.20);
  flex-shrink: 0;
}
.aai-product-item .name {
  min-width: 0;
  flex: 1;
}
.aai-product-kind {
  flex-shrink: 0;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(143, 183, 232, 0.12);
  color: #8fb7e8;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
}
.aai-product-item[aria-current="true"] .dot {
  background: #c9a24f;
  box-shadow: 0 0 8px rgba(201, 162, 79, 0.6);
}

/* ─── Coluna 2: Contexto ───────────────────────────────────────── */
.aai-context-product {
  font-size: 13px;
  font-weight: 600;
  color: rgba(237, 237, 235, 0.55);
}
.aai-tabs {
  display: flex;
  gap: 2px;
  padding: 10px 16px 0;
  overflow-x: auto;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.aai-tab {
  background: transparent;
  border: none;
  color: rgba(237, 237, 235, 0.45);
  padding: 10px 14px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.aai-tab:hover {
  color: rgba(237, 237, 235, 0.85);
}
.aai-tab[aria-selected="true"] {
  color: #c9a24f;
  border-bottom-color: #c9a24f;
}

.aai-tab-panel {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}
.aai-context-loading {
  color: rgba(237, 237, 235, 0.45);
  text-align: center;
  padding: 40px 0;
  font-size: 14px;
}

/* Card de pergunta */
.aai-q-card {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
}
.aai-q-card.is-new {
  border-color: rgba(201, 162, 79, 0.35);
  background: rgba(201, 162, 79, 0.04);
}
.aai-q-text {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  font-size: 13.5px;
  font-weight: 600;
  color: #ededeb;
  margin: 0 0 10px 0;
  line-height: 1.4;
}
.aai-q-delete {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: rgba(217, 124, 124, 0.55);
  font-size: 13px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.aai-q-delete:hover { color: #d97c7c; background: rgba(217, 124, 124, 0.08); }
.aai-q-answer {
  width: 100%;
  min-height: 100px;
  padding: 11px 14px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: #ededeb;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 21px;
  outline: none;
  resize: vertical;
  transition: border-color 0.15s;
}
.aai-q-answer:focus {
  border-color: rgba(201, 162, 79, 0.55);
}
.aai-flow-title {
  width: 100%;
  margin-bottom: 10px;
  padding: 9px 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: #ededeb;
  font-family: inherit;
  font-size: 13px;
  outline: none;
}
.aai-flow-title:focus {
  border-color: rgba(201, 162, 79, 0.55);
}
.aai-q-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  font-size: 11px;
  color: rgba(237, 237, 235, 0.40);
}
.aai-q-save {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: linear-gradient(135deg, #c9a24f 0%, #b58a3f 100%);
  border: none;
  border-radius: 6px;
  color: #0a0a0b;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
}
.aai-q-save:disabled { opacity: 0.5; cursor: not-allowed; }
.aai-q-save:hover:not(:disabled) { transform: translateY(-1px); }
.aai-q-save[data-saved="true"] {
  background: rgba(111, 199, 132, 0.18);
  color: #6fc784;
  box-shadow: inset 0 0 0 1px rgba(111, 199, 132, 0.45);
}

.aai-add-question {
  width: 100%;
  padding: 14px;
  background: transparent;
  border: 1.5px dashed rgba(255, 255, 255, 0.10);
  border-radius: 10px;
  color: rgba(237, 237, 235, 0.55);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.aai-add-question:hover {
  border-color: rgba(201, 162, 79, 0.50);
  color: #c9a24f;
  background: rgba(201, 162, 79, 0.03);
}

/* Ofertas */
.aai-offer-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.aai-offer-value {
  font-size: 18px;
  font-weight: 800;
  color: #c9a24f;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.aai-offer-desc {
  font-size: 13px;
  color: rgba(237, 237, 235, 0.80);
  line-height: 19px;
}
.aai-offer-link {
  font-size: 11px;
  color: rgba(237, 237, 235, 0.45);
  word-break: break-all;
  display: block;
  margin-top: 4px;
}
.aai-offer-link a { color: rgba(237, 237, 235, 0.65); text-decoration: underline; }
.aai-offer-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.aai-offer-actions button {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: rgba(237, 237, 235, 0.60);
  font-family: inherit;
  font-size: 11px;
  padding: 5px 10px;
  cursor: pointer;
  transition: all 0.15s;
}
.aai-offer-actions button:hover {
  color: #ededeb;
  border-color: rgba(255, 255, 255, 0.20);
}
.aai-offer-actions button.danger:hover {
  color: #d97c7c;
  border-color: rgba(217, 124, 124, 0.40);
}

/* Form pra nova oferta */
.aai-offer-form {
  background: rgba(201, 162, 79, 0.04);
  border: 1px solid rgba(201, 162, 79, 0.30);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.aai-offer-form input {
  padding: 9px 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: #ededeb;
  font-family: inherit;
  font-size: 13px;
  outline: none;
}
.aai-offer-form input:focus { border-color: rgba(201, 162, 79, 0.55); }
.aai-offer-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.aai-offer-form-actions button {
  padding: 7px 14px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(237, 237, 235, 0.85);
}
.aai-offer-form-actions button.primary {
  background: linear-gradient(135deg, #c9a24f 0%, #b58a3f 100%);
  border-color: transparent;
  color: #0a0a0b;
}

/* ─── Mídias ───────────────────────────────────────────────────── */
.aai-media-hint {
  font-size: 12px;
  color: rgba(237, 237, 235, 0.45);
  line-height: 18px;
  margin: 0 0 14px 0;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.aai-media-card {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 14px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
}
.aai-media-thumb {
  width: 88px;
  height: 88px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.30);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.aai-media-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.aai-media-thumb-icon {
  color: rgba(201, 162, 79, 0.65);
}
.aai-media-thumb-pdf   .aai-media-thumb-icon { color: rgba(217, 124, 124, 0.75); }
.aai-media-thumb-video .aai-media-thumb-icon { color: rgba(124, 175, 217, 0.75); }

.aai-media-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.aai-media-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.aai-media-name {
  font-size: 13.5px;
  font-weight: 600;
  color: #ededeb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.aai-media-type-badge {
  flex-shrink: 0;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.10em;
  padding: 3px 7px;
  border-radius: 4px;
  text-transform: uppercase;
}
.aai-media-type-image { background: rgba(201, 162, 79, 0.12); color: #c9a24f; box-shadow: inset 0 0 0 1px rgba(201, 162, 79, 0.30); }
.aai-media-type-pdf   { background: rgba(217, 124, 124, 0.12); color: #d97c7c; box-shadow: inset 0 0 0 1px rgba(217, 124, 124, 0.30); }
.aai-media-type-video { background: rgba(124, 175, 217, 0.12); color: #7cafd9; box-shadow: inset 0 0 0 1px rgba(124, 175, 217, 0.30); }

.aai-media-meta {
  font-size: 11px;
  color: rgba(237, 237, 235, 0.40);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}
.aai-media-desc {
  width: 100%;
  min-height: 60px;
  padding: 9px 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: #ededeb;
  font-family: inherit;
  font-size: 12.5px;
  line-height: 19px;
  outline: none;
  resize: vertical;
}
.aai-media-desc:focus { border-color: rgba(201, 162, 79, 0.55); }
.aai-media-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.aai-media-delete {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: rgba(217, 124, 124, 0.65);
  font-family: inherit;
  font-size: 11px;
  padding: 6px 10px;
  cursor: pointer;
  transition: all 0.15s;
}
.aai-media-delete:hover {
  color: #d97c7c;
  border-color: rgba(217, 124, 124, 0.40);
  background: rgba(217, 124, 124, 0.05);
}
.aai-media-save {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: linear-gradient(135deg, #c9a24f 0%, #b58a3f 100%);
  border: none;
  border-radius: 6px;
  color: #0a0a0b;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
}
.aai-media-save:disabled { opacity: 0.5; cursor: not-allowed; }
.aai-media-save:hover:not(:disabled) { transform: translateY(-1px); }
.aai-media-save[data-saved="true"] {
  background: rgba(111, 199, 132, 0.18);
  color: #6fc784;
  box-shadow: inset 0 0 0 1px rgba(111, 199, 132, 0.45);
}

/* Form de upload (reusa .aai-offer-form como base) */
.aai-media-form select,
.aai-media-form input[type="file"],
.aai-media-form textarea {
  padding: 9px 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: #ededeb;
  font-family: inherit;
  font-size: 13px;
  outline: none;
  width: 100%;
}
.aai-media-form select { color-scheme: dark; }
.aai-media-form select:focus,
.aai-media-form textarea:focus { border-color: rgba(201, 162, 79, 0.55); }
.aai-media-form input[type="file"] {
  cursor: pointer;
  padding: 7px 12px;
}
.aai-media-form input[type="file"]::file-selector-button {
  background: rgba(201, 162, 79, 0.12);
  color: #c9a24f;
  border: 1px solid rgba(201, 162, 79, 0.30);
  border-radius: 4px;
  padding: 4px 10px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  margin-right: 10px;
}
.aai-media-form textarea { resize: vertical; min-height: 60px; }
.aai-media-form .aai-media-form-hint {
  display: block;
  margin: -4px 0 2px;
  color: rgba(237, 237, 235, 0.50);
  font-size: 12px;
  line-height: 1.45;
}
.aai-media-form .aai-media-file-list {
  margin: 0;
  padding: 10px 12px;
  list-style: none;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.018);
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 180px;
  overflow-y: auto;
}
.aai-media-form .aai-media-file-list li {
  font-size: 12px;
  color: rgba(237, 237, 235, 0.75);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.aai-media-form .aai-media-file-list li::before {
  content: "↳ ";
  color: var(--gold, #c9a24f);
  margin-right: 4px;
}

/* ─── WhatsApp ─────────────────────────────────────────────────── */
.aai-conversations-view {
  flex: 1;
  height: calc(100dvh - 76px);
  max-height: calc(100dvh - 76px);
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #0d0d10;
  overflow: hidden;
}
.aai-conversations-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}
.aai-conversations-head h2 {
  margin: 5px 0 0;
  font-size: 20px;
  letter-spacing: 0;
}
.aai-conversations-body {
  flex: 1;
  min-height: 0;
  padding: 14px;
  overflow: hidden;
}
.aai-whatsapp-panel {
  display: grid;
  grid-template-columns: minmax(220px, 0.42fr) minmax(0, 1fr);
  gap: 14px;
  height: 100%;
  min-height: 0;
}
.aai-whatsapp-list,
.aai-whatsapp-detail {
  min-width: 0;
  min-height: 0;
  background: rgba(255, 255, 255, 0.018);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  overflow: hidden;
}
.aai-whatsapp-list {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.aai-whatsapp-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.aai-whatsapp-list-head strong {
  font-size: 13px;
  color: rgba(237, 237, 235, 0.86);
}
.aai-whatsapp-items {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
}
.aai-whatsapp-item {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 11px 10px;
  margin-bottom: 6px;
  text-align: left;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  border-radius: 7px;
  color: inherit;
  font-family: inherit;
  cursor: pointer;
}
.aai-whatsapp-item:hover {
  border-color: rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.035);
}
.aai-whatsapp-item.is-active {
  border-color: rgba(201, 162, 79, 0.35);
  background: rgba(201, 162, 79, 0.07);
}
.aai-whatsapp-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.aai-whatsapp-item-tags,
.aai-whatsapp-toolbar-tags {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
}
.aai-whatsapp-toolbar-tags {
  flex-shrink: 0;
}
.aai-whatsapp-item-top strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}
.aai-whatsapp-item-meta,
.aai-whatsapp-preview {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  color: rgba(237, 237, 235, 0.45);
}
.aai-whatsapp-preview {
  font-size: 12px;
  color: rgba(237, 237, 235, 0.66);
}
.aai-whatsapp-detail {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.aai-wpp-back-list {
  display: none;
}
.aai-whatsapp-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.aai-whatsapp-detail-head h3 {
  margin: 0 0 4px;
  font-size: 15px;
}
.aai-whatsapp-detail-head p {
  margin: 0;
  font-size: 12px;
  color: rgba(237, 237, 235, 0.48);
}
.aai-whatsapp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}
.aai-btn-ghost.is-selected {
  color: #c9a24f;
  border-color: rgba(201, 162, 79, 0.45);
  background: rgba(201, 162, 79, 0.08);
}
.aai-btn-ghost.danger {
  color: #d97c7c;
  border-color: rgba(217, 124, 124, 0.24);
}
.aai-btn-ghost.danger:hover {
  color: #ffaaaa;
  border-color: rgba(217, 124, 124, 0.50);
  background: rgba(217, 124, 124, 0.08);
}
.aai-whatsapp-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.aai-ai-state {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 0.7fr 0.55fr 0.7fr 0.85fr minmax(0, 1.35fr) minmax(0, 1.15fr);
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(201, 162, 79, 0.025);
}
.aai-ai-state div {
  min-width: 0;
  display: grid;
  gap: 3px;
}
.aai-ai-state span {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(201, 162, 79, 0.78);
}
.aai-ai-state strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: rgba(237, 237, 235, 0.82);
}
.aai-whatsapp-toolbar-fields {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.aai-whatsapp-toolbar label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 12px;
  color: rgba(237, 237, 235, 0.55);
}
.aai-whatsapp-toolbar select {
  max-width: 240px;
  padding: 7px 28px 7px 10px;
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: rgba(237, 237, 235, 0.85);
  font-family: inherit;
  font-size: 12px;
  color-scheme: dark;
}
.aai-whatsapp-workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 0.26fr);
}
.aai-whatsapp-thread {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}
.aai-whatsapp-messages {
  flex: 1;
  min-height: 0;
  max-height: calc(100dvh - 340px);
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.aai-whatsapp-reply-form {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 12px 16px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.aai-whatsapp-reply-form textarea {
  min-height: 42px;
  max-height: 120px;
  resize: vertical;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: #ededeb;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
  outline: none;
}
.aai-whatsapp-reply-form textarea:focus {
  border-color: rgba(201, 162, 79, 0.55);
}
.aai-whatsapp-reply-hint {
  grid-column: 1 / -1;
  margin: -2px 0 0;
  color: rgba(237, 237, 235, 0.42);
  font-size: 11px;
}
.aai-whatsapp-quick {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.12);
}
.aai-whatsapp-quick-head {
  flex-shrink: 0;
  display: grid;
  gap: 2px;
  padding: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.aai-whatsapp-quick-head strong {
  font-size: 13px;
  color: rgba(237, 237, 235, 0.88);
}
.aai-whatsapp-quick-head span {
  font-size: 11px;
  color: rgba(237, 237, 235, 0.44);
}
.aai-whatsapp-quick-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
  display: grid;
  align-content: start;
  gap: 7px;
}
.aai-whatsapp-quick-item {
  display: grid;
  gap: 5px;
  width: 100%;
  padding: 9px;
  text-align: left;
  background: rgba(255, 255, 255, 0.026);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 7px;
  color: inherit;
  font-family: inherit;
  cursor: pointer;
}
.aai-whatsapp-quick-item:hover {
  border-color: rgba(201, 162, 79, 0.36);
  background: rgba(201, 162, 79, 0.07);
}
.aai-whatsapp-quick-item strong {
  font-size: 12px;
  color: rgba(237, 237, 235, 0.88);
}
.aai-whatsapp-quick-item span {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 11px;
  line-height: 1.35;
  color: rgba(237, 237, 235, 0.56);
}
.aai-whatsapp-msg {
  max-width: min(78%, 520px);
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.035);
}
.aai-whatsapp-msg.is-outbound {
  align-self: flex-end;
  background: rgba(201, 162, 79, 0.11);
  border-color: rgba(201, 162, 79, 0.25);
}
.aai-whatsapp-msg.is-inbound {
  align-self: flex-start;
}
.aai-whatsapp-msg-meta {
  margin-bottom: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: rgba(237, 237, 235, 0.38);
}
.aai-whatsapp-msg-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.45;
  color: rgba(237, 237, 235, 0.88);
}
.aai-whatsapp-msg.is-media-only {
  padding: 8px 10px;
}
.aai-whatsapp-msg-media {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.aai-msg-media-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border-radius: 7px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(237, 237, 235, 0.82);
  text-decoration: none;
  max-width: 240px;
  overflow: hidden;
}
a.aai-msg-media-chip:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(201, 162, 79, 0.4);
  color: #f0d080;
}
.aai-msg-media-chip.is-image a.aai-msg-media-chip,
a.aai-msg-media-chip.is-image {
  flex-direction: column;
  align-items: flex-start;
  padding: 4px;
  max-width: 200px;
}
.aai-msg-media-thumb {
  width: 100%;
  max-width: 192px;
  max-height: 140px;
  object-fit: cover;
  border-radius: 5px;
  display: block;
}
.aai-msg-media-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 190px;
  font-size: 11px;
  color: rgba(237, 237, 235, 0.6);
}
.aai-msg-media-icon {
  font-size: 14px;
  flex-shrink: 0;
}
.aai-whatsapp-empty {
  margin: 20px;
  text-align: center;
  color: rgba(237, 237, 235, 0.42);
  font-size: 13px;
}
.aai-wpp-status {
  flex-shrink: 0;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.aai-wpp-status-ai {
  color: #79d29f;
  background: rgba(121, 210, 159, 0.11);
}
.aai-wpp-status-humano {
  color: #d9b36e;
  background: rgba(217, 179, 110, 0.12);
}
.aai-wpp-status-pausado {
  color: #d97c7c;
  background: rgba(217, 124, 124, 0.12);
}
.aai-wpp-status-aluno {
  color: #8fb7e8;
  background: rgba(143, 183, 232, 0.13);
}
.aai-wpp-status-comprou {
  color: #f2d38c;
  background: rgba(217, 177, 94, 0.18);
}
.aai-wpp-followup-badge {
  flex-shrink: 0;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #89c8ff;
  background: rgba(137, 200, 255, 0.11);
  border: 1px solid rgba(137, 200, 255, 0.16);
}
.aai-wpp-followup-badge.is-sent {
  color: #d9b36e;
  background: rgba(217, 179, 110, 0.11);
  border-color: rgba(217, 179, 110, 0.16);
}
.aai-wpp-followup-badge.is-done {
  color: rgba(237, 237, 235, 0.56);
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.08);
}

.aai-whatsapp-status-alert {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  width: min(360px, calc(100vw - 32px));
  padding: 14px;
  display: grid;
  gap: 7px;
  background: rgba(31, 13, 14, 0.96);
  border: 1px solid rgba(217, 124, 124, 0.48);
  border-radius: 8px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.38);
  color: #ededeb;
}
.aai-whatsapp-status-alert strong {
  font-size: 13px;
  color: #ffaaaa;
}
.aai-whatsapp-status-alert span,
.aai-whatsapp-status-alert small {
  font-size: 12px;
  line-height: 1.4;
  color: rgba(237, 237, 235, 0.78);
}
.aai-whatsapp-status-alert small {
  color: rgba(237, 237, 235, 0.52);
  overflow-wrap: anywhere;
}
.aai-whatsapp-status-alert button {
  justify-self: start;
  margin-top: 3px;
  padding: 6px 10px;
  border: 1px solid rgba(217, 124, 124, 0.36);
  border-radius: 6px;
  background: rgba(217, 124, 124, 0.10);
  color: #ffbcbc;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

/* ─── Coluna 3: Chat ───────────────────────────────────────────── */
.aai-chat-head { padding: 12px 16px; }
.aai-chat-head-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.aai-chat-product { font-size: 13px; font-weight: 600; color: rgba(237, 237, 235, 0.55); overflow: hidden; text-overflow: ellipsis; }
.aai-chat-head-right { display: flex; align-items: center; gap: 8px; }
.aai-chat-model-select {
  padding: 6px 28px 6px 12px;
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: rgba(237, 237, 235, 0.85);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%23a3a3a8' stroke-width='1.4' fill='none' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  /* Forca o popup de opcoes em tema escuro (Chrome/Edge/Safari) */
  color-scheme: dark;
}
.aai-chat-model-select option {
  background-color: #15151a;
  color: #ededeb;
}
.aai-btn-ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: rgba(237, 237, 235, 0.55);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  padding: 6px 10px;
  cursor: pointer;
  transition: all 0.15s;
}
.aai-btn-ghost:hover {
  color: #ededeb;
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.02);
}

.aai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.aai-chat-empty {
  margin: auto;
  text-align: center;
  color: rgba(237, 237, 235, 0.35);
  font-size: 13px;
  max-width: 280px;
  padding: 24px;
}

.aai-msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 21px;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.aai-msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(201, 162, 79, 0.18), rgba(201, 162, 79, 0.10));
  border: 1px solid rgba(201, 162, 79, 0.30);
  color: #ededeb;
  border-bottom-right-radius: 4px;
}
.aai-msg-assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(237, 237, 235, 0.90);
  border-bottom-left-radius: 4px;
}
.aai-msg-typing {
  align-self: flex-start;
  color: rgba(201, 162, 79, 0.65);
  font-size: 13px;
  font-style: italic;
  padding: 10px 14px;
}

/* Bolhas de mídia enviadas pela IA */
.aai-msg-media {
  padding: 6px;
  max-width: 70%;
}
.aai-msg-media img,
.aai-msg-media video {
  display: block;
  width: 100%;
  max-width: 320px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.30);
}
.aai-msg-media-missing {
  font-style: italic;
  color: rgba(237, 237, 235, 0.40);
  font-size: 12px;
  padding: 10px 14px;
}
.aai-msg-media-pdf { padding: 0; }
.aai-msg-pdf-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  text-decoration: none;
  color: inherit;
  border-radius: 10px;
  transition: background 0.15s;
}
.aai-msg-pdf-link:hover { background: rgba(255, 255, 255, 0.04); }
.aai-msg-pdf-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: rgba(217, 124, 124, 0.12);
  color: #d97c7c;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.aai-msg-pdf-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.aai-msg-pdf-name {
  font-size: 13px;
  font-weight: 600;
  color: #ededeb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
.aai-msg-pdf-action {
  font-size: 11px;
  color: rgba(201, 162, 79, 0.85);
  font-weight: 600;
}
.aai-msg-typing .dot {
  display: inline-block;
  width: 4px;
  height: 4px;
  margin: 0 1px;
  border-radius: 50%;
  background: currentColor;
  animation: aai-bounce 1.4s infinite;
}
.aai-msg-typing .dot:nth-child(2) { animation-delay: 0.16s; }
.aai-msg-typing .dot:nth-child(3) { animation-delay: 0.32s; }
@keyframes aai-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-3px); opacity: 1; }
}

.aai-chat-form {
  flex-shrink: 0;
  padding: 12px 16px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.aai-chat-form textarea {
  flex: 1;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  color: #ededeb;
  font-family: inherit;
  font-size: 14px;
  line-height: 21px;
  outline: none;
  resize: none;
  max-height: 160px;
}
.aai-chat-form textarea:focus { border-color: rgba(201, 162, 79, 0.55); }

.aai-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  background: linear-gradient(135deg, #c9a24f 0%, #b58a3f 100%);
  border: none;
  border-radius: 10px;
  color: #0a0a0b;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s, opacity 0.15s;
}
.aai-btn-primary:hover:not(:disabled) { transform: translateY(-1px); }
.aai-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.aai-btn-spinner {
  display: none;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(10, 10, 11, 0.25);
  border-top-color: #0a0a0b;
  border-radius: 50%;
  animation: aai-spin 0.8s linear infinite;
}
.aai-btn-primary[data-loading="true"] .aai-btn-spinner { display: inline-block; }
.aai-btn-primary[data-loading="true"] .aai-btn-label   { opacity: 0.6; }
@keyframes aai-spin { to { transform: rotate(360deg); } }

/* ─── Bottom nav (mobile) ──────────────────────────────────────── */
/* Sempre presente no DOM, escondido no desktop. */
.aai-mobile-nav {
  display: none;
}

/* ─── Responsivo ───────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .aai-layout { grid-template-columns: 200px 1fr 1fr; }
}

@media (max-width: 860px) and (min-width: 721px) {
  .aai-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }
  .aai-products, .aai-context, .aai-chat {
    max-height: none;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }
  .aai-products { max-height: 200px; }
  .aai-chat { min-height: 60vh; }
}

/* ─── Mobile real (<=720px): bottom nav + single pane ──────────── */
@media (max-width: 720px) {
  /* Layout: uma coluna, o painel ativo ocupa todo o espaço entre
     topbar e bottom nav. Reservamos 64px de padding embaixo do body
     pra abrir espaço pra nav fixa. */
  body { padding-bottom: 64px; }

  .aai-layout {
    display: block;
    min-height: calc(100vh - 76px - 64px);
  }

  .aai-products,
  .aai-context,
  .aai-chat {
    display: none;
    max-height: none;
    border-right: none;
    border-bottom: none;
    min-height: calc(100vh - 76px - 64px);
  }

  body[data-mobile-pane="products"] .aai-products { display: flex; }
  body[data-mobile-pane="context"]  .aai-context  { display: flex; }
  body[data-mobile-pane="chat"]     .aai-chat     { display: flex; }

  /* Mostra o bottom nav */
  .aai-mobile-nav {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(13, 13, 16, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 50;
  }
  .aai-mnav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 8px;
    background: transparent;
    border: none;
    color: rgba(237, 237, 235, 0.50);
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: color 0.15s;
    height: 64px;
  }
  body[data-aai-view="home"],
  body[data-aai-view="flow"],
  body[data-aai-view="brain"],
  body[data-aai-view="conversations"] {
    padding-bottom: 0;
  }
  body[data-aai-view="home"] .aai-mobile-nav,
  body[data-aai-view="flow"] .aai-mobile-nav,
  body[data-aai-view="brain"] .aai-mobile-nav,
  body[data-aai-view="conversations"] .aai-mobile-nav {
    display: none;
  }
  .aai-home {
    min-height: calc(100vh - 76px);
    padding: 18px;
    align-items: flex-start;
  }
  .aai-home-actions {
    grid-template-columns: 1fr;
  }
  .aai-home-card {
    min-height: 160px;
  }
  .aai-brain-view {
    min-height: calc(100vh - 76px);
  }
  .aai-flow-view {
    min-height: calc(100vh - 76px);
  }
  .aai-flow-body {
    padding: 16px 14px 24px;
  }
  .aai-flow-map {
    grid-template-columns: 1fr;
  }
  .aai-flow-step {
    min-height: 132px;
  }
  .aai-brain-head {
    padding: 14px;
    align-items: flex-start;
  }
  .aai-brain-head h2 {
    font-size: 18px;
  }
  .aai-brain-body {
    padding: 16px 14px 24px;
  }
  .aai-brain-form {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .aai-brain-field,
  .aai-brain-field:nth-child(n + 3),
  .aai-brain-actions {
    grid-column: span 1;
  }
  .aai-brain-field {
    padding: 13px;
  }
  .aai-brain-field textarea {
    font-size: 16px;
    line-height: 23px;
    min-height: 150px;
  }
  .aai-brain-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .aai-conversations-view {
    height: calc(100dvh - 76px);
    max-height: calc(100dvh - 76px);
    min-height: 0;
    overflow: hidden;
  }
  .aai-conversations-head {
    align-items: flex-start;
    flex-direction: row;
    gap: 10px;
    padding: 12px 14px;
    flex-shrink: 0;
  }
  .aai-conversations-head > div:first-child { min-width: 0; flex: 1; }
  .aai-conversations-head .aai-eyebrow { font-size: 10px; letter-spacing: 0.16em; }
  .aai-conversations-head h2 {
    font-size: 16px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: clip;
  }
  /* Acoes do header em mobile: botoes mais compactos. Texto do
     "Relatorio por AI" some abaixo de 480px e fica so o icone. */
  .aai-conv-actions {
    flex-shrink: 0;
    gap: 6px;
  }
  .aai-btn-ai-report {
    padding: 7px 10px;
    font-size: 11.5px;
  }
  .aai-conversations-body {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding: 10px;
  }
  .aai-ai-state {
    grid-template-columns: 1fr 1fr;
    padding: 10px 12px;
  }
  .aai-ai-state .is-wide {
    grid-column: 1 / -1;
  }
  .aai-mnav-btn:hover { color: rgba(237, 237, 235, 0.85); }
  .aai-mnav-btn.aai-mnav-active {
    color: #c9a24f;
  }
  .aai-mnav-btn.aai-mnav-active svg {
    filter: drop-shadow(0 0 6px rgba(201, 162, 79, 0.4));
  }

  /* Ajustes nas colunas em mobile */
  .aai-products {
    flex-direction: column;
  }
  .aai-product-list { padding: 12px; }

  .aai-col-head {
    padding: 14px 18px 12px;
  }
  .aai-tab-panel {
    padding: 16px;
  }

  /* Chat: textarea 16px pra nao ter zoom no iOS Safari */
  .aai-chat-form textarea,
  .aai-q-answer,
  .aai-media-desc,
  .aai-offer-form input,
  .aai-media-form select,
  .aai-media-form input[type="text"],
  .aai-media-form textarea {
    font-size: 16px;
  }

  /* Bolha de midia maxima largura mais permissiva em mobile */
  .aai-msg-media {
    max-width: 86%;
  }

  /* Card de midia: empilhar thumbnail em cima ajuda mais que side-by-side */
  .aai-media-card {
    grid-template-columns: 64px 1fr;
    gap: 12px;
    padding: 12px;
  }
  .aai-media-thumb {
    width: 64px;
    height: 64px;
  }

  .aai-whatsapp-panel {
    display: flex;
    flex-direction: column;
    gap: 0;
    height: 100%;
    min-height: 0;
  }
  .aai-whatsapp-panel.has-selected .aai-whatsapp-list { display: none; }
  .aai-whatsapp-panel:not(.has-selected) .aai-whatsapp-detail { display: none; }
  .aai-whatsapp-list {
    flex: 1;
    max-height: none;
    min-height: 0;
  }
  .aai-whatsapp-detail {
    flex: 1;
    min-height: 0;
  }
  /* === Detail head: bem compacto. Voltar pra lista + titulo + acoes
     em UMA linha (acoes ficam horizontais com scroll se nao couber) === */
  .aai-whatsapp-detail-head {
    align-items: center;
    flex-direction: row;
    gap: 8px;
    padding: 10px 12px;
  }
  .aai-whatsapp-detail-head > div:first-child {
    min-width: 0;
    flex: 1;
  }
  .aai-whatsapp-detail-head h3 {
    font-size: 14px;
    overflow: hidden;
    text-overflow: clip;
    white-space: nowrap;
  }
  .aai-whatsapp-detail-head p {
    font-size: 11px;
    overflow: hidden;
    text-overflow: clip;
    white-space: nowrap;
  }
  .aai-wpp-back-list {
    display: inline-flex;
    width: 32px;
    height: 32px;
    padding: 0;
    justify-content: center;
    flex-shrink: 0;
  }
  .aai-wpp-back-list span { display: none; }
  .aai-whatsapp-actions {
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap;
    margin: 0 -4px;
    padding: 0 4px;
    flex-shrink: 0;
  }
  .aai-whatsapp-actions .aai-btn-ghost {
    flex: 0 0 auto;
    padding: 6px 10px;
    font-size: 11.5px;
    white-space: nowrap;
  }

  /* === Toolbar: campos em 1 linha horizontal com scroll-x === */
  .aai-whatsapp-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 6px;
    padding: 8px 12px;
  }
  .aai-whatsapp-toolbar-tags {
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 1px;
  }
  .aai-whatsapp-toolbar-fields {
    align-items: center;
    flex-direction: row;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap;
    margin: 0 -4px;
    padding: 0 4px;
  }
  .aai-whatsapp-toolbar label {
    flex: 0 0 auto;
    white-space: nowrap;
    font-size: 11px;
  }
  .aai-whatsapp-toolbar select {
    max-width: 180px;
    min-width: 120px;
    width: auto;
    padding: 5px 22px 5px 8px;
    font-size: 12px;
  }

  /* === Workspace: thread vertical + quick replies como faixa inline
     ENXUTA acima do reply form (nao um painel separado) === */
  .aai-whatsapp-workspace {
    grid-template-columns: 1fr;
    overflow: hidden;
  }
  .aai-whatsapp-thread {
    min-height: 0;
    border-right: 0;
  }
  .aai-whatsapp-messages {
    max-height: none;
    padding: 10px 12px;
    gap: 6px;
  }
  .aai-whatsapp-msg {
    max-width: 88%;
    padding: 7px 10px;
    font-size: 13px;
  }

  /* Quick replies vira CHIPS horizontais compactas, agarradas no topo
     do reply form. Nao tem mais cabecalho proprio -- assume contexto. */
  .aai-whatsapp-quick {
    max-height: none;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.18);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
  }
  .aai-whatsapp-quick-head {
    display: none;
  }
  .aai-whatsapp-quick-list {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 10px;
    gap: 6px;
  }
  .aai-whatsapp-quick-item {
    width: auto;
    flex: 0 0 auto;
    padding: 6px 11px;
    border-radius: 999px;
    border: 1px solid rgba(201, 162, 79, 0.30);
    background: rgba(201, 162, 79, 0.08);
  }
  .aai-whatsapp-quick-item:hover {
    background: rgba(201, 162, 79, 0.16);
  }
  .aai-whatsapp-quick-item strong {
    font-size: 12px;
    color: #c9a24f;
    white-space: nowrap;
  }
  /* O subtitulo (preview da resposta) some no mobile -- o titulo da
     pill ja basta pra identificar e nao polui o eixo horizontal. */
  .aai-whatsapp-quick-item span { display: none; }

  .aai-whatsapp-reply-form {
    grid-template-columns: 1fr auto;
    padding: 10px 12px 12px;
    gap: 8px;
    align-items: end;
  }
  .aai-whatsapp-reply-form textarea {
    font-size: 16px;
    min-height: 38px;
    max-height: 100px;
  }
  .aai-whatsapp-reply-hint {
    grid-column: 1 / -1;
    font-size: 10.5px;
  }

  .aai-whatsapp-status-alert {
    right: 10px;
    bottom: 10px;
    left: 10px;
    width: auto;
  }
}

/* Scrollbars sutis */
.aai-product-list::-webkit-scrollbar,
.aai-tab-panel::-webkit-scrollbar,
.aai-chat-messages::-webkit-scrollbar { width: 8px; }
.aai-product-list::-webkit-scrollbar-thumb,
.aai-tab-panel::-webkit-scrollbar-thumb,
.aai-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
}
.aai-product-list::-webkit-scrollbar-thumb:hover,
.aai-tab-panel::-webkit-scrollbar-thumb:hover,
.aai-chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(201, 162, 79, 0.30);
}

/* ═══════════════════════════════════════════════════════════════════
   Atendimento em produção: botões no header
   ═══════════════════════════════════════════════════════════════════ */
.aai-conv-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.aai-btn-ai-report {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  background: rgba(201, 162, 79, 0.10);
  border: 1px solid rgba(201, 162, 79, 0.35);
  color: #c9a24f;
  border-radius: 8px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, color 0.18s;
}
.aai-btn-ai-report:hover {
  background: rgba(201, 162, 79, 0.18);
  border-color: rgba(201, 162, 79, 0.55);
  color: #dfb66a;
}

/* ═══════════════════════════════════════════════════════════════════
   Modal: Relatório por AI
   ═══════════════════════════════════════════════════════════════════ */
.aai-report-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.aai-report-modal[hidden] { display: none; }
.aai-report-modal.is-open { opacity: 1; }

.aai-report-overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 5, 7, 0.78);
  backdrop-filter: blur(6px);
}

.aai-report-frame {
  position: relative;
  width: 100%;
  max-width: 820px;
  max-height: calc(100vh - 48px);
  background: #0a0a0b;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(8px);
  transition: transform 0.18s ease;
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.7);
}
.aai-report-modal.is-open .aai-report-frame { transform: translateY(0); }

.aai-report-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}
.aai-report-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.018em;
  color: #ededeb;
  margin: 4px 0 0;
}
.aai-report-close {
  background: transparent;
  border: 0;
  color: rgba(237, 237, 235, 0.48);
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.aai-report-close:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ededeb;
}

.aai-report-controls {
  padding: 16px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex-shrink: 0;
}
.aai-report-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.aai-report-field > span {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(237, 237, 235, 0.55);
}
.aai-report-field select {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 8px;
  color: #ededeb;
  font-family: inherit;
  font-size: 13px;
  padding: 9px 12px;
  outline: 0;
}
.aai-report-field select:focus { border-color: rgba(201, 162, 79, 0.40); }

.aai-report-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 600px) {
  .aai-report-actions { grid-template-columns: 1fr; }
}
.aai-report-period {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 14px 16px;
  background: rgba(201, 162, 79, 0.06);
  border: 1px solid rgba(201, 162, 79, 0.30);
  border-radius: 10px;
  color: #c9a24f;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, transform 0.18s;
}
.aai-report-period:hover {
  background: rgba(201, 162, 79, 0.12);
  border-color: rgba(201, 162, 79, 0.55);
  transform: translateY(-1px);
}
.aai-report-period:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}
.aai-report-period strong {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.008em;
  color: #ededeb;
}
.aai-report-period small {
  font-size: 11.5px;
  color: rgba(237, 237, 235, 0.55);
  font-weight: 500;
}

.aai-report-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px 22px;
}
.aai-report-hint {
  font-size: 13px;
  line-height: 1.6;
  color: rgba(237, 237, 235, 0.65);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 9px;
  padding: 14px 16px;
  margin: 0;
}

.aai-report-loading {
  display: grid;
  place-items: center;
  text-align: center;
  padding: 40px 20px;
  color: rgba(237, 237, 235, 0.72);
  gap: 14px;
}
.aai-report-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(201, 162, 79, 0.18);
  border-top-color: #c9a24f;
  border-radius: 50%;
  animation: aai-report-spin 0.9s linear infinite;
}
@keyframes aai-report-spin { to { transform: rotate(360deg); } }

.aai-report-error {
  padding: 14px 16px;
  background: rgba(217, 124, 124, 0.10);
  border: 1px solid rgba(217, 124, 124, 0.30);
  border-radius: 9px;
  color: #d97c7c;
  font-size: 13px;
}

.aai-report-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 9px;
  font-size: 12px;
  color: rgba(237, 237, 235, 0.72);
  margin-bottom: 16px;
}
.aai-report-meta strong {
  color: #ededeb;
  font-weight: 700;
}
.aai-report-model-tag {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(201, 162, 79, 0.14);
  color: #c9a24f;
  padding: 3px 8px;
  border-radius: 5px;
}

.aai-report-content {
  font-size: 13.5px;
  line-height: 1.65;
  color: rgba(237, 237, 235, 0.85);
}
.aai-report-content h2 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.018em;
  color: #ededeb;
  margin: 22px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(201, 162, 79, 0.20);
}
.aai-report-content h3 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.012em;
  color: #c9a24f;
  margin: 18px 0 8px;
}
.aai-report-content h4 {
  font-size: 13.5px;
  font-weight: 700;
  color: #ededeb;
  margin: 14px 0 6px;
}
.aai-report-content p { margin: 0 0 10px; }
.aai-report-content ul {
  margin: 0 0 12px;
  padding-left: 22px;
}
.aai-report-content li { margin-bottom: 4px; }
.aai-report-content strong { color: #ededeb; font-weight: 700; }
.aai-report-content em { color: rgba(237, 237, 235, 0.95); }
.aai-report-content code {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12px;
  font-family: ui-monospace, 'JetBrains Mono', monospace;
}
.aai-report-content hr {
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin: 16px 0;
}

/* ─── Modal Relatório AI: split com histórico ──────────────────── */
.aai-report-split {
  flex: 1;
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 0;
  overflow: hidden;
}

.aai-report-history {
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.015);
  min-height: 0;
}
.aai-report-history-head {
  padding: 14px 14px 10px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.aai-report-history-meta {
  font-size: 11px;
  color: rgba(237, 237, 235, 0.48);
  font-variant-numeric: tabular-nums;
}
.aai-report-history-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 12px;
  margin: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.aai-report-history-empty {
  padding: 16px 10px;
  font-size: 12px;
  color: rgba(237, 237, 235, 0.45);
  text-align: center;
  line-height: 1.5;
}
.aai-report-history-item {
  position: relative;
  padding: 9px 10px 8px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.aai-report-history-item:hover {
  background: rgba(201, 162, 79, 0.08);
  border-color: rgba(201, 162, 79, 0.30);
}
.aai-report-history-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 3px;
}
.aai-report-history-period {
  font-size: 12px;
  font-weight: 700;
  color: #ededeb;
  letter-spacing: -0.005em;
}
.aai-report-history-time {
  font-size: 10.5px;
  color: rgba(237, 237, 235, 0.45);
  font-variant-numeric: tabular-nums;
}
.aai-report-history-bottom {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: rgba(237, 237, 235, 0.55);
}
.aai-report-history-model {
  text-transform: lowercase;
  background: rgba(201, 162, 79, 0.10);
  color: #c9a24f;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
}
.aai-report-history-del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 0;
  background: transparent;
  color: rgba(237, 237, 235, 0.40);
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.aai-report-history-item:hover .aai-report-history-del { opacity: 1; }
.aai-report-history-del:hover {
  background: rgba(217, 124, 124, 0.18);
  color: #d97c7c;
}

@media (max-width: 720px) {
  .aai-report-split {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .aai-report-history {
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    max-height: 180px;
  }
  .aai-report-history-list {
    flex-direction: row;
    overflow-x: auto;
    padding: 0 12px 12px;
  }
  .aai-report-history-item {
    flex: 0 0 200px;
  }
}

/* ─── Mobile estreito (≤ 480px): icon-only no header de produção ── */
@media (max-width: 480px) {
  .aai-conversations-head { padding: 10px 12px; }
  .aai-conversations-head h2 { font-size: 15px; }
  /* Botao "Relatorio por AI" vira so icone -- texto some pra liberar
     espaco pro titulo. Tooltip nativo mantem a label legivel. */
  .aai-btn-ai-report {
    padding: 8px;
    width: 34px;
    height: 34px;
    justify-content: center;
    gap: 0;
  }
  .aai-btn-ai-report > span,
  .aai-btn-ai-report:not(:has(svg)) { display: inline; }
  .aai-btn-ai-report {
    font-size: 0;        /* esconde nodes de texto sem <span> */
  }
  .aai-btn-ai-report svg { font-size: 14px; }
  /* Voltar tambem fica enxuto */
  .aai-conversations-head .aai-btn-ghost {
    padding: 7px 10px;
    font-size: 12px;
  }
}

/* ─── Modal Relatório AI em mobile: sidebar vira faixa enxuta ───── */
@media (max-width: 720px) {
  .aai-report-modal { padding: 12px; }
  .aai-report-frame {
    max-height: calc(100dvh - 24px);
    border-radius: 10px;
  }
  .aai-report-head { padding: 14px 16px 10px; }
  .aai-report-title { font-size: 15px; }
  .aai-report-controls { padding: 12px 16px; gap: 10px; }
  .aai-report-period { padding: 11px 13px; }
  .aai-report-period strong { font-size: 13px; }
  .aai-report-period small { font-size: 11px; }
  .aai-report-history { max-height: 132px; }
  .aai-report-history-head { padding: 10px 12px 8px; }
  .aai-report-body { padding: 14px 16px 16px; }
  .aai-report-content { font-size: 13px; line-height: 1.6; }
  .aai-report-content h2 { font-size: 16px; margin-top: 18px; }
  .aai-report-content h3 { font-size: 14px; }
}
