/*
 * Viareggio Chatbot widget — Cliengo-style.
 * Theme: green (#00B388) primary.
 */

:root {
  --vc-brand: #00B388;
  --vc-brand-dark: #009674;
  --vc-text: #2b2b2b;
  --vc-bot-bg: #f0f2f5;
  --vc-user-bg: #00B388;
  --vc-user-color: #fff;
  --vc-border: #e5e7eb;
}

.vc-launcher {
  position: fixed; bottom: 20px; right: 20px; z-index: 9990;
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--vc-brand); color: white; border: 0; cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,179,136,.45);
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s ease, box-shadow .2s ease;
}
.vc-launcher:hover { transform: scale(1.06); box-shadow: 0 8px 24px rgba(0,179,136,.55); }
.vc-launcher svg { width: 30px; height: 30px; fill: white; }
.vc-launcher.hidden { display: none; }

.vc-prompt {
  position: fixed; bottom: 96px; right: 20px; z-index: 9989;
  background: white; padding: 12px 38px 12px 14px; border-radius: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12); max-width: 240px;
  font-size: 13px; color: var(--vc-text); cursor: pointer;
  display: none; animation: vc-slide 0.4s ease;
}
.vc-prompt.show { display: block; }
.vc-prompt::after {
  content: ''; position: absolute; bottom: -6px; right: 28px;
  width: 12px; height: 12px; background: white; transform: rotate(45deg);
}
.vc-prompt-close {
  position: absolute; top: 6px; right: 8px; background: none; border: 0;
  font-size: 16px; color: #999; cursor: pointer; line-height: 1;
}
@keyframes vc-slide { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.vc-window {
  position: fixed; bottom: 20px; right: 20px; z-index: 9991;
  width: 370px; height: 580px; max-height: calc(100vh - 40px);
  background: white; border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
  display: none; flex-direction: column; overflow: hidden;
  animation: vc-pop 0.25s ease;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.vc-window.open { display: flex; }
@keyframes vc-pop { from { opacity: 0; transform: translateY(20px) scale(.96); } to { opacity: 1; transform: translateY(0) scale(1); } }

.vc-header {
  background: var(--vc-brand); color: white;
  padding: 14px 16px; display: flex; align-items: center; gap: 12px; flex-shrink: 0;
}
.vc-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: white; display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.vc-header-info { flex: 1; min-width: 0; }
.vc-header-name { font-weight: 600; font-size: 14px; }
.vc-header-status { font-size: 11px; opacity: .9; display: flex; align-items: center; gap: 5px; }
.vc-header-status::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%; background: #5fffae;
  box-shadow: 0 0 6px #5fffae;
}
.vc-close {
  background: rgba(255,255,255,.15); color: white; border: 0;
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  font-size: 18px; line-height: 1; display: flex; align-items: center; justify-content: center;
}

.vc-body { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 16px 14px; background: #fafbfc; display: flex; flex-direction: column; gap: 10px; }
.vc-msg { display: flex; gap: 8px; max-width: 92%; min-width: 0; }
.vc-msg.bot { align-self: flex-start; }
.vc-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.vc-msg-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--vc-brand);
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 14px; flex-shrink: 0;
}
.vc-msg.user .vc-msg-avatar { display: none; }
.vc-bubble { padding: 10px 13px; border-radius: 14px; font-size: 14px; line-height: 1.4; word-wrap: break-word; min-width: 0; overflow: hidden; box-sizing: border-box; }
.vc-msg.bot .vc-bubble { background: var(--vc-bot-bg); color: var(--vc-text); border-bottom-left-radius: 4px; }
.vc-msg.user .vc-bubble { background: var(--vc-user-bg); color: var(--vc-user-color); border-bottom-right-radius: 4px; }
.vc-bubble a { color: inherit; text-decoration: underline; }
.vc-msg.user .vc-bubble a { color: white; }
.vc-bubble ol, .vc-bubble ul { margin: 6px 0; padding-left: 20px; }
.vc-bubble li { margin: 2px 0; }

