/* ═══════════════════════════════════════════════════════════
   Alfa Mare Chatbot — Public CSS v1.1
   ═══════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

#amchat-root * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

#amchat-root {
  --am-primary:       #1a6e3c;
  --am-primary-dark:  #155c31;
  --am-primary-light: rgba(26,110,60,.12);
  --am-online:        #22c55e;
  --am-shadow:        0 8px 48px rgba(0,0,0,.18);
  --am-msg-gap:       14px;
  --am-pad-h:         18px;
  --am-pad-v:         20px;
}

/* ══════════════════════════════════════════════════════════
   LAUNCHER
══════════════════════════════════════════════════════════ */
#amchat-launcher {
  position: fixed;
  bottom: 28px;
  z-index: 999990;
  display: flex;
  align-items: center;
  gap: 0;
}
#amchat-launcher.amchat-left  { left: 24px;  flex-direction: row; }
#amchat-launcher.amchat-right { right: 24px; flex-direction: row-reverse; }

#amchat-balloon {
  background: #fff;
  border-radius: 22px;
  padding: 13px 20px;
  font-size: 14px;
  font-weight: 500;
  color: #1e2a38;
  box-shadow: 0 4px 22px rgba(0,0,0,.14);
  position: relative;
  cursor: pointer;
  animation: amBalloonIn .45s cubic-bezier(.34,1.56,.64,1) both;
  max-width: 250px;
  line-height: 1.45;
}
#amchat-launcher.amchat-left  #amchat-balloon { margin-right: 10px; border-bottom-left-radius: 5px; }
#amchat-launcher.amchat-right #amchat-balloon { margin-left:  10px; border-bottom-right-radius: 5px; }
#amchat-launcher.amchat-left  #amchat-balloon::after {
  content: ''; position: absolute; right: -8px; bottom: 15px;
  border-top: 6px solid transparent; border-bottom: 6px solid transparent; border-left: 9px solid #fff;
}
#amchat-launcher.amchat-right #amchat-balloon::after {
  content: ''; position: absolute; left: -8px; bottom: 15px;
  border-top: 6px solid transparent; border-bottom: 6px solid transparent; border-right: 9px solid #fff;
}
@keyframes amBalloonIn {
  from { opacity:0; transform: scale(.7) translateX(12px); }
  to   { opacity:1; transform: scale(1)  translateX(0); }
}

#amchat-balloon-close {
  position: absolute; top: -8px; right: -8px;
  width: 20px; height: 20px;
  background: #94a3b8; border: 2px solid #fff; border-radius: 50%;
  font-size: 9px; color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s; line-height: 1;
}
#amchat-balloon-close:hover { background: #64748b; }

#amchat-bubble {
  width: 60px; height: 60px; border-radius: 50%;
  background: #fff; border: none;
  box-shadow: 0 4px 20px rgba(0,0,0,.18);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; overflow: visible; position: relative;
  transition: transform .2s;
  animation: amBubbleIn .35s cubic-bezier(.34,1.56,.64,1) both .08s;
}
#amchat-bubble:hover { transform: scale(1.07); }
#amchat-bubble svg,
#amchat-bubble img.amchat-bubble-img {
  width: 42px; height: 42px; border-radius: 50%; object-fit: cover;
}
@keyframes amBubbleIn {
  from { opacity:0; transform: scale(.5); }
  to   { opacity:1; transform: scale(1); }
}

.amchat-online-pip {
  position: absolute; bottom: 2px; right: 2px;
  width: 15px; height: 15px;
  background: var(--am-online); border-radius: 50%;
  border: 2.5px solid #fff;
  box-shadow: 0 0 0 1px rgba(34,197,94,.25);
}

/* ══════════════════════════════════════════════════════════
   CHAT WINDOW
══════════════════════════════════════════════════════════ */
#amchat-window {
  position: fixed;
  bottom: 104px;
  width: 390px;
  height: 600px;
  background: #fff;
  border-radius: 20px;
  box-shadow: var(--am-shadow);
  display: flex; flex-direction: column;
  overflow: hidden;
  opacity: 0; pointer-events: none;
  transform: translateY(18px) scale(.96);
  transition: opacity .24s ease, transform .24s ease;
  z-index: 999989;
}
#amchat-window.amchat-left  { left: 24px; }
#amchat-window.amchat-right { right: 24px; }
#amchat-window.amchat-open  { opacity:1; pointer-events:all; transform:translateY(0) scale(1); }

