/* ==========================================================================
   AGASTYA — solution advisor chatbot widget
   Floating button + chat panel, fully client-side
   ========================================================================== */

/* CSS variables derived from site palette so this stays themeable */
.agastya {
  --ag-primary: #0a2540;
  --ag-primary-2: #13304f;
  --ag-accent: #00a8b5;
  --ag-accent-dark: #1a8a94;
  --ag-coral: #ff6a55;
  --ag-coral-dark: #e85a47;
  --ag-fg: #0a2540;
  --ag-fg-2: #4a5d75;
  --ag-fg-mute: #8294aa;
  --ag-line: #e3e8ef;
  --ag-bg: #ffffff;
  --ag-bg-tint: #f6f8fb;
  --ag-shadow: 0 16px 50px rgba(10, 37, 64, 0.18);

  font-family: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ag-fg);
}

/* ---- Floating launcher button (always visible) ---- */
.agastya__launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9998;
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
}
.agastya__launcher-pill {
  background: var(--ag-bg);
  color: var(--ag-fg);
  padding: 10px 16px;
  border-radius: 24px;
  box-shadow: var(--ag-shadow);
  font-weight: 600;
  font-size: 14px;
  display: none;
  align-items: center;
  gap: 6px;
  transition: transform 200ms ease;
  white-space: nowrap;
}
.agastya__launcher-pill .agastya__pulse {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ag-coral);
  animation: agastya-pulse 2s ease-in-out infinite;
}
@media (min-width: 640px) { .agastya__launcher-pill { display: inline-flex; } }
.agastya__launcher-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ag-coral), var(--ag-coral-dark));
  box-shadow: var(--ag-shadow), 0 0 0 0 rgba(255, 106, 85, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  border: 0;
  cursor: pointer;
  transition: transform 200ms ease, box-shadow 200ms ease;
  position: relative;
}
.agastya__launcher-btn::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--ag-coral);
  opacity: 0;
  animation: agastya-ring 2.5s ease-out infinite;
}
.agastya__launcher:hover .agastya__launcher-btn { transform: scale(1.05); }
.agastya__launcher:hover .agastya__launcher-pill { transform: translateX(-2px); }
@keyframes agastya-ring {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.6); opacity: 0; }
}
@keyframes agastya-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.2); }
}

.agastya--open .agastya__launcher { display: none; }

/* ---- Chat panel ---- */
.agastya__panel {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9999;
  width: min(400px, calc(100vw - 32px));
  height: min(640px, calc(100vh - 48px));
  background: var(--ag-bg);
  border-radius: 18px;
  box-shadow: var(--ag-shadow);
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--ag-line);
}
.agastya--open .agastya__panel {
  display: flex;
  animation: agastya-slide-up 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes agastya-slide-up {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@media (max-width: 640px) {
  .agastya__panel {
    right: 12px;
    bottom: 12px;
    left: 12px;
    width: auto;
    height: calc(100vh - 24px);
    height: calc(100dvh - 24px);
    border-radius: 14px;
  }
}

/* ---- Header ---- */
.agastya__header {
  background: linear-gradient(135deg, var(--ag-primary), var(--ag-primary-2));
  color: white;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.agastya__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ag-accent), var(--ag-accent-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.5px;
  color: white;
  position: relative;
  flex-shrink: 0;
}
.agastya__avatar::after {
  content: "";
  position: absolute;
  bottom: 0;
  right: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #4ade80;
  border: 2px solid var(--ag-primary);
}
.agastya__title {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.agastya__name {
  font-family: 'Manrope', sans-serif;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.agastya__subtitle {
  font-size: 12px;
  opacity: 0.7;
  letter-spacing: 0.05em;
  margin-top: 2px;
}
.agastya__close {
  background: rgba(255, 255, 255, 0.1);
  border: 0;
  border-radius: 8px;
  padding: 8px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 200ms ease;
  flex-shrink: 0;
}
.agastya__close:hover { background: rgba(255, 255, 255, 0.2); }

/* ---- Messages area ---- */
.agastya__body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px;
  background: var(--ag-bg-tint);
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}
.agastya__body::-webkit-scrollbar { width: 6px; }
.agastya__body::-webkit-scrollbar-thumb { background: var(--ag-line); border-radius: 3px; }
.agastya__body::-webkit-scrollbar-track { background: transparent; }

/* Message bubbles */
.agastya__msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 88%;
  animation: agastya-msg-in 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes agastya-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.agastya__msg--bot { align-self: flex-start; }
.agastya__msg--user { align-self: flex-end; flex-direction: row-reverse; }

.agastya__msg-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ag-accent), var(--ag-accent-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 11px;
  color: white;
  flex-shrink: 0;
  margin-bottom: 2px;
}
.agastya__msg--user .agastya__msg-avatar { display: none; }

.agastya__bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
}
.agastya__msg--bot .agastya__bubble {
  background: white;
  color: var(--ag-fg);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(10, 37, 64, 0.06);
}
.agastya__msg--user .agastya__bubble {
  background: linear-gradient(135deg, var(--ag-coral), var(--ag-coral-dark));
  color: white;
  border-bottom-right-radius: 4px;
}
.agastya__bubble strong { font-weight: 700; }
.agastya__bubble a {
  color: var(--ag-coral);
  font-weight: 600;
  text-decoration: none;
}
.agastya__bubble a:hover { text-decoration: underline; }
.agastya__msg--user .agastya__bubble a { color: white; text-decoration: underline; }

/* Typing indicator */
.agastya__typing {
  display: inline-flex;
  gap: 4px;
  padding: 4px 0;
}
.agastya__typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ag-fg-mute);
  animation: agastya-typing 1.4s ease-in-out infinite;
}
.agastya__typing span:nth-child(2) { animation-delay: 0.2s; }
.agastya__typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes agastya-typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ---- Recommendation card ---- */
.agastya__rec {
  background: white;
  border: 1px solid var(--ag-line);
  border-radius: 12px;
  padding: 14px;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.agastya__rec-tag {
  font-family: 'Manrope', sans-serif;
  font-size: 10px;
  font-weight: 700;
  color: var(--ag-coral);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.agastya__rec-title {
  font-family: 'Manrope', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--ag-primary);
  line-height: 1.25;
}
.agastya__rec-desc { font-size: 13px; color: var(--ag-fg-2); line-height: 1.5; }
.agastya__rec-link {
  font-size: 13px;
  font-weight: 700;
  color: var(--ag-accent-dark);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}
.agastya__rec-link:hover { text-decoration: underline; }

/* ---- Input area (chips, text input, form) ---- */
.agastya__input {
  border-top: 1px solid var(--ag-line);
  background: white;
  padding: 14px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 50%;
  overflow-y: auto;
}
.agastya__input::-webkit-scrollbar { width: 6px; }
.agastya__input::-webkit-scrollbar-thumb { background: var(--ag-line); border-radius: 3px; }

.agastya__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.agastya__chip {
  background: white;
  border: 1.5px solid var(--ag-line);
  border-radius: 18px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ag-fg);
  cursor: pointer;
  font-family: inherit;
  transition: all 150ms ease;
}
.agastya__chip:hover {
  border-color: var(--ag-accent);
  background: var(--ag-bg-tint);
  transform: translateY(-1px);
}
.agastya__chip:active { transform: translateY(0); }