.vc-feedback { margin-top: 6px; display: flex; gap: 4px; }
.vc-fb-btn {
  background: none; border: 1px solid rgba(0,0,0,.1); border-radius: 12px;
  font-size: 13px; line-height: 1; padding: 3px 8px; cursor: pointer; opacity: .55;
}
.vc-fb-btn:hover { opacity: 1; background: rgba(0,0,0,.04); }
.vc-fb-thanks { font-size: 11px; color: #888; }

.vc-cta-btn {
  display: inline-block; margin-top: 6px; padding: 8px 14px;
  background: var(--vc-brand); color: white !important; text-decoration: none;
  border-radius: 6px; font-size: 13px; font-weight: 600;
}
.vc-cta-btn:hover { background: var(--vc-brand-dark); }

.vc-product-list { margin-top: 4px; display: flex; flex-direction: column; gap: 5px; width: 100%; box-sizing: border-box; }
.vc-product {
  display: flex; align-items: center; gap: 8px;
  background: white; padding: 6px 8px; border-radius: 8px;
  border: 1px solid var(--vc-border); text-decoration: none; color: var(--vc-text); font-size: 12px;
  transition: border-color .15s ease; width: 100%; box-sizing: border-box; min-width: 0;
}
.vc-product:hover { border-color: var(--vc-brand); transform: translateX(2px); }
.vc-product-thumb {
  width: 36px; height: 36px; border-radius: 5px; object-fit: cover;
  flex-shrink: 0; background: #f0f0f0;
}
.vc-product-emoji {
  font-size: 22px; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.vc-product-info { flex: 1; min-width: 0; }
.vc-product-name { font-weight: 600; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vc-product-meta { font-size: 11px; color: #888; margin-top: 2px; }
.vc-product-price { font-size: 12px; color: var(--vc-brand); font-weight: 600; margin-top: 2px; }

.vc-typing { display: inline-flex; gap: 3px; padding: 4px 0; }
.vc-typing span {
  width: 7px; height: 7px; border-radius: 50%; background: #aaa;
  animation: vc-bounce 1.2s infinite ease-in-out;
}
.vc-typing span:nth-child(2) { animation-delay: .15s; }
.vc-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes vc-bounce { 0%,80%,100% { transform: scale(.6); opacity: .5; } 40% { transform: scale(1); opacity: 1; } }

.vc-quick {
  padding: 8px 14px 4px; display: flex; flex-wrap: wrap; gap: 6px;
  border-top: 1px solid var(--vc-border); background: white;
}
.vc-chip {
  background: white; border: 1px solid var(--vc-brand); color: var(--vc-brand);
  padding: 6px 11px; border-radius: 16px; font-size: 12px; cursor: pointer; white-space: nowrap;
}
.vc-chip:hover { background: var(--vc-brand); color: white; }

.vc-leadform {
  margin: 6px 0; padding: 14px; background: white;
  border: 1px solid var(--vc-border); border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.vc-leadform-title { font-weight: 600; font-size: 13px; color: #2b2b2b; margin-bottom: 4px; }
.vc-leadform-intro { font-size: 12px; color: #666; margin-bottom: 10px; line-height: 1.4; }
.vc-leadform label { font-size: 11px; color: #555; display: block; margin: 8px 0 3px; font-weight: 600; }
.vc-leadform label .vc-req { color: #d33; }
.vc-leadform input, .vc-leadform textarea, .vc-leadform select {
  width: 100%; padding: 8px 10px; border: 1px solid #ddd; border-radius: 5px;
  font-size: 13px; font-family: inherit; outline: none; box-sizing: border-box;
}
.vc-leadform input:focus, .vc-leadform textarea:focus, .vc-leadform select:focus { border-color: var(--vc-brand); }
.vc-leadform select { background: #fff; }
.vc-leadform textarea { resize: vertical; min-height: 70px; }
.vc-leadform .vc-error { color: #d33; font-size: 11px; margin-top: 4px; min-height: 14px; }
.vc-leadform button {
  margin-top: 12px; width: 100%; padding: 10px; background: var(--vc-brand);
  color: white; border: 0; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.vc-leadform button:hover { background: var(--vc-brand-dark); }

.vc-input-wrap {
  border-top: 1px solid var(--vc-border); padding: 10px 12px;
  background: white; display: flex; gap: 8px; align-items: center; flex-shrink: 0;
}
.vc-input {
  flex: 1; border: 1px solid var(--vc-border); border-radius: 18px;
  padding: 9px 14px; font-size: 14px; font-family: inherit; outline: none;
}
.vc-input:focus { border-color: var(--vc-brand); }
.vc-send {
  background: var(--vc-brand); color: white; border: 0; border-radius: 50%;
  width: 36px; height: 36px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.vc-send svg { width: 16px; height: 16px; fill: white; }

.vc-foot { text-align: center; font-size: 10px; color: #999; padding: 4px 0 6px; background: white; border-top: 1px solid #f0f0f0; }

@media (max-width: 480px) {
  .vc-window {
    width: 100%; height: 100%; height: 100dvh;
    max-height: 100%; bottom: 0; right: 0; border-radius: 0;
  }
  .vc-launcher {
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    right: 16px; width: 56px; height: 56px;
  }
  .vc-prompt {
    right: 16px;
    bottom: calc(84px + env(safe-area-inset-bottom, 0px));
    max-width: 220px;
  }
  /* Prevent iOS Safari from zooming in when input is tapped */
  .vc-input { font-size: 16px; }
  /* Allow product names to wrap on narrow screens instead of truncating */
  .vc-product-name { white-space: normal; }
  /* Bigger touch targets for quick-reply chips */
  .vc-chip { min-height: 36px; display: inline-flex; align-items: center; }
}

/* ── Product wrap: stock notice + add-to-cart ───────────────────────── */
.vc-product-wrap { display: flex; flex-direction: column; margin-bottom: 0; width: 100%; box-sizing: border-box; }
.vc-product-wrap .vc-product { border-radius: 8px 8px 0 0; margin-bottom: 0; border-bottom: none; }
.vc-stock-notice {
  background: #c0392b; color: #fff; font-size: 11px; font-weight: 700;
  padding: 3px 10px; border-radius: 6px 6px 0 0; text-align: center; letter-spacing: .02em;
}
.vc-stock-notice + .vc-product { border-radius: 0; }
.vc-add-to-cart {
  display: block; text-align: center; background: var(--vc-brand); color: #fff !important;
  padding: 5px 10px; font-size: 11px; font-weight: 700; text-decoration: none;
  border-radius: 0 0 8px 8px; transition: background .15s; letter-spacing: .02em;
  border: 1px solid var(--vc-brand); border-top: none; box-sizing: border-box; width: 100%;
}
.vc-add-to-cart:hover { background: var(--vc-brand-dark); border-color: var(--vc-brand-dark); }
