/* WhatsApp-assistant preview.
   Authentic WhatsApp layout so it reads as "our assistant, running on WhatsApp".
   Accent aligns with the We MicroSaaS brand green (#0d8050), which sits right on
   top of WhatsApp's own header green, so the two are coherent. */

:root {
  --wa-header: #0d8050;
  --wa-header-ink: #ffffff;
  --wa-bg: #efe7de;
  --wa-in: #ffffff;
  --wa-out: #d6f5cc;
  --wa-ink: #111b21;
  --wa-sub: #667781;
  --wa-tick: #53bdeb;      /* WhatsApp read-receipt blue — iconic, kept for realism */
  --wa-reply-ink: #0d8050;
  --wa-shadow: 0 1px 1px rgba(11, 20, 26, 0.12);
  --wa-radius: 8px;
  --wa-motion: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  color: var(--wa-ink);
}

/* Stage: only visible when the URL is opened directly, not inside the phone frame. */
.stage {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(120% 80% at 50% 0%, #e7f2ec 0%, #dfe9e3 40%, #cfe0d6 100%);
  padding: 0;
}

.wa {
  position: relative;
  width: 100%;
  max-width: 460px;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background-color: var(--wa-bg);
  /* Faint doodle wallpaper, drawn as a tiled SVG so it stays crisp and light. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140' viewBox='0 0 140 140'%3E%3Cg fill='none' stroke='%23c9b8a8' stroke-width='1.4' stroke-linecap='round' opacity='0.28'%3E%3Cpath d='M20 24h14M27 17v14'/%3E%3Ccircle cx='104' cy='30' r='7'/%3E%3Cpath d='M64 96l6 6 10-12'/%3E%3Cpath d='M30 108c4-6 12-6 16 0'/%3E%3Cpath d='M110 104h16M118 96v16'/%3E%3C/g%3E%3C/svg%3E");
  overflow: hidden;
}

@media (min-width: 480px) {
  .wa {
    height: min(92dvh, 900px);
    border-radius: 14px;
    box-shadow: 0 30px 70px -30px rgba(11, 20, 26, 0.55);
  }
}

/* ---------- Header ---------- */
.wa-top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px 10px 4px;
  /* Clear the host phone frame's notch/status area so the name is never
     hidden behind it (and behaves as a status-bar gap when opened directly). */
  padding-top: max(32px, env(safe-area-inset-top));
  background: var(--wa-header);
  color: var(--wa-header-ink);
  z-index: 2;
}

.wa-back, .wa-menu, .wa-hicon {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 6px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  cursor: pointer;
}
.wa-back { padding-left: 4px; }
.wa-actions { margin-left: auto; display: flex; align-items: center; gap: 1px; }
.wa-back:active, .wa-menu:active, .wa-hicon:active { background: rgba(255, 255, 255, 0.16); }

/* Video/voice-call icons only have room once the app fills the screen (mobile);
   on the narrow desktop mock they'd crowd the name, so they hide there. */
.wa-hicon-call { display: none; }
@media (min-width: 340px) { .wa-hicon-call { display: grid; } }

.wa-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.02em;
  flex: 0 0 auto;
}

.wa-id { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.wa-name { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-status { font-size: 12px; opacity: 0.9; }

/* ---------- Chat area ---------- */
.wa-chat {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scroll-behavior: smooth;
}

.wa-row { display: flex; width: 100%; }
.wa-row.in { justify-content: flex-start; }
.wa-row.out { justify-content: flex-end; }

.wa-bubble {
  position: relative;
  max-width: 82%;
  padding: 6px 9px 8px;
  border-radius: 8px;
  font-size: 14.5px;
  line-height: 1.35;
  box-shadow: var(--wa-shadow);
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: pop 0.18s var(--wa-motion);
}
.wa-row.in .wa-bubble { background: var(--wa-in); border-top-left-radius: 2px; }
.wa-row.out .wa-bubble { background: var(--wa-out); border-top-right-radius: 2px; }

.wa-meta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  float: right;
  margin: 6px 0 -4px 8px;
  font-size: 11px;
  color: var(--wa-sub);
}
.wa-meta .tick { color: var(--wa-tick); display: inline-flex; }

.wa-bubble strong { font-weight: 600; }

/* Typing indicator */
.wa-typing { display: inline-flex; gap: 4px; padding: 10px 12px; }
.wa-typing i {
  width: 7px; height: 7px; border-radius: 50%;
  background: #9aa6ac;
  animation: blink 1.2s infinite ease-in-out;
}
.wa-typing i:nth-child(2) { animation-delay: 0.2s; }
.wa-typing i:nth-child(3) { animation-delay: 0.4s; }

/* Day divider / system note */
.wa-note {
  align-self: center;
  background: #d7e7d0;
  color: #4a6b52;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 8px;
  margin: 6px 0;
  box-shadow: var(--wa-shadow);
}

/* ---------- Quick replies ---------- */
.wa-replies {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 10px 2px;
  max-height: 42dvh;
  overflow-y: auto;
}
.wa-replies:empty { display: none; }

.wa-chip {
  border: 0;
  background: #ffffff;
  color: var(--wa-reply-ink);
  font-size: 14.5px;
  font-weight: 500;
  font-family: inherit;
  padding: 11px 14px;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(11, 20, 26, 0.14);
  cursor: pointer;
  text-align: center;
  transition: transform 0.12s var(--wa-motion), background 0.12s var(--wa-motion);
  animation: rise 0.22s var(--wa-motion) both;
}
.wa-chip:hover { background: #f3fbf6; }
.wa-chip:active { transform: scale(0.98); }
.wa-chip:disabled { opacity: 0.5; cursor: default; }

/* ---------- Input bar ---------- */
.wa-input {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: var(--wa-bg);
}
.wa-input-pill {
  flex: 1 1 auto;
  background: #ffffff;
  border-radius: 22px;
  padding: 0 10px;
  box-shadow: var(--wa-shadow);
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
}
.wa-input-pill input {
  border: 0;
  outline: 0;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 15px;
  font-family: inherit;
  background: transparent;
  color: var(--wa-ink);
  padding: 10px 0;
}
.wa-input-pill input::placeholder { color: #8696a0; }

/* Emoji / attach / camera glyphs inside the composer — WhatsApp's signature bar.
   Emoji always shows; attach + camera appear once there's room (mobile). */
.wa-pill-icon { flex: 0 0 auto; display: grid; place-items: center; color: #8696a0; }
.wa-pill-extra { display: none; }
@media (min-width: 340px) { .wa-pill-extra { display: grid; } }
.wa-send {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--wa-header);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.12s var(--wa-motion);
}
.wa-send:active { transform: scale(0.94); }

/* ---------- Animations ---------- */
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes blink { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-2px); } }

@media (prefers-reduced-motion: reduce) {
  .wa-bubble, .wa-chip { animation: none; }
  .wa-chat { scroll-behavior: auto; }
  .wa-typing i { animation: none; opacity: 0.6; }
}
