/* Roboto is also what WhatsApp uses on Android, so it is authentic here as
   well as consistent with the console. */
@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 300 600;
  font-display: swap;
  src: url('/fonts/roboto-var.woff2') format('woff2');
}

:root {
  --wa-teal: #075e54;
  --wa-teal-dark: #054d44;
  --wa-green: #25d366;
  --wa-bubble-out: #d9fdd3;
  --wa-bubble-in: #ffffff;
  --wa-bg: #efeae2;
  --wa-text: #111b21;
  --wa-muted: #667781;

  /* Guardian brand — used only for elements the BUSINESS owns inside the
     chat (the quote card, the certificate link). WhatsApp's own chrome keeps
     WhatsApp's colours; a real business card in WhatsApp carries the brand's
     colour, not the app's. */
  --g-plane: #08090b;
  --g-accent: #3987e5;
  --g-accent-2: #1d4f92;
  --g-accent-text: #9dbfe8;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,0.014) 0 1px, transparent 1px 62px),
    radial-gradient(120% 60% at 50% 0%, rgba(60,110,180,0.10), transparent 62%),
    var(--g-plane);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

/* Phone frame */
.phone {
  width: 100%;
  max-width: 420px;
  height: min(860px, 96vh);
  background: var(--wa-bg);
  border-radius: 28px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  position: relative;
}

/* Header */
.wa-header {
  background: var(--wa-teal);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 12px;
  flex-shrink: 0;
}
.wa-back { background: none; border: none; color: #fff; font-size: 26px; line-height: 1; cursor: pointer; opacity: 0.9; }
.wa-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--wa-green), #128c7e);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px; color: #fff; flex-shrink: 0;
}
.wa-title { flex: 1; min-width: 0; }
.wa-name { font-weight: 600; font-size: 16px; }
.wa-status { font-size: 12px; opacity: 0.85; }
.wa-timer {
  background: rgba(255, 255, 255, 0.16);
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-variant-numeric: tabular-nums; font-weight: 600;
  transition: background 0.3s;
}
.wa-timer.done { background: var(--wa-green); color: #05331f; }
.wa-timer.over { background: #f0b429; color: #3d2c00; }

/* Chat area */
.wa-chat {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(0,0,0,0.015) 0 2px, transparent 2px),
    radial-gradient(circle at 70% 60%, rgba(0,0,0,0.015) 0 2px, transparent 2px);
  background-color: var(--wa-bg);
}
.wa-chat::-webkit-scrollbar { width: 0; }
/* Prevent the flex column from compressing tall items (e.g. the QR card). */
.wa-chat > * { flex-shrink: 0; }

.wa-daystamp { display: flex; justify-content: center; margin: 4px 0 8px; }
.wa-daystamp span {
  background: #e2f0e6; color: var(--wa-muted);
  font-size: 11px; font-weight: 600; padding: 5px 12px; border-radius: 8px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.04);
}
.wa-encnote {
  align-self: center; text-align: center; max-width: 85%;
  background: #fdf4c9; color: #6b5b16;
  font-size: 11px; padding: 8px 12px; border-radius: 8px; margin-bottom: 6px;
}

