/* ============================================================
   CoreDrishti AI — Chatbot Widget Styles
   Brand: Teal #1F6F5C · Gold #D9A53B · Warm white
   Premium animations: float launcher, smooth panel, typing dots,
   message slide-in. Fully responsive.
   ============================================================ */

#cdai-root {
  --cd-teal: #1F6F5C;
  --cd-teal-dark: #155244;
  --cd-teal-light: #2E9579;
  --cd-gold: #D9A53B;
  --cd-gold-dark: #B8862A;
  --cd-ink: #2B2722;
  --cd-ink-soft: #5A554E;
  --cd-bg: #FAFAF9;
  --cd-line: #E7E6E2;
  --cd-font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-family: var(--cd-font);
}

/* ---------- Launcher button ---------- */
#cdai-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  z-index: 99998;
  background: linear-gradient(135deg, var(--cd-teal), var(--cd-teal-dark));
  box-shadow: 0 12px 30px rgba(31, 111, 92, 0.42), 0 4px 10px rgba(0,0,0,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: cdai-float 3.6s ease-in-out infinite;
  transition: transform 0.35s cubic-bezier(0.22,1,0.36,1), box-shadow 0.35s ease;
}
#cdai-launcher:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 18px 38px rgba(31, 111, 92, 0.5);
}
#cdai-launcher:active { transform: scale(0.96); }

.cdai-launch-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--cd-teal);
  opacity: 0.55;
  z-index: -1;
  animation: cdai-pulse 2.4s ease-out infinite;
}

.cdai-launch-icon {
  color: var(--cd-gold);
  font-size: 1.7rem;
  line-height: 1;
  transition: opacity 0.25s ease, transform 0.4s ease;
}
.cdai-launch-close {
  position: absolute;
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  opacity: 0;
  transform: rotate(-90deg) scale(0.4);
  transition: opacity 0.25s ease, transform 0.4s cubic-bezier(0.22,1,0.36,1);
}
#cdai-launcher.active .cdai-launch-icon { opacity: 0; transform: scale(0.4); }
#cdai-launcher.active .cdai-launch-close { opacity: 1; transform: rotate(0) scale(1); }
#cdai-launcher.active .cdai-launch-pulse { display: none; }

