:root {
  --wa-header: #075e54;
  --wa-header-dark: #054c44;
  --wa-bg: #e5ddd5;
  --wa-bubble-in: #ffffff;
  --wa-bubble-out: #dcf8c6;
  --wa-text: #111b21;
  --wa-meta: #667781;
  --wa-accent: #25d366;
  --wa-composer: #f0f0f0;
  --wa-danger: #d32f2f;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  font-family: "Segoe UI", Helvetica, Arial, sans-serif;
  background: #0b141a;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.phone {
  width: 100%;
  max-width: 420px;
  height: 100vh;
  height: 100dvh;
  max-height: 900px;
  background: var(--wa-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
  position: relative;
}

@media (min-width: 480px) {
  .phone {
    height: min(900px, 92vh);
    height: min(900px, 92dvh);
    margin: 16px 0;
    border-radius: 16px;
  }
}

/* Header */
.chat-header {
  background: var(--wa-header);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  flex-shrink: 0;
  z-index: 2;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  background: #cfd8dc;
}

.avatar-text {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--wa-header-dark);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.header-info {
  flex: 1;
  min-width: 0;
}

.header-name {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-status {
  font-size: 12.5px;
  opacity: 0.85;
  line-height: 1.2;
}

.header-icons {
  display: flex;
  gap: 4px;
}

.icon-btn {
  background: transparent;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.back-btn {
  margin-right: -2px;
}

/* Chat body */
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background-color: var(--wa-bg);
  background-image:
    radial-gradient(circle at 15% 20%, rgba(0,0,0,0.02) 0, transparent 40%),
    radial-gradient(circle at 85% 60%, rgba(0,0,0,0.02) 0, transparent 40%);
}

.day-divider {
  text-align: center;
  margin: 6px auto 14px;
}

.day-divider span {
  background: #e1f2fb;
  color: #54656f;
  font-size: 12.5px;
  padding: 5px 12px;
  border-radius: 8px;
  box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.1);
}

.msg-row {
  display: flex;
  margin: 2px 6px;
  animation: pop-in 0.18s ease-out;
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.msg-row.in {
  justify-content: flex-start;
}

.msg-row.out {
  justify-content: flex-end;
}

.bubble {
  max-width: 78%;
  padding: 6px 9px 6px 9px;
  border-radius: 8px;
  font-size: 14.3px;
  line-height: 1.35;
  position: relative;
  box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.msg-row.in .bubble {
  background: var(--wa-bubble-in);
  color: var(--wa-text);
  border-top-left-radius: 0;
}

.msg-row.out .bubble {
  background: var(--wa-bubble-out);
  color: var(--wa-text);
  border-top-right-radius: 0;
}

.bubble .meta {
  display: block;
  text-align: right;
  font-size: 11px;
  color: var(--wa-meta);
  margin-top: 3px;
  float: right;
  margin-left: 8px;
  white-space: nowrap;
}

.bubble .meta .tick {
  color: #53bdeb;
  margin-left: 2px;
}

.bubble.error {
  border: 1px solid #ffd7d7;
  background: #fff0f0;
}

.bubble strong {
  font-weight: 700;
}

/* Card bubble (result / summary) */
.bubble.card {
  max-width: 88%;
}

.card-title {
  font-weight: 700;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
  border-bottom: 1px dashed rgba(0, 0, 0, 0.08);
  font-size: 13.5px;
}

.card-row:last-of-type {
  border-bottom: none;
}

.card-row .label {
  color: var(--wa-meta);
}

.card-row .value {
  font-weight: 600;
  text-align: right;
}

/* Typing indicator */
.typing-row {
  display: flex;
  margin: 2px 6px;
}

.typing-bubble {
  background: var(--wa-bubble-in);
  border-radius: 8px;
  border-top-left-radius: 0;
  padding: 10px 14px;
  display: flex;
  gap: 4px;
  align-items: center;
  box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
}

.typing-bubble span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9aa3a7;
  display: inline-block;
  animation: blink 1.2s infinite ease-in-out;
}

.typing-bubble span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-bubble span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes blink {
  0%, 80%, 100% {
    opacity: 0.3;
    transform: scale(0.85);
  }
  40% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Quick reply buttons */
.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 12px;
  background: var(--wa-bg);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.quick-replies.hidden,
[hidden] {
  display: none !important;
}

.qr-btn {
  border: 1.5px solid var(--wa-header);
  color: var(--wa-header);
  background: #fff;
  padding: 9px 18px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.qr-btn:hover {
  background: var(--wa-header);
  color: #fff;
}

.qr-btn.danger {
  border-color: var(--wa-danger);
  color: var(--wa-danger);
}

.qr-btn.danger:hover {
  background: var(--wa-danger);
  color: #fff;
}

.qr-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Dropdown nativo (listas longas, ex: estados) */
.select-wrap {
  display: flex;
  gap: 8px;
  width: 100%;
}

.qr-select {
  flex: 1;
  min-width: 0;
  border: 1.5px solid var(--wa-header);
  color: var(--wa-text);
  background: #fff;
  padding: 9px 12px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.qr-select-confirm {
  flex-shrink: 0;
}

/* Composer */
.composer {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--wa-bg);
  flex-shrink: 0;
}

.composer-input {
  flex: 1;
  border: none;
  border-radius: 22px;
  padding: 11px 16px;
  font-size: 16px;
  background: #fff;
  outline: none;
  min-width: 0;
}

.composer-input:disabled {
  background: #f5f5f5;
  color: #99a3a6;
}

.composer .icon-btn {
  color: #54656f;
}

.composer .icon-btn svg {
  width: 24px;
  height: 24px;
}

.send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--wa-header);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.send-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  margin-left: -2px;
}

.send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.chat-body::-webkit-scrollbar {
  width: 6px;
}

.chat-body::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}