/* ── HEADER ───────────────────────────────────────────── */
#amchat-header {
  background: var(--am-primary);
  padding: 0 18px;
  height: 72px;
  display: flex; align-items: center; gap: 12px;
  flex-shrink: 0;
}
.amchat-hav {
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(255,255,255,.15);
  overflow: hidden; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid rgba(255,255,255,.35);
}
.amchat-hav svg { width: 40px; height: 40px; }
.amchat-hav img.amchat-hav-img {
  width: 46px; height: 46px; object-fit: cover; border-radius: 50%;
}
.amchat-hinfo  { flex: 1; min-width: 0; }
.amchat-hname  { font-size: 15px; font-weight: 700; color: #fff; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.amchat-hco    { font-size: 11.5px; color: rgba(255,255,255,.72); margin-top: 1px; }
.amchat-honline {
  display: flex; align-items: center; gap: 5px;
  font-size: 11.5px; color: rgba(255,255,255,.9); margin-top: 4px;
}
.amchat-honline::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: #7effa0; box-shadow: 0 0 6px #7effa0; display: block; flex-shrink: 0;
}
.amchat-close-btn {
  background: rgba(255,255,255,.15); border: none;
  width: 34px; height: 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: #fff; transition: background .15s; flex-shrink: 0;
}
.amchat-close-btn:hover { background: rgba(255,255,255,.28); }
.amchat-close-btn svg   { width: 16px; height: 16px; fill: none; }

/* ── BODY ─────────────────────────────────────────────── */
#amchat-body {
  flex: 1; overflow-y: auto;
  padding: var(--am-pad-v) var(--am-pad-h) 12px;
  display: flex; flex-direction: column;
  gap: var(--am-msg-gap);
  background: #f5f7fa;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
#amchat-body::-webkit-scrollbar       { width: 4px; }
#amchat-body::-webkit-scrollbar-thumb { background: #d0d7e2; border-radius: 4px; }

/* ── LINHAS ───────────────────────────────────────────── */
.amchat-row {
  display: flex; gap: 10px; align-items: flex-end;
  animation: amMsgIn .28s ease;
}
@keyframes amMsgIn {
  from { opacity:0; transform: translateY(8px); }
  to   { opacity:1; transform: translateY(0); }
}
.amchat-row-av {
  width: 34px; height: 34px; border-radius: 50%;
  background: #fff; border: 1px solid #e2e8f0;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
}
.amchat-row-av svg { width: 30px; height: 30px; }
.amchat-row-av img.amchat-av-img {
  width: 34px; height: 34px; object-fit: cover; border-radius: 50%;
}

/* ── BALÕES ───────────────────────────────────────────── */
.amchat-bubble-bot {
  background: #fff;
  border: 1px solid #e8edf4;
  border-radius: 16px 16px 16px 4px;
  padding: 13px 16px;
  font-size: 14.5px; line-height: 1.6; color: #1e2a38;
  box-shadow: 0 1px 5px rgba(0,0,0,.06);
  max-width: calc(100% - 52px);
  word-break: break-word;
}
.amchat-row.amchat-user { flex-direction: row-reverse; }
.amchat-bubble-user {
  background: var(--am-primary);
  border-radius: 16px 16px 4px 16px;
  padding: 13px 16px;
  font-size: 14.5px; line-height: 1.6; color: #fff;
  max-width: calc(100% - 20px);
  word-break: break-word;
  box-shadow: 0 2px 8px rgba(26,110,60,.25);
}

/* ── TYPING ───────────────────────────────────────────── */
.amchat-typing-row { display: flex; gap: 10px; align-items: flex-end; animation: amMsgIn .28s ease; }
.amchat-typing-bub {
  background: #fff; border: 1px solid #e8edf4;
  border-radius: 16px 16px 16px 4px;
  padding: 15px 18px; display: flex; gap: 5px; align-items: center;
  box-shadow: 0 1px 5px rgba(0,0,0,.06);
}
.amchat-typing-bub span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--am-primary); opacity: .55;
  animation: amTyp 1.1s ease-in-out infinite;
}
.amchat-typing-bub span:nth-child(2){animation-delay:.18s}
.amchat-typing-bub span:nth-child(3){animation-delay:.36s}
@keyframes amTyp { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-6px)} }

/* ── CTA ──────────────────────────────────────────────── */
.amchat-cta {
  align-self: center;
  background: var(--am-primary); color: #fff; border: none;
  border-radius: 12px; padding: 14px 30px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  box-shadow: 0 4px 14px rgba(26,110,60,.38);
  animation: amMsgIn .3s ease; transition: background .15s, transform .12s;
  font-family: inherit; margin-top: 4px;
}
.amchat-cta:hover { background: var(--am-primary-dark); transform: translateY(-1px); }

