:root {
  --wa-dark: #075e54;
  --wa-mid: #128c7e;
  --wa-green: #25d366;
  --wa-green-hover: #20bd5a;
  --chat-bg: #efe7dd;
  --incoming: #ffffff;
  --outgoing: #dcf8c6;
  --text: #17211d;
  --muted: #6f7d77;
  --shadow: 0 20px 60px rgba(9, 36, 31, 0.22);
  --radius: 18px;
  --font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: var(--font-family);
  background: radial-gradient(circle at center, #128c7e 0%, #064039 100%);
  color: var(--text);
  overflow: hidden;
}

body {
  display: grid;
  place-items: center;
  min-height: 100vh;
}

/* Phone Container Frame */
.phone {
  width: min(100%, 460px);
  height: 100vh;
  min-height: 100%;
  background: var(--chat-bg);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

@media (min-width: 520px) {
  body {
    padding: 24px;
    background: radial-gradient(circle at center, #128c7e 0%, #064039 100%);
  }
  .phone {
    height: min(860px, calc(100vh - 48px));
    border-radius: 28px;
    border: 8px solid #2d3835;
  }
}

/* Header styling */
.chat-header {
  height: 76px;
  flex: 0 0 auto;
  background: var(--wa-dark);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.12);
  z-index: 10;
  cursor: pointer;
  user-select: none;
}

.avatar {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 50%;
  overflow: hidden;
  background: #2f2f93;
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.25);
  transition: transform 0.2s ease;
}

.avatar:hover {
  transform: scale(1.05);
}

.contact {
  min-width: 0;
  flex: 1;
}

.contact-name {
  font-weight: 700;
  font-size: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.status {
  display: flex;
  align-items: center;
  gap: 6px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 13px;
  margin-top: 1px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--wa-green);
  box-shadow: 0 0 0 4px rgba(37, 211, 102, 0.2);
  display: inline-block;
}

.header-icon {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0.9;
  transition: background 0.2s, opacity 0.2s;
}

.header-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  opacity: 1;
}

/* Chat Message Area */
.chat {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 20px 16px 120px;
  scroll-behavior: smooth;
  background:
    linear-gradient(rgba(239, 231, 221, 0.93), rgba(239, 231, 221, 0.93)),
    radial-gradient(circle at 10% 10%, rgba(7, 94, 84, 0.05) 0 2px, transparent 3px),
    radial-gradient(circle at 85% 25%, rgba(7, 94, 84, 0.05) 0 2px, transparent 3px),
    radial-gradient(circle at 45% 65%, rgba(7, 94, 84, 0.04) 0 2px, transparent 3px);
  background-size: auto, 120px 120px, 150px 150px, 180px 180px;
}

/* Custom Scrollbar for Chat */
.chat::-webkit-scrollbar {
  width: 5px;
}
.chat::-webkit-scrollbar-track {
  background: transparent;
}
.chat::-webkit-scrollbar-thumb {
  background: rgba(7, 94, 84, 0.15);
  border-radius: 10px;
}
.chat::-webkit-scrollbar-thumb:hover {
  background: rgba(7, 94, 84, 0.3);
}

.row {
  display: flex;
  width: 100%;
  margin: 10px 0;
  animation: rise 0.28s cubic-bezier(0.18, 0.89, 0.32, 1.28) both;
}

.row.bot {
  justify-content: flex-start;
}

.row.user {
  justify-content: flex-end;
}

/* Bubbles */
.bubble {
  max-width: min(85%, 350px);
  border-radius: 16px;
  padding: 10px 14px 8px;
  font-size: 15.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  position: relative;
  box-shadow: 0 1.5px 2px rgba(0, 0, 0, 0.06);
  overflow-wrap: anywhere;
}

.bot .bubble {
  background: var(--incoming);
  border-top-right-radius: 4px;
}

.user .bubble {
  background: var(--outgoing);
  border-top-left-radius: 4px;
}

.time {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
  margin-inline-start: 12px;
  float: left;
  transform: translateY(4px);
  margin-top: -2px;
}

.ticks {
  color: #53a6d8;
  font-size: 13px;
  letter-spacing: -2px;
  font-weight: bold;
}

/* Media Bubbles */
.media-bubble {
  max-width: min(88%, 370px);
  padding: 6px;
  border-radius: var(--radius);
}

.chat-photo {
  width: 100%;
  display: block;
  border-radius: 14px;
  background: #f5f5f5;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
}

.caption {
  padding: 8px 8px 4px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
}

/* Typing Indicator */
.typing {
  width: 72px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--incoming);
  border-radius: 18px;
  border-top-right-radius: 4px;
  box-shadow: 0 1.5px 2px rgba(0, 0, 0, 0.06);
}

.typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9ca8a2;
  animation: blink 1.2s infinite ease-in-out;
}

.typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing span:nth-child(3) {
  animation-delay: 0.4s;
}

/* Bottom Quick Replies and CTAs */
.quick-replies {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  padding: 16px 16px 20px;
  background: linear-gradient(to top, rgba(239, 231, 221, 1) 75%, rgba(239, 231, 221, 0));
  display: grid;
  gap: 10px;
  z-index: 5;
  animation: slideUp 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.quick-replies.hidden {
  display: none;
}

.options {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.options.single {
  justify-content: center;
}

.reply,
.cta {
  width: auto;
  min-width: 130px;
  max-width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  padding: 10px 22px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  touch-action: manipulation;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  outline: none;
}

.reply {
  background: #ffffff;
  color: var(--wa-dark);
  border: 1px solid rgba(7, 94, 84, 0.2);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.reply:hover {
  background: #fbfbfb;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.reply:active {
  transform: translateY(0) scale(0.98);
}

.cta {
  background: var(--wa-green);
  color: #073b22;
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.35);
  font-size: 16px;
}

.cta:hover {
  background: var(--wa-green-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(37, 211, 102, 0.45);
}

.cta:active {
  transform: translateY(0) scale(0.98);
}

/* Animations */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  40% {
    opacity: 1;
    transform: scale(1.1);
  }
}

@media (max-width: 360px) {
  .bubble {
    font-size: 14.5px;
  }
  .reply,
  .cta {
    min-width: 120px;
    padding-inline: 16px;
  }
  .contact-name {
    font-size: 16px;
  }
}

