/* Bella V2 — Chat IA (Assistente Bella). Bottom sheet full-height. */

.chat-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 12, 9, 0.55);
  z-index: 8900;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}
.chat-overlay.active { opacity: 1; pointer-events: auto; }

.chat-panel {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%) translateY(100%);
  width: 100%;
  max-width: 540px;
  height: 88dvh;
  max-height: 88dvh;
  z-index: 8901;
  background: var(--paper);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -8px 40px rgba(15, 12, 9, 0.25);
  display: flex;
  flex-direction: column;
  pointer-events: none;
  transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
  color: var(--ink);
}
.chat-panel.active { transform: translateX(-50%) translateY(0); pointer-events: auto; }

.chat-handle {
  width: 44px;
  height: 4px;
  border-radius: 2px;
  background: rgba(42, 26, 14, 0.18);
  margin: 8px auto 4px;
  flex-shrink: 0;
}

.chat-header {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 6px 16px 12px;
  border-bottom: 1px solid rgba(42, 26, 14, 0.10);
  flex-shrink: 0;
}
.chat-header-titles { flex: 1; min-width: 0; }
.chat-title {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.2px;
}
.chat-disclaimer {
  font-size: 10.5px;
  color: rgba(42, 26, 14, 0.55);
  margin-top: 3px;
  line-height: 1.35;
}
.chat-header-btn {
  background: none;
  border: none;
  color: rgba(42, 26, 14, 0.6);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.chat-header-btn:active { opacity: 0.5; background: rgba(42, 26, 14, 0.06); }
.chat-header-close { font-size: 24px; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-msg {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: normal;
}
.chat-msg strong { font-weight: 700; }
.chat-bot {
  align-self: flex-start;
  background: var(--cream);
  border: 1px solid rgba(42, 26, 14, 0.08);
  color: var(--ink);
  border-bottom-left-radius: 4px;
}
.chat-user {
  align-self: flex-end;
  background: var(--primary);
  color: var(--primary-foreground);
  border-bottom-right-radius: 4px;
}
.chat-loading {
  align-self: flex-start;
  color: rgba(42, 26, 14, 0.55);
  font-style: italic;
  font-size: 13px;
  padding: 6px 4px;
}

.chat-suggestions {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 16px;
  flex-shrink: 0;
  scrollbar-width: none;
  border-top: 1px solid rgba(42, 26, 14, 0.06);
}
.chat-suggestions::-webkit-scrollbar { display: none; }
.chat-suggestion {
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1.5px solid rgba(42, 26, 14, 0.16);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.chat-suggestion:active { background: rgba(42, 26, 14, 0.06); }

.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 14px calc(12px + var(--safe-bottom));
  border-top: 1px solid rgba(42, 26, 14, 0.10);
  flex-shrink: 0;
}
#chat-input {
  flex: 1;
  border: 1.5px solid rgba(42, 26, 14, 0.16);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 16px;
  font-family: var(--font-ui);
  background: var(--white, #fff);
  color: var(--ink);
  outline: none;
}
#chat-input:focus { border-color: var(--ink); }
#chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#chat-send-btn:disabled { opacity: 0.5; cursor: wait; }

/* ─── Cards de ação (tool_use) ─── */
.chat-acao-card {
  align-self: stretch;
  background: var(--cream);
  border: 1.5px solid rgba(42, 26, 14, 0.14);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-acao-header {
  display: flex;
  align-items: center;
  gap: 8px;
}
.chat-acao-icon { font-size: 18px; }
.chat-acao-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
}
.chat-acao-params {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-top: 1px solid rgba(42, 26, 14, 0.08);
  border-bottom: 1px solid rgba(42, 26, 14, 0.08);
  padding: 8px 0;
}
.chat-acao-param {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}
.chat-acao-param > span { color: rgba(42, 26, 14, 0.6); }
.chat-acao-param > strong { color: var(--ink); text-align: right; }
.chat-acao-footer {
  display: flex;
  gap: 8px;
}
.chat-acao-btn {
  flex: 1;
  padding: 10px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  min-height: 40px;
}
.chat-acao-btn.cancel {
  background: transparent;
  color: var(--ink);
  border: 1.5px solid rgba(42, 26, 14, 0.18);
}
.chat-acao-btn.confirm {
  background: var(--ink);
  color: var(--cream);
  border: none;
}
.chat-acao-btn:disabled { opacity: 0.5; cursor: wait; }