@keyframes cdai-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}
@keyframes cdai-pulse {
  0% { transform: scale(1); opacity: 0.5; }
  70% { transform: scale(1.8); opacity: 0; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* ---------- Launcher label / tooltip ---------- */
.cdai-tip {
  position: fixed;
  bottom: 40px;
  right: 100px;
  z-index: 99998;
  background: #fff;
  color: var(--cd-ink);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 10px 32px 10px 15px;
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(43,39,34,0.18);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transform: translateX(14px) scale(0.92);
  transform-origin: right center;
  transition: opacity 0.4s ease, transform 0.45s cubic-bezier(0.22,1,0.36,1), visibility 0.4s;
  pointer-events: none;
}
.cdai-tip strong { color: var(--cd-teal); font-weight: 700; }
/* little pointer arrow toward the button */
.cdai-tip::after {
  content: '';
  position: absolute;
  right: -7px;
  top: 50%;
  transform: translateY(-50%) rotate(45deg);
  width: 14px; height: 14px;
  background: #fff;
  border-radius: 2px;
}
.cdai-tip.cdai-show {
  opacity: 1;
  visibility: visible;
  transform: translateX(0) scale(1);
  pointer-events: auto;
  cursor: pointer;
  animation: cdai-tip-bob 3s ease-in-out 0.6s infinite;
}
.cdai-tip.cdai-hide {
  opacity: 0 !important;
  visibility: hidden !important;
  transform: translateX(14px) scale(0.92) !important;
  animation: none !important;
  pointer-events: none !important;
}
.cdai-tip-close {
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.05rem;
  line-height: 1;
  color: var(--cd-ink-soft);
  opacity: 0.55;
  transition: opacity 0.2s ease;
}
.cdai-tip-close:hover { opacity: 1; }
@keyframes cdai-tip-bob {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(-5px); }
}

/* ---------- Panel ---------- */
#cdai-panel {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 130px);
  background: var(--cd-bg);
  border-radius: 22px;
  box-shadow: 0 30px 70px rgba(43, 39, 34, 0.28), 0 8px 20px rgba(0,0,0,0.12);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(28px) scale(0.92);
  transform-origin: bottom right;
  transition: opacity 0.34s ease, transform 0.42s cubic-bezier(0.22,1,0.36,1), visibility 0.34s;
  border: 1px solid rgba(255,255,255,0.6);
}
#cdai-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* ---------- Header ---------- */
.cdai-header {
  background: linear-gradient(135deg, var(--cd-teal), var(--cd-teal-dark));
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  flex-shrink: 0;
}
.cdai-header::after {
  content: '';
  position: absolute;
  right: -30px; top: -40px;
  width: 120px; height: 120px;
  background: radial-gradient(circle, rgba(217,165,59,0.25), transparent 70%);
  pointer-events: none;
}
.cdai-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: rgba(217,165,59,0.22);
  border: 1.5px solid var(--cd-gold);
  color: var(--cd-gold);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
  animation: cdai-avatar-glow 3s ease-in-out infinite;
}
@keyframes cdai-avatar-glow {
  0%,100% { box-shadow: 0 0 0 0 rgba(217,165,59,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(217,165,59,0); }
}
.cdai-titles { flex: 1; min-width: 0; }
.cdai-name {
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  display: flex; align-items: center; gap: 7px;
}
.cdai-online {
  width: 8px; height: 8px; border-radius: 50%;
  background: #6EE7B7;
  box-shadow: 0 0 0 3px rgba(110,231,183,0.3);
  animation: cdai-blink 2s ease-in-out infinite;
}
@keyframes cdai-blink { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.cdai-slogan {
  color: rgba(255,255,255,0.82);
  font-size: 0.76rem;
  margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cdai-min {
  background: rgba(255,255,255,0.14);
  border: none;
  color: #fff;
  width: 30px; height: 30px;
  border-radius: 50%;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.25s ease, transform 0.25s ease;
  flex-shrink: 0;
}
.cdai-min:hover { background: rgba(255,255,255,0.28); transform: scale(1.08); }

/* ---------- Body (messages) ---------- */
.cdai-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 6px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.cdai-body::-webkit-scrollbar { width: 6px; }
.cdai-body::-webkit-scrollbar-thumb { background: rgba(31,111,92,0.22); border-radius: 10px; }

.cdai-msg {
  display: flex;
  gap: 8px;
  max-width: 88%;
  animation: cdai-msg-in 0.4s cubic-bezier(0.22,1,0.36,1) both;
}
@keyframes cdai-msg-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.cdai-bot { align-self: flex-start; }
.cdai-user { align-self: flex-end; }

.cdai-mini-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cd-teal), var(--cd-teal-light));
  color: var(--cd-gold);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
  align-self: flex-end;
}
.cdai-bubble {
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.55;
  word-wrap: break-word;
}
.cdai-bot .cdai-bubble {
  background: #fff;
  color: var(--cd-ink);
  border-bottom-left-radius: 5px;
  box-shadow: 0 3px 12px rgba(43,39,34,0.07);
}
.cdai-user .cdai-bubble {
  background: linear-gradient(135deg, var(--cd-teal), var(--cd-teal-dark));
  color: #fff;
  border-bottom-right-radius: 5px;
}
.cdai-bubble a {
  color: var(--cd-gold-dark);
  font-weight: 600;
  text-decoration: underline;
}
.cdai-user .cdai-bubble a { color: #fff; }
.cdai-bubble strong { font-weight: 700; }
.cdai-bubble em { font-style: italic; color: var(--cd-ink-soft); }

/* ---------- Typing indicator ---------- */
.cdai-typing { display: flex; gap: 4px; align-items: center; padding: 14px 16px; }
.cdai-typing span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--cd-teal-light);
  opacity: 0.5;
  animation: cdai-bounce 1.2s infinite ease-in-out;
}
.cdai-typing span:nth-child(2) { animation-delay: 0.18s; }
.cdai-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes cdai-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ---------- Quick-reply chips ---------- */
.cdai-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 16px 10px;
  flex-shrink: 0;
}
.cdai-chip {
  background: rgba(31,111,92,0.08);
  color: var(--cd-teal);
  border: 1px solid rgba(31,111,92,0.2);
  border-radius: 100px;
  padding: 7px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--cd-font);
  cursor: pointer;
  transition: all 0.25s var(--cd-ease, ease);
  animation: cdai-chip-in 0.35s ease both;
}
.cdai-chip:hover {
  background: var(--cd-teal);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(31,111,92,0.25);
}
@keyframes cdai-chip-in {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}

/* ---------- Input bar ---------- */
.cdai-input {
  display: flex;
  gap: 8px;
  padding: 12px 14px 8px;
  border-top: 1px solid var(--cd-line);
  background: #fff;
  flex-shrink: 0;
}
#cdai-text {
  flex: 1;
  border: 1.5px solid var(--cd-line);
  border-radius: 100px;
  padding: 11px 16px;
  font-size: 0.9rem;
  font-family: var(--cd-font);
  color: var(--cd-ink);
  outline: none;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
#cdai-text:focus {
  border-color: var(--cd-teal);
  box-shadow: 0 0 0 3px rgba(31,111,92,0.12);
}
.cdai-input button {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--cd-gold), var(--cd-gold-dark));
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.cdai-input button:hover {
  transform: scale(1.08) rotate(8deg);
  box-shadow: 0 6px 16px rgba(217,165,59,0.4);
}
.cdai-input button:active { transform: scale(0.94); }

.cdai-foot {
  text-align: center;
  font-size: 0.68rem;
  color: var(--cd-ink-soft);
  padding: 0 0 9px;
  background: #fff;
  letter-spacing: 0.3px;
}

/* ---------- Mobile ---------- */
@media (max-width: 480px) {
  #cdai-launcher { bottom: 18px; right: 18px; width: 58px; height: 58px; }
  .cdai-tip { display: none; }
  #cdai-panel {
    bottom: 0; right: 0; left: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }
}

/* ---------- Hide launcher while the mobile nav menu is open ---------- */
body.nav-open #cdai-launcher,
body.nav-open .cdai-tip { opacity: 0; visibility: hidden; pointer-events: none; }

/* ---------- Respect reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  #cdai-launcher, .cdai-launch-pulse, .cdai-avatar, .cdai-online { animation: none; }
  #cdai-panel { transition: opacity 0.2s ease, visibility 0.2s; }
}
