@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;1,400&family=Inter:wght@300;400;500&display=swap');

:root {
  --accent: #FFA69E;
  --accent-d: #e8857c;
  --accent-m: #ffbdb8;
  --accent-s: #FFF0EE;
  --accent-rgb: 255, 166, 158;
  --bg: #FAF3DD;
  --menta: #B8F2E6;
  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-sans: 'Inter', sans-serif;
}

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

body {
  font-family: var(--font-sans);
  background: linear-gradient(135deg, var(--bg) 0%, var(--accent) 50%, var(--menta) 100%);
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ─── CONTAINER ─────────────────────────────────────────── */
.chat-container {
  width: 100%;
  max-width: 680px;
  height: 88vh;
  background: #fff;
  border-radius: 28px;
  box-shadow: 0 24px 64px rgba(232, 133, 124, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ─── HEADER ─────────────────────────────────────────────── */
.chat-header {
  background: linear-gradient(150deg, var(--accent-d) 0%, var(--accent) 55%, var(--accent-m) 100%);
  color: white;
  padding: 20px 20px 28px;
  text-align: center;
  position: relative;
  flex-shrink: 0;
}

.chat-back-link {
  position: absolute;
  left: 16px;
  top: 20px;
  display: flex;
  align-items: center;
  gap: 4px;
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 400;
  opacity: 0.75;
  transition: opacity 0.2s;
}
.chat-back-link:hover { opacity: 1; color: white; }
.chat-back-link svg { width: 16px; height: 16px; stroke: currentColor; }

.header-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.chat-header-logo {
  height: 72px;
  width: auto;
  filter: brightness(0) invert(1);
}

.subtitle {
  font-family: var(--font-serif);
  font-size: 15px;
  letter-spacing: 0.3px;
  opacity: 0.95;
  font-weight: 500;
}

.online-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 10px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 400;
  color: rgba(255,255,255,0.82);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.online-dot {
  width: 7px;
  height: 7px;
  background: #4ade80;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.3);
  animation: pulse-dot 2.4s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.3); }
  50%       { box-shadow: 0 0 0 5px rgba(74, 222, 128, 0.12); }
}

/* ─── MESSAGES AREA ──────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  background: #fffaf7;
}

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

/* Bot message */
.msg-row {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  animation: slideIn 0.28s ease-out;
}

.maia-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-m));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
  flex-shrink: 0;
  margin-top: 2px;
}

.bot-message {
  background: #ffffff;
  border: 0.5px solid #ffd9d4;
  border-radius: 16px 16px 16px 4px;
  padding: 12px 16px;
  max-width: calc(100% - 42px);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.65;
  color: #5a3a36;
  word-break: break-word;
  overflow-wrap: break-word;
  box-shadow: 0 1px 4px rgba(232, 133, 124, 0.07);
}

/* Bot message column (buttons + content together) */
.bot-col {
  flex: 1;
  min-width: 0;
  max-width: calc(100% - 42px);
}

/* User message */
.message {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  animation: slideIn 0.28s ease-out;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-s);
  color: var(--accent-d);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  margin-top: 2px;
}

.message-content {
  padding: 12px 16px;
  border-radius: 16px 16px 4px 16px;
  max-width: calc(100% - 42px);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
  overflow-wrap: break-word;
}

.user-message {
  flex-direction: row-reverse;
}

.user-message .message-content {
  background: linear-gradient(135deg, var(--accent-m) 0%, var(--accent-d) 100%);
  color: white;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 16px !important; /* override bot-message default */
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  background: var(--accent-m);
  border-radius: 50%;
  display: inline-block;
  animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0);   opacity: 0.45; }
  30%            { transform: translateY(-6px); opacity: 1;    }
}

/* ─── FLOW BUTTONS ───────────────────────────────────────── */
.flow-buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.flow-buttons.btn-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.flow-btn {
  background: #ffffff;
  border: 1px solid var(--accent-m);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  font-family: var(--font-sans);
  font-weight: 400;
  color: var(--accent-d);
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.35;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.flow-btn:hover {
  background: var(--accent-s);
  border-color: var(--accent);
}

.flow-btn:active {
  transform: scale(0.98);
}

.flow-btn:disabled {
  opacity: 0.42;
  cursor: default;
  pointer-events: none;
}

/* ─── PROCEDIMENTOS LIST ─────────────────────────────────── */
.proc-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  width: 100%;
}

.proc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #fff;
  border: 0.5px solid #ffd9d4;
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.proc-item:hover, .proc-item:active {
  border-color: var(--accent);
  background: var(--accent-s);
}

.proc-num  { font-size: 12px; font-weight: 700; color: var(--accent-d); min-width: 18px; }
.proc-nome { flex: 1; font-size: 14px; font-weight: 500; color: #4a2f2b; font-family: var(--font-sans); }
.proc-valor { font-size: 13px; color: #b08b85; white-space: nowrap; }
.proc-item.proc-item-disabled { pointer-events: none; opacity: 0.48; cursor: default; }

/* ─── INPUT AREA ─────────────────────────────────────────── */
.chat-input-container {
  padding: 12px 16px;
  background: #ffffff;
  border-top: 0.5px solid #ffe6e2;
  flex-shrink: 0;
}

.chat-input-wrapper {
  display: flex;
  gap: 10px;
  align-items: center;
}

.chat-input {
  flex: 1;
  padding: 11px 16px;
  border: 0.5px solid #ffd9d4;
  border-radius: 20px;
  background: #fffaf7;
  font-size: 14px;
  font-family: var(--font-sans);
  color: #5a3a36;
  outline: none;
  transition: border-color 0.25s;
}
.chat-input:focus { border-color: var(--accent); }
.chat-input::placeholder { color: #d9b3ae; }

.chat-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-m) 0%, var(--accent-d) 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}
.chat-send-btn svg { width: 16px; height: 16px; color: #fff; }
.chat-send-btn span { display: none; }
.chat-send-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 4px 14px rgba(var(--accent-rgb), 0.4);
}
.chat-send-btn:active { transform: scale(0.94); }
.chat-send-btn:disabled { opacity: 0.35; cursor: default; pointer-events: none; }

.chat-input-hidden { display: none !important; }

/* ─── SCROLLBAR ──────────────────────────────────────────── */
.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-track { background: var(--accent-s); }
.chat-messages::-webkit-scrollbar-thumb {
  background: var(--accent-m);
  border-radius: 4px;
}
.chat-messages::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ─── MOBILE ≤ 768px ─────────────────────────────────────── */
@media (max-width: 768px) {
  .chat-container {
    height: 100dvh;
    height: 100vh; /* fallback para browsers sem dvh */
    border-radius: 0;
    max-width: 100%;
  }
  .chat-header { padding: 14px 16px 22px; }
  .chat-header-logo { height: 56px; }
  .subtitle { font-size: 13px; }
  .chat-messages { padding: 16px 12px; }
  .bot-message, .bot-col { max-width: calc(100% - 42px); }
  .message-content { max-width: 82%; }
  .chat-input-container { padding: 10px 12px; }
  .chat-input { font-size: 16px; } /* evita zoom automático iOS */
}

/* ─── MOBILE ≤ 480px ─────────────────────────────────────── */
@media (max-width: 480px) {
  .chat-back-link { font-size: 11px; top: 14px; }
  .chat-header-logo { height: 50px; }
  .subtitle { font-size: 12px; }
  .online-badge { font-size: 10px; }
  .chat-input-wrapper { gap: 8px; }
  /* Grid 2 col vira coluna única em telas muito pequenas */
  .flow-buttons.btn-grid-2 { grid-template-columns: 1fr; }
}
