:root {
  color-scheme: light;
  --ink: #111b21;
  --muted: #667781;
  --line: #e9edef;
  --panel: #ffffff;
  --soft: #f0f2f5;
  --brand: #00a884;
  --brand-dark: #008f72;
  --brand-deep: #075e54;
  --whatsapp: #25d366;
  --chat-bg: #efeae2;
  --outgoing: #d9fdd3;
  --success: #25d366;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--soft); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.button {
  border: 0;
  border-radius: 8px;
  padding: 11px 16px;
  color: #fff;
  background: var(--brand);
  font-weight: 700;
  transition: transform .15s ease, background .15s ease;
}
.button:hover { background: var(--brand-dark); transform: translateY(-1px); }
.button.secondary { color: #54656f; background: #e9edef; }
.button.danger { background: #d6485f; }

.field { display: grid; gap: 7px; margin-bottom: 14px; }
.field label { color: var(--muted); font-size: 13px; font-weight: 700; }
.field input, .composer textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  color: var(--ink);
  background: #fff;
}
.field input { padding: 12px 13px; }
.field input:focus, .composer textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px #00a8841f; }

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px #18a6751c; }
.empty { display: grid; place-items: center; height: 100%; padding: 32px; color: var(--muted); text-align: center; }
.error { min-height: 20px; margin: 8px 0; color: #c6324d; font-size: 13px; }

.messages {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 5.5%;
  background-color: var(--chat-bg);
  background-image:
    radial-gradient(circle at 18px 18px, #8696a018 1.2px, transparent 1.4px),
    radial-gradient(circle at 48px 48px, #8696a012 1px, transparent 1.3px);
  background-size: 66px 66px;
}
.message { display: flex; min-width: 0; margin: 10px 0; }
.message .bubble { min-width: 0; max-width: min(78%, 580px); overflow-wrap: anywhere; padding: 7px 10px 8px; border-radius: 8px 8px 8px 2px; color: var(--ink); background: #fff; box-shadow: 0 1px 1px #0b141a1f; }
.message.welcome-message .bubble { border-left: 3px solid var(--whatsapp); background: #fff; box-shadow: 0 2px 8px #0b141a1f; }
.message.self { justify-content: flex-end; }
.message.self .bubble { color: var(--ink); background: var(--outgoing); border-radius: 8px 8px 2px 8px; }
.message.system { justify-content: center; }
.message.system .bubble { padding: 6px 10px; color: #54656f; background: #ffeecd; box-shadow: 0 1px 1px #0b141a12; font-size: 12px; text-align: center; }
.message-meta { margin-bottom: 4px; opacity: .7; font-size: 11px; }
.message-body { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
.translation-note { margin-top: 8px; padding-top: 7px; border-top: 1px solid #dfe5e7; color: var(--muted); font-size: 11px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.self .translation-note { border-top-color: #b8d8b4; color: #54656f; }
.translation-failed { color: #c43d55; }
.media-card { display: block; max-width: 100%; overflow: hidden; border-radius: 10px; background: #111827; }
.media-card img { display: block; width: min(320px, 100%); max-height: 340px; object-fit: contain; background: #eef0f5; }
.media-card video { display: block; width: min(360px, 100%); max-height: 340px; background: #111; }
.media-caption { margin-top: 6px; overflow: hidden; font-size: 11px; opacity: .75; text-overflow: ellipsis; white-space: nowrap; }
.media-loading { min-width: 180px; padding: 25px 12px; color: var(--muted); text-align: center; }

.composer { display: flex; width: 100%; min-width: 0; max-width: 100%; align-items: end; gap: 8px; overflow: hidden; padding: 10px 12px; border-top: 1px solid #d8dcdf; background: #f0f2f5; }
.composer textarea { flex: 1 1 auto; width: auto; min-width: 0; min-height: 44px; max-height: 120px; resize: none; padding: 11px 16px; border: 0; border-radius: 22px; }
.attach-button { display: grid; flex: 0 0 44px; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; color: #54656f; background: transparent; font-size: 25px; font-weight: 400; cursor: pointer; }
.attach-button:hover { background: #dfe3e5; }
.attach-button.uploading { cursor: wait; opacity: .55; }
.file-input { display: none; }
.typing-indicator { min-height: 23px; padding: 3px 18px 5px; color: var(--brand-dark); background: #f0f2f5; font-size: 11px; font-style: italic; }

@media (max-width: 520px) {
  .messages { padding: 13px; }
  .message .bubble { max-width: 88%; }
  .composer { gap: 7px; padding: 10px; }
  .composer .button { flex: 0 0 auto; padding: 11px 12px; white-space: nowrap; }
  .composer .button { max-width: 82px; overflow: hidden; text-overflow: ellipsis; }
}