/* Form fields when capturing contact info */
.agastya__field { display: flex; flex-direction: column; gap: 4px; }
.agastya__field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ag-fg-2);
  letter-spacing: 0.02em;
}
.agastya__field input,
.agastya__field textarea,
.agastya__field select {
  padding: 9px 12px;
  border: 1.5px solid var(--ag-line);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--ag-fg);
  background: white;
  transition: border-color 150ms ease;
}
.agastya__field input:focus,
.agastya__field textarea:focus,
.agastya__field select:focus {
  outline: none;
  border-color: var(--ag-accent);
}
.agastya__field textarea { resize: vertical; min-height: 70px; }

.agastya__submit {
  background: linear-gradient(135deg, var(--ag-coral), var(--ag-coral-dark));
  color: white;
  border: 0;
  padding: 11px 16px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: transform 150ms ease;
}
.agastya__submit:hover { transform: translateY(-1px); }
.agastya__submit:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.agastya__row { display: flex; gap: 8px; }
.agastya__row .agastya__field { flex: 1; }

/* Restart link */
.agastya__restart {
  background: transparent;
  border: 0;
  color: var(--ag-fg-mute);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  align-self: flex-start;
  font-family: inherit;
  padding: 0;
}
.agastya__restart:hover { color: var(--ag-fg); }

/* Footer note */
.agastya__footer-note {
  font-size: 11px;
  color: var(--ag-fg-mute);
  text-align: center;
  padding: 6px 14px;
  background: white;
  border-top: 1px solid var(--ag-line);
}
.agastya__footer-note a { color: var(--ag-accent-dark); }

/* ---- Hybrid input (text field + chip suggestions) ---- */
.agastya__hybrid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.agastya__hint {
  font-size: 11px;
  color: var(--ag-fg-mute);
  letter-spacing: 0.04em;
}
.agastya__chips--small .agastya__chip {
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 500;
}
.agastya__textbar {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.agastya__textbar input,
.agastya__textbar textarea {
  flex: 1;
  padding: 10px 12px;
  border: 1.5px solid var(--ag-line);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  color: var(--ag-fg);
  background: white;
  resize: none;
  transition: border-color 150ms ease;
}
.agastya__textbar input:focus,
.agastya__textbar textarea:focus {
  outline: none;
  border-color: var(--ag-accent);
}
.agastya__send {
  background: linear-gradient(135deg, var(--ag-coral), var(--ag-coral-dark));
  color: white;
  border: 0;
  width: 42px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 120ms ease;
}
.agastya__send:hover { transform: translateY(-1px); }
.agastya__send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
