/*
 * Zozo AI Chat Widget — widget.css
 * Light theme. Primary colour injected via JS into :root --zp-* vars.
 * Inherits from Blocksy CSS vars when present.
 */

:root {
  --zp:       #E8422A;
  --zp-50:    #FEF0ED;
  --zp-100:   #FDD9D3;
  --zp-200:   #FAB3A8;
  --zp-700:   #C73520;
  --zp-ink:   #1a1a1a;
  --zp-ink2:  #555;
  --zp-ink3:  #888;
  --zp-border:#e8e8e8;
  --zp-r:     14px;
  --zp-rsm:   8px;
  --zp-font:  -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Blocksy override — if Blocksy is active, inherit its vars */
@supports (--test: 0) {
  :root {
    --zp: var(--theme-palette-color-1, #E8422A);
  }
}

/* ── ROOT ── */
#zozo-chat-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  font-family: var(--zp-font);
  -webkit-font-smoothing: antialiased;
}

/* ── LAUNCHER ── */
#zozo-launcher {
  width: 54px;
  height: 54px;
  background: var(--zp);
  border: none;
  border-radius: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,.18), 0 0 0 0 rgba(232,66,42,.3);
  transition: transform .2s, box-shadow .2s;
  overflow: hidden;
  padding: 0;
  position: relative;
  margin-left: auto;
}
#zozo-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
#zozo-launcher .z-logo-img {
  width: 100%; height: 100%; object-fit: cover;
  transition: opacity .2s, transform .2s;
}
#zozo-launcher .z-logo-letter {
  font-size: 22px; font-weight: 800; color: white;
  transition: opacity .2s, transform .2s;
}
#zozo-launcher .z-close-icon {
  position: absolute; color: white;
  opacity: 0; transform: rotate(-90deg) scale(.7);
  transition: opacity .2s, transform .2s;
}
#zozo-launcher.z-open .z-logo-img,
#zozo-launcher.z-open .z-logo-letter {
  opacity: 0; transform: rotate(90deg) scale(.7);
}
#zozo-launcher.z-open .z-close-icon {
  opacity: 1; transform: rotate(0) scale(1);
}

/* Badge */
.z-badge {
  position: absolute; top: -4px; right: -4px;
  width: 14px; height: 14px; background: #22c55e;
  border-radius: 50%; border: 2px solid white;
  transition: transform .2s;
}
.z-badge.z-hidden { transform: scale(0); }

