/* ============================================================
   CHARIS AI CHAT WIDGET — Zohar I.T. Solutions
   ============================================================ */

/* ── Floating trigger button ── */
#charis-trigger {
  position: fixed;
  bottom: 104px; right: 28px;
  z-index: 9000;
  width: 60px; height: 60px;
  border-radius: 50%;
  background: var(--gradient, linear-gradient(135deg, #0057ff, #00d4ff));
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 28px rgba(0,87,255,0.45);
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.3s ease;
  font-family: 'Fira Sans', sans-serif;
}
[data-theme="green"] #charis-trigger { box-shadow: 0 6px 28px rgba(22,163,74,0.45); }
#charis-trigger:hover { transform: scale(1.08); box-shadow: 0 8px 36px rgba(0,87,255,0.60); }
[data-theme="green"] #charis-trigger:hover { box-shadow: 0 8px 36px rgba(22,163,74,0.60); }
#charis-trigger .ct-icon { font-size: 1.4rem; color: #fff; transition: transform 0.3s ease; }
#charis-trigger .ct-close { display: none; font-size: 1.2rem; color: #fff; transition: transform 0.3s ease; }
#charis-trigger.open .ct-icon  { display: none; }
#charis-trigger.open .ct-close { display: block; }

/* Pulse ring on trigger */
#charis-trigger::before {
  content: '';
  position: absolute; inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(0,87,255,0.35);
  animation: charis-ring-pulse 2.5s ease-in-out infinite;
}
[data-theme="green"] #charis-trigger::before { border-color: rgba(22,163,74,0.35); }
@keyframes charis-ring-pulse { 0%,100%{transform:scale(1);opacity:0.7} 50%{transform:scale(1.15);opacity:0.2} }

/* Unread badge */
#charis-badge {
  position: absolute; top: -4px; right: -4px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #ef4444; color: white;
  font-size: 0.68rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--dark, #050d1a);
  animation: badge-pop 0.3s cubic-bezier(0.34,1.56,0.64,1) forwards;
}
@keyframes badge-pop { from{transform:scale(0)} to{transform:scale(1)} }

