/* ================================================================
   VITA AI ASSISTANT — vita.css
   WordPress / WooCommerce / Astra Theme compatible
   All selectors scoped under #vita-container or #vita-backdrop
   ================================================================ */

/* ── Google Fonts are enqueued via PHP ── */

/* ── Reset inside Vita only ── */
#vita-container,
#vita-container * {
  box-sizing: border-box;
  font-family: 'Nunito', sans-serif;
}

/* ── Fixed container — DEFAULT: bottom-left ── */
#vita-container {
  position: fixed !important;
  z-index: 999999 !important;
  bottom: 24px;
  left: 24px;
  right: auto;
  user-select: none;
  overflow: visible !important;
}
/* right-position variant */
#vita-container.vita-pos-right {
  left: auto;
  right: 24px;
}

/* Chat window — адаптивний розмір через clamp() */
#vita-window {
  /* Ширина: мін 280px, бажана 22vw, макс 340px */
  width: clamp(320px, 25vw, 375px);
  /* Висота: мін 400px, бажана 55vh, макс 520px */
  height: clamp(450px, 58vh, 555px);
  background: linear-gradient(170deg,#f4fcf5 0%,#eaf7eb 30%,#f0f8ff 100%);
  border-radius: 24px;
  box-shadow: 0 20px 80px rgba(93,158,97,0.25), 0 4px 20px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(125,186,132,0.25);
  position: fixed;
  bottom: 96px;
  left: 24px;
  right: auto;
  transform-origin: bottom left;
  transform: scale(0) translateY(20px);
  opacity: 0;
  transition: transform .4s cubic-bezier(0.34,1.56,0.64,1), opacity .3s ease;
  pointer-events: none;
  cursor: default;
  z-index: 999999 !important;
}
/* right-position variant */
#vita-container.vita-pos-right #vita-window {
  left: auto;
  right: 24px;
  transform-origin: bottom right;
}
#vita-bubble {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--vita-color, #7dba84) 0%, var(--vita-color-dark, #5a9e61) 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(93,158,97,0.45);
  transition: transform .3s cubic-bezier(0.34,1.56,0.64,1), box-shadow .3s;
  animation: vita-pulse 2.5s ease-in-out infinite;
  position: relative;
  outline: none;
}
#vita-bubble:hover,
#vita-bubble:focus {
  transform: scale(1.1);
  box-shadow: 0 12px 40px rgba(93,158,97,0.55);
}
#vita-bubble svg {
  width: 32px;
  height: 32px;
  fill: white;
  pointer-events: none;
}

.vita-notif {
  position: absolute;
  top: -4px; right: -4px;
  width: 20px; height: 20px;
  background: #ff7b7b;
  border-radius: 50%;
  border: 2px solid white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  color: white;
  animation: vita-notif-bounce 1s ease-in-out infinite alternate;
}

@keyframes vita-pulse {
  0%,100% { box-shadow: 0 8px 32px rgba(93,158,97,0.45), 0 0 0 0 rgba(125,186,132,0.4); }
  50%      { box-shadow: 0 8px 32px rgba(93,158,97,0.45), 0 0 0 12px rgba(125,186,132,0); }
}
@keyframes vita-notif-bounce {
  from { transform: scale(1); }
  to   { transform: scale(1.2); }
}

#vita-window.vita-open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}
#vita-window.vita-minimized { height: 70px; }
#vita-window.vita-minimized .vita-messages,
#vita-window.vita-minimized .vita-input-area { display: none; }

/* Window is fixed — no drag */
#vita-window { cursor: default; }
#vita-window .vita-input   { cursor: text !important; }
#vita-window .vita-send,
#vita-window .vita-btn,
#vita-window .vita-chip,
#vita-window .vita-product-card,
#vita-window .vita-product-card-btn,
#vita-window a              { cursor: pointer !important; }