/* ── PANEL ── */
#zozo-panel {
  position: absolute;
  bottom: 66px;
  right: 0;
  width: 360px;
  height: 520px;
  background: white;
  border: 1px solid var(--zp-border);
  border-radius: var(--zp-r);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,.12);
  transform: translateY(12px) scale(.97);
  opacity: 0;
  pointer-events: none;
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), opacity .2s ease;
}
#zozo-panel.z-open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* ── HEADER ── */
.z-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .85rem 1.1rem;
  border-bottom: 1px solid var(--zp-border);
  background: var(--zp-50);
  flex-shrink: 0;
}
.z-header-left { display: flex; align-items: center; gap: .6rem; }
.z-av {
  width: 36px; height: 36px; border-radius: 10px;
  overflow: hidden; flex-shrink: 0; position: relative;
  background: var(--zp);
  display: flex; align-items: center; justify-content: center;
}
.z-av img { width: 100%; height: 100%; object-fit: cover; }
.z-av span { font-size: 16px; font-weight: 800; color: white; }
.z-av::after {
  content: '';
  position: absolute; bottom: -2px; right: -2px;
  width: 8px; height: 8px; background: #22c55e;
  border-radius: 50%; border: 2px solid var(--zp-50);
  transition: background .3s;
}
.z-av.z-offline::after { background: #d1d5db; }
.z-name { font-size: .88rem; font-weight: 700; color: var(--zp-ink); line-height: 1.2; }
.z-status { font-size: .68rem; color: #16a34a; font-weight: 500; }
.z-status.z-offline-txt { color: var(--zp-ink3); }
.z-header-right { display: flex; align-items: center; gap: .6rem; }
.z-brand { font-size: .6rem; font-weight: 700; letter-spacing: .1em; color: var(--zp-ink3); }
.z-close-btn {
  display: none; /* hidden on desktop — launcher button closes */
  width: 28px; height: 28px;
  background: var(--zp-50); border: 1px solid var(--zp-100);
  border-radius: 8px; cursor: pointer;
  align-items: center; justify-content: center;
  color: var(--zp-ink2); flex-shrink: 0;
  padding: 0;
}
.z-close-btn:hover { background: var(--zp-100); color: var(--zp); }

/* ── MESSAGES ── */
.z-msgs {
  flex: 1; overflow-y: auto; padding: .9rem;
  display: flex; flex-direction: column; gap: .75rem;
  scroll-behavior: smooth; background: #fafafa;
}
.z-msgs::-webkit-scrollbar { width: 3px; }
.z-msgs::-webkit-scrollbar-thumb { background: var(--zp-border); border-radius: 99px; }

.z-msg {
  display: flex; gap: .45rem; align-items: flex-end;
  animation: zFadeUp .25s ease both;
}
.z-msg.z-bot { align-self: flex-start; max-width: 88%; }
.z-msg.z-usr { align-self: flex-end; max-width: 80%; flex-direction: row-reverse; }

@keyframes zFadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.z-msg-av {
  width: 26px; height: 26px; border-radius: 8px; overflow: hidden;
  flex-shrink: 0; margin-bottom: 2px; background: var(--zp);
  display: flex; align-items: center; justify-content: center;
}
.z-msg-av img { width: 100%; height: 100%; object-fit: cover; }
.z-msg-av span { font-size: 11px; font-weight: 800; color: white; }

.z-bubble {
  padding: .6rem .85rem; border-radius: 12px;
  font-size: .84rem; line-height: 1.65; font-weight: 400;
}
.z-bot .z-bubble {
  background: white; border: 1px solid var(--zp-border);
  border-bottom-left-radius: 3px; color: var(--zp-ink);
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.z-usr .z-bubble {
  background: var(--zp); border-bottom-right-radius: 3px;
  color: white; font-weight: 500;
}

/* Rec card */
.z-rec {
  background: var(--zp-50); border: 1px solid var(--zp-100);
  border-left: 3px solid var(--zp); border-radius: var(--zp-rsm);
  padding: .65rem .85rem; margin-top: .35rem;
}
.z-rec-lbl {
  font-size: .6rem; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--zp); margin-bottom: .2rem;
}
.z-rec-title { font-size: .84rem; font-weight: 700; color: var(--zp-ink); margin-bottom: .1rem; }
.z-rec-desc  { font-size: .74rem; color: var(--zp-ink2); line-height: 1.5; }
.z-rec-link  {
  display: inline-flex; align-items: center; gap: .25rem;
  margin-top: .35rem; font-size: .73rem; font-weight: 600;
  color: var(--zp); text-decoration: none; transition: gap .15s;
}
.z-rec-link:hover { gap: .4rem; }

/* CTA card */
.z-cta {
  background: white; border: 1px solid var(--zp-border);
  border-left: 3px solid #22c55e;
  border-radius: var(--zp-rsm); padding: .65rem .85rem; margin-top: .35rem;
}
.z-cta-lbl   { font-size: .6rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: #16a34a; margin-bottom: .2rem; }
.z-cta-title { font-size: .84rem; font-weight: 700; color: var(--zp-ink); margin-bottom: .1rem; }
.z-cta-note  { font-size: .74rem; color: var(--zp-ink2); line-height: 1.5; }
.z-cta-link  {
  display: inline-flex; align-items: center; gap: .25rem;
  margin-top: .35rem; font-size: .73rem; font-weight: 600;
  color: #16a34a; text-decoration: none; transition: gap .15s;
}
.z-cta-link:hover { gap: .4rem; }

/* Lead form */
.z-lead {
  background: white; border: 1px solid var(--zp-border);
  border-radius: var(--zp-rsm); padding: .75rem .85rem; margin-top: .35rem;
}
.z-lead-lbl { font-size: .6rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--zp); margin-bottom: .5rem; }
.z-lead-inputs { display: flex; flex-direction: column; gap: .35rem; }
.z-lead-in {
  border: 1px solid var(--zp-border); border-radius: 6px;
  padding: .42rem .65rem; font-family: var(--zp-font);
  font-size: .78rem; color: var(--zp-ink); outline: none; transition: border-color .18s;
  width: 100%;
}
.z-lead-in:focus { border-color: var(--zp); }
.z-lead-in::placeholder { color: var(--zp-ink3); }
.z-lead-btn {
  background: var(--zp); border: none; border-radius: 6px;
  padding: .45rem .85rem; margin-top: .35rem;
  font-family: var(--zp-font); font-weight: 600; font-size: .75rem;
  color: white; cursor: pointer; transition: background .18s;
  display: inline-flex; align-items: center; gap: .35rem;
}
.z-lead-btn:hover { background: var(--zp-700); }
.z-lead-note { font-size: .65rem; color: var(--zp-ink3); margin-top: .3rem; }
.z-lead-done { font-size: .8rem; color: #16a34a; font-weight: 600; padding: .35rem 0; }

/* Offline message */
.z-offline-msg {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 1.5rem; text-align: center;
  font-size: .84rem; color: var(--zp-ink2); line-height: 1.65;
  background: #fafafa;
}

/* Captcha gate */
#z-captcha-gate {
  background: #fafafa; border-bottom: 1px solid var(--zp-border);
  padding: 1rem; flex-shrink: 0;
}
.z-captcha-q { font-size: .84rem; font-weight: 600; color: var(--zp-ink); margin-bottom: .5rem; }
.z-captcha-row { display: flex; gap: .5rem; align-items: center; }
.z-captcha-in {
  border: 1px solid var(--zp-border); border-radius: 6px;
  padding: .42rem .65rem; font-size: .84rem; width: 80px; outline: none;
}
.z-captcha-in:focus { border-color: var(--zp); }
.z-captcha-btn {
  background: var(--zp); border: none; border-radius: 6px;
  padding: .45rem .85rem; font-weight: 600; font-size: .78rem;
  color: white; cursor: pointer; transition: background .18s;
}
.z-captcha-btn:hover { background: var(--zp-700); }
.z-captcha-err { font-size: .72rem; color: var(--zp); margin-top: .35rem; }

/* ── TYPING ── */
.z-typing {
  display: flex; align-items: center; gap: .45rem;
  padding: 0 .9rem; flex-shrink: 0; min-height: 22px; margin-bottom: .1rem;
}
.z-dots { display: flex; gap: 3px; }
.z-dot {
  width: 5px; height: 5px; background: var(--zp-200);
  border-radius: 50%; animation: zBounce 1.1s infinite;
}
.z-dot:nth-child(2) { animation-delay: .18s; }
.z-dot:nth-child(3) { animation-delay: .36s; }
@keyframes zBounce {
  0%,60%,100% { transform: translateY(0); opacity: .4; }
  30%          { transform: translateY(-4px); opacity: 1; }
}
.z-typing-txt { font-size: .67rem; color: var(--zp-ink3); font-style: italic; }

/* ── QUICK REPLIES ── */
.z-qr-wrap {
  display: flex; flex-wrap: wrap; gap: .3rem;
  padding: 0 .9rem .5rem; flex-shrink: 0; background: #fafafa;
}
.z-qr {
  background: white; border: 1px solid var(--zp-200); border-radius: 100px;
  padding: .28rem .75rem; font-size: .73rem; font-weight: 500;
  color: var(--zp); cursor: pointer; transition: all .15s; white-space: nowrap;
  font-family: var(--zp-font);
}
.z-qr:hover { background: var(--zp-50); }

/* ── INPUT AREA ── */
.z-input-area {
  padding: .65rem .9rem .8rem;
  border-top: 1px solid var(--zp-border);
  background: white; flex-shrink: 0;
}
.z-input-row {
  display: flex; align-items: flex-end; gap: .4rem;
  border: 1px solid var(--zp-border); border-radius: 10px;
  padding: .45rem .45rem .45rem .8rem; transition: border-color .18s;
}
.z-input-row:focus-within { border-color: var(--zp); }
.z-input {
  flex: 1; background: transparent; border: none; outline: none;
  font-family: var(--zp-font); font-size: .83rem; color: var(--zp-ink);
  font-weight: 400; resize: none; max-height: 80px; line-height: 1.5; padding: .1rem 0;
}
.z-input::placeholder { color: var(--zp-ink3); }
.z-send {
  width: 30px; height: 30px; background: var(--zp); border: none; border-radius: 8px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .16s; color: white;
}
.z-send:hover { background: var(--zp-700); }
.z-send:disabled { opacity: .35; cursor: not-allowed; }
.z-send svg { width: 13px; height: 13px; }
.z-foot { text-align: center; font-size: .6rem; color: var(--zp-ink3); margin-top: .4rem; }

/* ── Mobile ── */
@media (max-width: 480px) {

  /* Root: stays bottom-right, just wraps the launcher */
  #zozo-chat-root {
    bottom: 16px;
    right: 16px;
    left: auto;
    width: auto;
  }

  /* Hide launcher when panel open — panel has its own close button */
  #zozo-launcher.z-open {
    opacity: 0;
    pointer-events: none;
    transform: scale(0);
    transition: opacity .2s, transform .2s;
  }

  /* Panel: anchored to all four edges via inset shorthand.
     Moved to document.body in JS so position:fixed is relative to true viewport.
     No padding here — safe area handled by header only. */
  #zozo-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    transform: translateY(100%);
    transition: transform .3s ease, opacity .2s ease;
  }

  #zozo-panel.z-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: all;
  }

  /* Header: top padding absorbs status bar notch */
  .z-header {
    padding-top: calc(.85rem + env(safe-area-inset-top, 0px));
  }

  /* msgs: takes all remaining vertical space, scrolls internally */
  .z-msgs {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
  }

  /* Show close button in header */
  .z-close-btn {
    display: flex !important;
  }

  /* Input area: never shrinks, always visible */
  .z-input-area {
    flex-shrink: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  /* Prevent iOS auto-zoom on input focus (any input < 16px triggers page zoom) */
  .z-input {
    font-size: 16px;
  }
}