/* ── Chat window ── */
#charis-window {
  position: fixed;
  bottom: 176px; right: 28px;
  z-index: 8999;
  width: 380px; max-width: calc(100vw - 40px);
  height: 540px; max-height: calc(100vh - 140px);
  background: var(--dark-card, #0d1b35);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 20px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.55);
  display: flex; flex-direction: column;
  overflow: hidden;
  opacity: 0; transform: translateY(20px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
  font-family: 'Fira Sans', sans-serif;
}
#charis-window.open {
  opacity: 1; transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ── Header ── */
.charis-header {
  background: var(--gradient, linear-gradient(135deg,#0057ff,#00d4ff));
  padding: 16px 20px;
  display: flex; align-items: center; gap: 12px;
  flex-shrink: 0;
}
.charis-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; color: white; flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.3);
}
.charis-header-info { flex: 1; }
.charis-header-info strong { display: block; color: #fff; font-size: 0.95rem; font-weight: 700; }
.charis-header-info span { font-size: 0.75rem; color: rgba(255,255,255,0.80); display: flex; align-items: center; gap: 5px; }
.charis-header-info span::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #4ade80; display: inline-block; animation: charis-ring-pulse 2s infinite; }
.charis-header-actions { display: flex; gap: 6px; }
.charis-hbtn {
  width: 30px; height: 30px; border-radius: 8px;
  background: rgba(255,255,255,0.15); border: none; cursor: pointer;
  color: white; font-size: 0.82rem;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s ease; font-family: inherit;
}
.charis-hbtn:hover { background: rgba(255,255,255,0.25); }

/* ── Visitor gate (name/email required before first use each session) ── */
.charis-gate {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center;
  padding: 28px 24px; gap: 4px; overflow-y: auto;
}
.charis-gate-icon {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--gradient, linear-gradient(135deg,#0057ff,#00d4ff));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; color: #fff; margin-bottom: 10px;
}
.charis-gate-title { color: #fff; font-size: 1.05rem; font-weight: 700; margin: 0 0 6px; }
.charis-gate-desc { color: rgba(255,255,255,0.55); font-size: 0.82rem; line-height: 1.55; margin: 0 0 18px; max-width: 300px; }
.charis-gate-input {
  width: 100%; max-width: 280px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 10px; padding: 11px 14px;
  color: white; font-size: 0.88rem; font-family: inherit;
  outline: none; margin-bottom: 10px; transition: border 0.2s ease;
}
.charis-gate-input:focus { border-color: rgba(0,87,255,0.55); }
[data-theme="green"] .charis-gate-input:focus { border-color: rgba(22,163,74,0.55); }
.charis-gate-input::placeholder { color: rgba(255,255,255,0.30); }
.charis-gate-error {
  width: 100%; max-width: 280px;
  color: #f87171; font-size: 0.78rem; text-align: left;
  margin: -2px 0 10px;
}
.charis-gate-btn {
  width: 100%; max-width: 280px;
  background: var(--gradient, linear-gradient(135deg,#0057ff,#00d4ff));
  border: none; border-radius: 10px; padding: 12px 14px;
  color: #fff; font-size: 0.9rem; font-weight: 700; font-family: inherit;
  cursor: pointer; margin-top: 4px; transition: transform 0.15s ease, opacity 0.15s ease;
}
.charis-gate-btn:hover:not(:disabled) { transform: translateY(-1px); }
.charis-gate-btn:disabled { opacity: 0.6; cursor: default; }
.charis-gate-privacy {
  font-size: 0.7rem; color: rgba(255,255,255,0.30);
  max-width: 280px; margin: 14px 0 0; line-height: 1.5;
}
.charis-gate-privacy a { color: rgba(255,255,255,0.45); }

/* ── Messages area ── */
.charis-messages {
  flex: 1; overflow-y: auto;
  padding: 20px 16px; display: flex; flex-direction: column;
  gap: 14px; scroll-behavior: smooth;
}
.charis-messages::-webkit-scrollbar { width: 4px; }
.charis-messages::-webkit-scrollbar-track { background: transparent; }
.charis-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.10); border-radius: 2px; }

/* Message bubbles */
.cm-row {
  display: flex; align-items: flex-end; gap: 8px;
  animation: cm-in 0.25s ease forwards;
}
@keyframes cm-in { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }
.cm-row.user { flex-direction: row-reverse; }
.cm-avatar-sm {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; color: white;
}
.cm-avatar-sm.agent-av { background: var(--gradient, linear-gradient(135deg,#0057ff,#00d4ff)); }
.cm-avatar-sm.user-av  { background: rgba(255,255,255,0.12); font-size: 0.65rem; }

.cm-bubble {
  max-width: 78%; padding: 10px 14px;
  border-radius: 16px; font-size: 0.88rem; line-height: 1.55;
  word-break: break-word;
}
.cm-bubble.agent {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.10);
  color: rgba(255,255,255,0.90);
  border-bottom-left-radius: 4px;
}
.cm-bubble.user {
  background: var(--gradient, linear-gradient(135deg,#0057ff,#00d4ff));
  color: white; border-bottom-right-radius: 4px;
}
.cm-bubble strong { color: white; }
.cm-bubble a { color: var(--accent, #00d4ff); text-decoration: underline; }
.cm-bubble ul { margin: 6px 0 2px 16px; }
.cm-bubble li { margin-bottom: 3px; }
.cm-time {
  font-size: 0.68rem; color: rgba(255,255,255,0.35);
  margin-top: 4px; text-align: right; padding: 0 4px;
}

/* Typing indicator */
.cm-typing {
  display: flex; align-items: flex-end; gap: 8px;
}
.typing-dots {
  display: flex; align-items: center; gap: 4px;
  padding: 12px 16px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 16px; border-bottom-left-radius: 4px;
}
.typing-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: rgba(255,255,255,0.45);
  animation: typing-bounce 1.2s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-6px)} }

/* Quick replies */
.charis-quick-replies {
  padding: 0 16px 12px;
  display: flex; flex-wrap: wrap; gap: 7px;
  flex-shrink: 0;
}
.charis-qr {
  padding: 7px 14px; border-radius: 20px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.75); font-size: 0.78rem; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: all 0.2s ease;
}
.charis-qr:hover {
  background: rgba(0,87,255,0.15);
  border-color: rgba(0,87,255,0.40);
  color: #fff;
}
[data-theme="green"] .charis-qr:hover { background: rgba(22,163,74,0.15); border-color: rgba(22,163,74,0.40); }

/* ── Input area ── */
.charis-input-area {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex; gap: 10px; align-items: flex-end;
  flex-shrink: 0; background: rgba(0,0,0,0.15);
}
.charis-textarea {
  flex: 1; background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px; padding: 10px 14px;
  color: white; font-size: 0.88rem; font-family: inherit;
  outline: none; resize: none; line-height: 1.5;
  max-height: 100px; overflow-y: auto;
  transition: border 0.2s ease;
  min-height: 42px;
}
.charis-textarea:focus { border-color: rgba(0,87,255,0.50); }
[data-theme="green"] .charis-textarea:focus { border-color: rgba(22,163,74,0.50); }
.charis-textarea::placeholder { color: rgba(255,255,255,0.30); }
.charis-send-btn {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  background: var(--gradient, linear-gradient(135deg,#0057ff,#00d4ff));
  border: none; cursor: pointer; color: white; font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.2s, opacity 0.2s;
}
.charis-send-btn:hover { transform: scale(1.07); }
.charis-send-btn:disabled { opacity: 0.4; cursor: default; transform: none; }

/* ── Powered-by footer ── */
.charis-footer {
  padding: 8px 16px;
  text-align: center;
  font-size: 0.68rem; color: rgba(255,255,255,0.25);
  border-top: 1px solid rgba(255,255,255,0.05);
  flex-shrink: 0;
}
.charis-footer a { color: rgba(255,255,255,0.35); }

/* ── Mobile ── */
@media (max-width: 480px) {
  #charis-window { right: 12px; bottom: 162px; width: calc(100vw - 24px); }
  #charis-trigger { right: 20px; bottom: 96px; }
}