/* Bubbles */
.bubble {
  max-width: 82%;
  padding: 7px 10px 8px;
  border-radius: 10px;
  font-size: 14.5px;
  line-height: 1.4;
  color: var(--wa-text);
  position: relative;
  box-shadow: 0 1px 0.5px rgba(0,0,0,0.13);
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: pop 0.18s ease-out;
}
@keyframes pop { from { transform: translateY(6px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }

.bubble.in { align-self: flex-start; background: var(--wa-bubble-in); border-top-left-radius: 2px; }
.bubble.out { align-self: flex-end; background: var(--wa-bubble-out); border-top-right-radius: 2px; }
.bubble .meta { display: block; text-align: right; font-size: 10px; color: var(--wa-muted); margin-top: 2px; }
.bubble strong { font-weight: 700; }
.bubble em { color: var(--wa-muted); font-style: italic; }

/* Typing indicator */
.typing { align-self: flex-start; background: var(--wa-bubble-in); padding: 12px 14px; border-radius: 10px; border-top-left-radius: 2px; display: inline-flex; gap: 4px; box-shadow: 0 1px 0.5px rgba(0,0,0,0.13); }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: #9aa6ac; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* Quick-reply buttons */
.quick-wrap { align-self: flex-end; display: flex; flex-direction: column; gap: 6px; max-width: 82%; width: 82%; margin: 2px 0 4px; }
.quick {
  background: #fff; color: var(--wa-teal);
  border: none; border-radius: 9px;
  padding: 12px 14px; font-size: 14.5px; font-weight: 600;
  cursor: pointer; text-align: center;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
  transition: transform 0.08s, background 0.15s;
}
.quick:hover { background: #f3faf7; }
.quick:active { transform: scale(0.97); }
.quick.primary { background: var(--wa-teal); color: #fff; }
.quick.primary:hover { background: var(--wa-teal-dark); }
.quick.pay { background: var(--wa-green); color: #05331f; font-size: 16px; }

/* Quote card */
.quote-card {
  align-self: flex-start; background: #fff; border-radius: 12px; border-top-left-radius: 2px;
  max-width: 88%; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,0.15); animation: pop 0.2s ease-out;
}
.quote-head { background: linear-gradient(135deg, var(--g-accent), var(--g-accent-2)); color: #fff; padding: 12px 14px; }
.quote-product { font-size: 13px; opacity: 0.9; }
.quote-price { font-size: 26px; font-weight: 800; margin-top: 2px; }
.quote-price small { font-size: 13px; font-weight: 600; opacity: 0.85; }
.quote-usd { font-size: 11px; opacity: 0.8; }
.quote-body { padding: 12px 14px; }
.quote-body ul { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.quote-body li { font-size: 13.5px; color: #223; padding-left: 20px; position: relative; }
.quote-body li::before { content: "✓"; position: absolute; left: 0; color: var(--wa-green); font-weight: 800; }
.quote-excl { margin-top: 10px; font-size: 12px; color: #b00020; }
.quote-carrier {
  margin-top: 10px; padding-top: 9px; border-top: 1px solid #eceff1;
  font-size: 11px; color: var(--wa-muted);
}
.quote-foot { font-size: 10.5px; color: var(--wa-muted); padding: 0 14px 12px; display: flex; justify-content: space-between; }

/* DuitNow payment QR card */
.pay-card {
  align-self: center;
  background: #fff;
  border-radius: 14px;
  width: 82%;
  max-width: 300px;
  padding: 0 0 16px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  text-align: center;
  animation: pop 0.2s ease-out;
  margin: 4px 0;
}
.pay-head {
  background: linear-gradient(135deg, #ed1c24, #b3121a);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.pay-brand { font-weight: 800; font-size: 16px; letter-spacing: 0.3px; }
.pay-brand span { background: #fff; color: #ed1c24; padding: 1px 6px; border-radius: 5px; font-size: 13px; margin-left: 2px; }
.pay-secure { font-size: 11px; opacity: 0.9; }
.pay-merchant { font-size: 12px; color: #667781; margin-top: 14px; font-weight: 600; letter-spacing: 0.3px; }
.pay-amount { font-size: 26px; font-weight: 800; color: #111b21; margin-top: 2px; }
.pay-qr { padding: 12px 16px 6px; }
.pay-qr img { width: 100%; max-width: 220px; border: 6px solid #fff; border-radius: 8px; }
.pay-instr { font-size: 12px; color: #333; font-weight: 600; }
.pay-ref { font-size: 10px; color: #9aa6ac; margin-top: 6px; font-family: ui-monospace, Menlo, monospace; }

/* Document (certificate) bubble */
.doc {
  align-self: flex-end; background: var(--wa-bubble-out); border-radius: 10px; border-top-right-radius: 2px;
  padding: 10px; max-width: 82%; box-shadow: 0 1px 0.5px rgba(0,0,0,0.13); animation: pop 0.2s ease-out;
}
.doc a { text-decoration: none; color: inherit; display: flex; align-items: center; gap: 10px; }
.doc-icon { width: 42px; height: 42px; border-radius: 8px; background: #eb5757; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.doc-meta { min-width: 0; }
.doc-title { font-size: 14px; font-weight: 600; color: var(--wa-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-sub { font-size: 11px; color: var(--wa-muted); }
.doc-dl { font-size: 11px; color: var(--g-accent); font-weight: 700; margin-top: 3px; }

/* Composer */
.wa-composer { background: #f0f2f5; padding: 8px 10px; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.wa-input { flex: 1; background: #fff; border-radius: 22px; padding: 10px 16px; font-size: 13.5px; color: var(--wa-muted); }
.wa-send { width: 42px; height: 42px; border-radius: 50%; border: none; background: var(--wa-teal); color: #fff; font-size: 18px; cursor: pointer; flex-shrink: 0; }
.wa-send:active { transform: scale(0.95); }

.admin-link { position: fixed; top: 14px; right: 16px; color: var(--g-accent-text); font-size: 12px; text-decoration: none; opacity: 0.75; }
.admin-link:hover { opacity: 1; }
