* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(ellipse 90% 70% at 50% 38%, #2a3935 0%, #11181a 60%, #060a0c 100%);
  color: #111B21;
  display: flex; align-items: center; justify-content: center;
  height: 100dvh;
  overflow: hidden;
}

/* Institutional footer marker — desktop only */
body::after {
  content: "Capital Verde Europeia 2026 · Demonstração";
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.34);
  white-space: nowrap;
  pointer-events: none;
  font-weight: 500;
}
@media (max-width: 500px) {
  body::after { display: none; }
}

/* Phone frame — desktop */
.phone-frame {
  width: 375px;
  height: 812px;
  max-height: 95dvh;
  border-radius: 50px;
  overflow: hidden;
  box-shadow:
    0 0 0 3px #1a1a1a,
    0 0 0 6px #333,
    0 30px 80px rgba(0,0,0,0.6),
    0 0 0 1px rgba(255,255,255,0.04);
  display: flex; flex-direction: column;
  background: #ECE5DD;
  position: relative;
}

/* Notch */
.phone-frame::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 160px;
  height: 30px;
  background: #1a1a1a;
  border-radius: 0 0 18px 18px;
  z-index: 10;
}

/* Mobile: full screen, no frame */
@media (max-width: 500px) {
  body { background: #ECE5DD; }
  .phone-frame {
    width: 100%;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
  }
  .phone-frame::before { display: none; }
}

/* Header */
.topbar {
  background: #075E54;
  color: #fff;
  padding: 38px 14px 10px;
  display: flex; align-items: center; gap: 12px;
  flex: 0 0 auto;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
  position: relative;
  z-index: 5;
}
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: #128C7E; color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.avatar svg { width: 22px; height: 22px; display: block; }

.title-block { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; flex: 1; }
.title-row { display: flex; align-items: center; gap: 5px; }
.title { font-weight: 600; font-size: 16px; }
.verified {
  width: 14px; height: 14px; flex-shrink: 0;
}
.subtitle {
  font-size: 12px;
  opacity: 0.88;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 5px;
}
.online-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.7);
  flex-shrink: 0;
}

/* Chat area */
.chat {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 10px 10px 6px;
  display: flex; flex-direction: column; gap: 4px;
  background:
    linear-gradient(rgba(236,229,221,0.92), rgba(236,229,221,0.92)),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='40'><circle cx='2' cy='2' r='1' fill='%23000' opacity='0.04'/></svg>");
}
.chat::before {
  content: "";
  flex: 1 1 auto;
}

/* Bubbles */
.bubble {
  max-width: 85%;
  padding: 6px 10px 4px;
  border-radius: 7.5px;
  box-shadow: 0 1px 1px rgba(0,0,0,0.08);
  word-wrap: break-word;
  overflow-wrap: break-word;
  animation: bubbleIn 180ms ease-out;
}
@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.bubble.bot {
  align-self: flex-start;
  background: #FFFFFF;
  border-top-left-radius: 0;
  margin-right: auto;
}
.bubble.user {
  align-self: flex-end;
  background: #DCF8C6;
  border-top-right-radius: 0;
  margin-left: auto;
}
.bubble + .bubble { margin-top: 2px; }
.bubble.bot + .bubble.user,
.bubble.user + .bubble.bot { margin-top: 10px; }

.text {
  font-size: 14.5px;
  line-height: 1.4;
  white-space: pre-wrap;
  color: #111B21;
}
.text strong { font-weight: 600; }
.text em { font-style: italic; }
.text del { text-decoration: line-through; opacity: 0.7; }
.text code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: rgba(0,0,0,0.05);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.92em;
}
.text a { color: #027EB5; text-decoration: underline; }

.time {
  font-size: 11px; color: #667781;
  text-align: right; margin-top: 1px;
}

/* Typing indicator */
.typing {
  display: inline-flex; gap: 4px; padding: 6px 4px 4px;
  align-items: center;
}
.typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: #8696A0;
  animation: blink 1.3s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.18s; }
.typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes blink {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.9); }
  40% { opacity: 1; transform: scale(1.05); }
}

/* Composer */
.composer {
  background: #F0F2F5;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  flex: 0 0 auto;
}
.composer form { display: flex; gap: 8px; align-items: center; }
#input {
  flex: 1; border: 0; border-radius: 22px;
  padding: 10px 14px; font-size: 15px;
  background: #fff; color: #111B21;
  outline: none;
}
#input:disabled { opacity: 0.6; }
#send {
  width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: #25D366; color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease;
}
#send:hover:not(:disabled) { transform: scale(1.06); background: #20BD5C; }
#send:disabled { background: #8696A0; cursor: default; }

/* Quick-reply chips */
.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 0 2px;
  align-self: flex-start;
  max-width: 100%;
  animation: bubbleIn 180ms ease-out;
}
.chip {
  appearance: none;
  border: 1.5px solid #25D366;
  background: #fff;
  color: #075E54;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: 18px;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, transform 100ms ease;
  white-space: nowrap;
  flex: 1 1 auto;
  text-align: center;
  min-width: 0;
}
.chip:hover {
  background: #25D366;
  color: #fff;
}
.chip:active {
  background: #128C7E;
  color: #fff;
  transform: scale(0.97);
}

/* FIX 1: iOS status bar */
.status-bar {
  background: #075E54;
  color: #fff;
  height: 44px;
  padding: 14px 28px 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  font-weight: 600;
  font-feature-settings: "tnum";
  flex: 0 0 auto;
  position: relative;
  z-index: 6;
}
.status-icons { display: inline-flex; gap: 5px; align-items: center; }
.status-icons svg { display: block; }
/* Ajustar padding do topbar agora que status-bar fornece o espaço para o notch */
.topbar { padding: 10px 14px 10px !important; }
@media (max-width: 500px) {
  .status-bar { display: none; }
  .topbar { padding: calc(10px + env(safe-area-inset-top)) 14px 10px !important; }
}

/* FIX 2: Institutional badge */
.institutional-badge {
  background: linear-gradient(90deg, #0a7d5c, #0d6b4f);
  color: #d4f4e0;
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: center;
  padding: 5px 10px;
  font-weight: 600;
  flex: 0 0 auto;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}

/* FIX 4: Ticks azuis */
.bubble.user .time {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
}
.ticks { color: #53bdeb; line-height: 0; }
.ticks svg { display: block; }

/* Language selector chips */
.lang-selector {
  justify-content: center;
  gap: 8px;
  padding: 10px 0 4px;
}
.chip-lang {
  font-size: 14px;
  padding: 9px 16px;
  flex: 0 1 auto;
}

/* Browse chips: fixed 3-column grid for consistent layout */
.browse-chips {
  display: grid !important;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.browse-chips .chip {
  flex: none;
  min-width: 0;
  white-space: nowrap;
  font-size: 12px;
  padding: 7px 8px;
}

/* Accessibility: respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .bubble, .quick-replies { animation: none; }
  .typing span { animation: none; opacity: 0.6; }
  .online-dot { box-shadow: none; }
  #send { transition: none; }
  .chip { transition: none; }
}