/* ── WHATSAPP ─────────────────────────────────────────── */
.amchat-wa-btn {
  align-self: center; background: #25d366; color: #fff; border: none;
  border-radius: 12px; padding: 14px 24px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; gap: 9px;
  box-shadow: 0 4px 14px rgba(37,211,102,.38);
  animation: amMsgIn .3s ease; transition: background .15s, transform .12s;
  font-family: inherit; text-decoration: none; margin-top: 4px;
}
.amchat-wa-btn:hover { background: #1db954; transform: translateY(-1px); }
.amchat-wa-btn svg   { width: 20px; height: 20px; fill: #fff; flex-shrink: 0; }

/* ── STATUS ───────────────────────────────────────────── */
.amchat-status {
  font-size: 13px; border-radius: 10px; padding: 11px 14px;
  animation: amMsgIn .25s ease; text-align: center; line-height: 1.4;
}
.amchat-status.ok      { background:#e6f9ee; color:#1a6e3c; border:1px solid #aee8c1; }
.amchat-status.err     { background:#fff0f0; color:#c53030; border:1px solid #fbb6b6; }
.amchat-status.loading { background:#f0f4f8; color:#718096; border:1px solid #e2e8f0; }

/* ── FOOTER INPUT ─────────────────────────────────────── */
#amchat-footer {
  padding: 12px 14px; border-top: 1px solid #eaeef4;
  display: flex; gap: 9px; align-items: flex-end;
  background: #fff; flex-shrink: 0;
}
#amchat-input {
  flex: 1; background: #f4f7fb; border: 1.5px solid #dde3ee;
  border-radius: 12px; padding: 11px 14px;
  font-size: 14.5px; color: #1e2a38;
  resize: none; outline: none;
  min-height: 44px; max-height: 96px;
  transition: border-color .2s, box-shadow .2s;
  font-family: inherit; line-height: 1.45;
  -webkit-appearance: none;
}
#amchat-input::placeholder { color: #aab2c0; }
#amchat-input:focus { border-color: var(--am-primary); box-shadow: 0 0 0 3px rgba(26,110,60,.1); }
#amchat-input:disabled { background: #eef2f7; cursor: default; color: #a0aec0; }

#amchat-send {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--am-primary); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .15s, transform .12s, opacity .15s;
}
#amchat-send:hover:not(:disabled) { background: var(--am-primary-dark); transform: scale(1.05); }
#amchat-send:disabled { opacity: .32; cursor: default; }
#amchat-send svg { width: 18px; height: 18px; fill: #fff; }

#amchat-lgpd {
  text-align: center; font-size: 11px; color: #aab2c0;
  padding: 6px 0 10px; background: #fff; flex-shrink: 0; letter-spacing: .1px;
}
#amchat-lgpd a { color: var(--am-primary); text-decoration: none; }
#amchat-lgpd a:hover { text-decoration: underline; }

/* ══════════════════════════════════════════════════════════
   RESPONSIVO MOBILE
══════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  #amchat-window {
    width: 100vw !important;
    height: 100dvh !important;
    left: 0 !important; right: 0 !important; bottom: 0 !important;
    border-radius: 20px 20px 0 0;
    transform: translateY(24px) scale(1) !important;
  }
  #amchat-window.amchat-open { transform: translateY(0) scale(1) !important; }

  #amchat-launcher.amchat-left  { left: 14px; }
  #amchat-launcher.amchat-right { right: 14px; }
  #amchat-launcher { bottom: 20px; }
  #amchat-bubble  { width: 56px; height: 56px; }
  #amchat-bubble svg,
  #amchat-bubble img.amchat-bubble-img { width: 38px; height: 38px; }
  #amchat-balloon { max-width: 210px; font-size: 13.5px; padding: 11px 16px; }

  #amchat-header  { height: 68px; padding: 0 16px; }
  #amchat-body    { --am-pad-h: 14px; --am-pad-v: 16px; --am-msg-gap: 14px; }

  .amchat-bubble-bot,
  .amchat-bubble-user { font-size: 15px; padding: 12px 15px; }

  #amchat-footer  { padding: 10px 12px 12px; }
  #amchat-input   { font-size: 15px; min-height: 46px; padding: 12px 14px; }
  #amchat-send    { width: 46px; height: 46px; }

  .amchat-cta     { padding: 15px 32px; font-size: 15.5px; width: 100%; max-width: 280px; }
  .amchat-wa-btn  { padding: 15px 24px; font-size: 15px; width: 100%; max-width: 300px; justify-content: center; }
}

@media (max-width: 360px) {
  #amchat-balloon { max-width: 175px; font-size: 13px; }
  .amchat-bubble-bot,
  .amchat-bubble-user { font-size: 14px; }
}

@media (max-width: 480px) and (orientation: landscape) {
  #amchat-body { --am-pad-v: 10px; --am-msg-gap: 10px; }
}

/* Safe area — iPhone notch/home bar */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  #amchat-footer {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
  #amchat-launcher {
    bottom: calc(20px + env(safe-area-inset-bottom));
  }
}