/* ── Header ── */
.vita-header {
  background: linear-gradient(135deg, var(--vita-color, #7dba84) 0%, var(--vita-color-mid, #58a860) 50%, var(--vita-color-deep, #4a9e6a) 100%);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 28px 28px 0 0;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.vita-header:active { cursor: grabbing; }
.vita-header::before {
  content: '';
  position: absolute;
  top: -30px; right: -30px;
  width: 100px; height: 100px;
  background: rgba(255,255,255,0.1);
  border-radius: 50%;
  pointer-events: none;
}
.vita-header::after {
  content: '';
  position: absolute;
  bottom: -20px; left: 30%;
  width: 80px; height: 80px;
  background: rgba(255,255,255,0.06);
  border-radius: 50%;
  pointer-events: none;
}

.vita-avatar {
  width: 44px; height: 44px;
  background: rgba(255,255,255,0.25);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  border: 2px solid rgba(255,255,255,0.4);
  position: relative; z-index: 1;
  flex-shrink: 0;
}
.vita-header-info {
  flex: 1;
  position: relative; z-index: 1;
  min-width: 0;
}
.vita-name {
  color: white;
  font-family: 'Quicksand', sans-serif;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}
.vita-status {
  display: flex; align-items: center; gap: 6px;
  margin-top: 4px;
}
.vita-status-dot {
  width: 8px; height: 8px;
  background: #b8f5be;
  border-radius: 50%;
  flex-shrink: 0;
  animation: vita-status-blink 2s ease-in-out infinite;
  transition: background .4s;
}
@keyframes vita-status-blink {
  0%,100% { opacity: 1; transform: scale(1); }
  50%     { opacity: 0.6; transform: scale(0.8); }
}
.vita-status-text {
  color: rgba(255,255,255,0.9);
  font-size: 12px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.vita-header-actions {
  display: flex; gap: 8px;
  position: relative; z-index: 1;
  flex-shrink: 0;
}
.vita-btn {
  width: 32px; height: 32px;
  background: rgba(255,255,255,0.2);
  border: none; border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s, transform .2s;
  color: white;
  padding: 0;
}
.vita-btn:hover {
  background: rgba(255,255,255,0.35);
  transform: scale(1.1);
}
.vita-btn:focus { outline: 2px solid rgba(255,255,255,0.6); }
.vita-btn svg { width: 16px; height: 16px; pointer-events: none; }

/* ── Messages ── */
.vita-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.vita-messages::-webkit-scrollbar { width: 4px; }
.vita-messages::-webkit-scrollbar-track { background: transparent; }
.vita-messages::-webkit-scrollbar-thumb { background: rgba(125,186,132,0.3); border-radius: 4px; }

/* Welcome card */
.vita-welcome {
  background: linear-gradient(135deg,rgba(125,186,132,0.15),rgba(168,224,168,0.1));
  border: 1px solid rgba(125,186,132,0.25);
  border-radius: 20px;
  padding: 16px;
  text-align: center;
  animation: vita-msg-in .4s cubic-bezier(0.34,1.56,0.64,1);
}
.vita-welcome-emoji { font-size: 32px; margin-bottom: 8px; }
.vita-welcome h3 {
  font-family: 'Quicksand', sans-serif;
  font-size: 16px; color: #3a7a42; font-weight: 700; margin: 0 0 6px;
}
.vita-welcome p { font-size: 12px; color: #6a8a6e; line-height: 1.5; margin: 0; }

/* Quick chips */
.vita-chips {
  display: flex; flex-wrap: wrap; gap: 8px;
  animation: vita-msg-in .4s cubic-bezier(0.34,1.56,0.64,1) .1s both;
}
.vita-chip {
  background: white;
  border: 1.5px solid rgba(125,186,132,0.4);
  color: #3a7a42;
  font-family: 'Nunito', sans-serif;
  font-size: 12px; font-weight: 600;
  padding: 7px 14px;
  border-radius: 50px;
  cursor: pointer;
  transition: all .2s;
  box-shadow: 0 2px 8px rgba(125,186,132,0.1);
}
.vita-chip:hover {
  background: linear-gradient(135deg,#7dba84,#5a9e61);
  color: white;
  border-color: transparent;
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(93,158,97,0.3);
}

/* Message bubbles */
.vita-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: vita-msg-in .35s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes vita-msg-in {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.vita-msg.vita-user { align-self: flex-end; align-items: flex-end; }
.vita-msg.vita-bot  { align-self: flex-start; align-items: flex-start; }

.vita-msg-bubble {
  padding: 12px 16px;
  border-radius: 20px;
  font-size: 13.5px;
  line-height: 1.6;
  word-break: break-word;
  margin: 0;
}
.vita-msg.vita-user .vita-msg-bubble {
  background: linear-gradient(135deg,#7dba84 0%,#5a9e61 100%);
  color: white;
  border-radius: 20px 20px 6px 20px;
  box-shadow: 0 4px 16px rgba(93,158,97,0.3);
}
.vita-msg.vita-bot .vita-msg-bubble {
  background: white;
  color: #3a4a3e;
  border-radius: 20px 20px 20px 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  border: 1px solid rgba(125,186,132,0.15);
}
.vita-msg-time {
  font-size: 10px; color: #a0b4a4;
  margin-top: 4px; padding: 0 4px;
}

/* Product card in chat */
.vita-product-card {
  background: white;
  border-radius: 16px;
  padding: 14px;
  border: 1px solid rgba(125,186,132,0.2);
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  margin-top: 4px;
  transition: transform .2s, box-shadow .2s;
  max-width: 290px;
  text-decoration: none !important;
  display: block;
}
.vita-product-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(93,158,97,0.15);
  text-decoration: none !important;
}
.vita-product-card-inner { display: flex; flex-direction: column; gap: 8px; }
.vita-product-card-header { display: flex; align-items: center; gap: 10px; }
.vita-product-card-img {
  width: 48px; height: 48px;
  border-radius: 10px;
  object-fit: cover;
  background: #f0f8f0;
  flex-shrink: 0;
}
.vita-product-card-emoji { font-size: 30px; flex-shrink: 0; }
.vita-product-card-name {
  font-family: 'Quicksand', sans-serif;
  font-size: 14px; font-weight: 700; color: #3a4a3e;
  margin: 0;
}
.vita-product-card-price {
  font-size: 15px; font-weight: 800; color: #4a9a52;
  margin: 0;
}
.vita-product-card-desc {
  font-size: 11px; color: #7a9a7e;
  line-height: 1.4; margin: 0;
}
.vita-product-card-stock {
  font-size: 11px; font-weight: 700;
  color: #3a9a42;
}
.vita-product-card-stock.vita-out { color: #c05050; }
.vita-product-card-btn {
  width: 100%; padding: 8px;
  background: linear-gradient(135deg,#7dba84,#5a9e61);
  color: white; border: none; border-radius: 10px;
  font-family: 'Nunito', sans-serif;
  font-size: 12px; font-weight: 700;
  cursor: pointer;
  transition: opacity .2s;
  text-align: center;
}
.vita-product-card-btn:hover { opacity: 0.85; }

/* Typing indicator */
.vita-typing {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  background: white;
  border-radius: 20px 20px 20px 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  border: 1px solid rgba(125,186,132,0.15);
  align-self: flex-start;
  animation: vita-msg-in .3s ease;
  max-width: 80px;
}
.vita-typing-dot {
  width: 8px; height: 8px;
  background: linear-gradient(135deg,#7dba84,#5a9e61);
  border-radius: 50%;
  animation: vita-typing-anim 1.2s ease-in-out infinite;
}
.vita-typing-dot:nth-child(2) { animation-delay: .2s; }
.vita-typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes vita-typing-anim {
  0%,100% { transform: translateY(0); opacity: 0.5; }
  50%     { transform: translateY(-6px); opacity: 1; }
}

/* Searching indicator */
.vita-searching {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  background: rgba(125,186,132,0.1);
  border: 1px solid rgba(125,186,132,0.25);
  border-radius: 50px;
  align-self: flex-start;
  font-size: 11px; color: #5a8a5e; font-weight: 600;
  animation: vita-msg-in .3s ease;
}
.vita-searching-icon {
  width: 14px; height: 14px;
  border: 2px solid #7dba84;
  border-top-color: transparent;
  border-radius: 50%;
  animation: vita-spin .8s linear infinite;
}
@keyframes vita-spin { to { transform: rotate(360deg); } }

/* Input area */
.vita-input-area {
  padding: 16px;
  background: rgba(255,255,255,0.7);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(125,186,132,0.15);
  flex-shrink: 0;
}
.vita-input-row { display: flex; gap: 10px; align-items: flex-end; }
.vita-input {
  flex: 1;
  background: white;
  border: 1.5px solid rgba(125,186,132,0.3) !important;
  border-radius: 20px !important;
  padding: 12px 16px;
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  color: #3a4a3e;
  resize: none;
  outline: none !important;
  min-height: 44px;
  max-height: 100px;
  line-height: 1.5;
  transition: border-color .2s, box-shadow .2s;
  box-shadow: 0 2px 10px rgba(0,0,0,0.04) !important;
  overflow-y: auto;
}
.vita-input:focus {
  border-color: #7dba84 !important;
  box-shadow: 0 0 0 4px rgba(125,186,132,0.12) !important;
}
.vita-input::placeholder { color: #a0b4a4; }
.vita-send {
  width: 44px; height: 44px; flex-shrink: 0;
  background: linear-gradient(135deg,#7dba84,#5a9e61);
  border: none; border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(93,158,97,0.35);
  transition: transform .2s cubic-bezier(0.34,1.56,0.64,1), box-shadow .2s;
  padding: 0;
}
.vita-send:hover  { transform: scale(1.1); box-shadow: 0 6px 20px rgba(93,158,97,0.5); }
.vita-send:active { transform: scale(0.95); }
.vita-send svg { width: 18px; height: 18px; fill: white; pointer-events: none; }
.vita-input-hint { font-size: 10px; color: #a0b4a4; text-align: center; margin-top: 8px; }

/* Drag cursor */
.vita-is-dragging,
.vita-is-dragging * { cursor: grabbing !important; }

/* ── Backdrop (mobile) ── */
#vita-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(30,50,32,0.35);
  backdrop-filter: blur(3px);
  z-index: 999998;
  opacity: 0;
  transition: opacity .3s ease;
  pointer-events: none;
}
#vita-backdrop.vita-active {
  opacity: 1;
  pointer-events: all;
}

/* ══════════════════════════════════════════════════════
   АДАПТИВНІСТЬ
   Базовий розмір задано через clamp() вище.
   Тут тільки крайні випадки — дуже малі екрани і мобільні.
   ══════════════════════════════════════════════════════ */

/* ── Маленькі ноутбуки де браузер перекриває кнопки ── */
/* Екрани < 800px висотою — зменшуємо висоту вікна */
@media (max-height: 700px) and (min-width: 481px) {
  #vita-window {
    height: clamp(320px, 70vh, 440px) !important;
    bottom: 90px !important;
  }
}

/* ── Мобільні (ширина ≤ 480px) ── */
@media (max-width: 480px) {
  #vita-container {
    bottom: 16px !important;
    left: 12px !important;
    right: auto !important;
  }
  #vita-container.vita-pos-right {
    left: auto !important;
    right: 12px !important;
  }

  #vita-bubble { width: 52px; height: 52px; }
  #vita-bubble svg { width: 26px; height: 26px; }

  #vita-window {
    position: fixed !important;
    bottom: 78px !important;
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
    height: clamp(360px, 62dvh, 520px) !important;
    border-radius: 20px !important;
    transform-origin: bottom left !important;
  }
  #vita-container.vita-pos-right #vita-window {
    transform-origin: bottom right !important;
  }
  #vita-window.vita-open {
    transform: scale(1) translateY(0) !important;
    opacity: 1 !important;
    pointer-events: all !important;
  }
  #vita-window.vita-minimized { height: 58px !important; }

  .vita-avatar { width: 34px; height: 34px; font-size: 16px; }
  .vita-name   { font-size: 14px; }
  .vita-status-text { font-size: 10px; }
  .vita-messages { padding: 10px 10px; gap: 8px; }
  .vita-msg-bubble { font-size: 13px; padding: 9px 12px; }
  .vita-product-card { max-width: 100%; }
  .vita-chips { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .vita-chips::-webkit-scrollbar { display: none; }
  .vita-chip { flex-shrink: 0; font-size: 11px; padding: 5px 10px; }
  .vita-input-area { padding: 8px 10px 12px; }
  .vita-input  { font-size: 15px; padding: 8px 12px; }
  .vita-send   { width: 38px; height: 38px; }
  .vita-input-hint { font-size: 9px; }
  #vita-backdrop { display: block; }
}

/* ── Streaming cursor ─────────────────────────────── */
.vita-cursor {
  display: inline-block;
  animation: vita-blink .7s step-end infinite;
  color: var(--vita-color);
  font-weight: bold;
  margin-left: 1px;
}
@keyframes vita-blink { 0%,100%{opacity:1} 50%{opacity:0} }

.vita-msg-bubble.vita-streaming {
  min-width: 40px;
  min-height: 20px;
}

/* ── Profile badge ────────────────────────────────── */
.vita-profile-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 6px 12px;
  padding: 7px 12px;
  background: linear-gradient(135deg, #e8f5e9, #f1f8e9);
  border-left: 3px solid var(--vita-color);
  border-radius: 8px;
  font-size: 12px;
  color: #2e7d32;
  font-weight: 500;
  opacity: 1;
  transition: opacity 0.8s ease;
}
.vita-profile-badge.vita-badge-fade {
  opacity: 0;
}
