/* =========================================================================
   GC Dhaliara Assistant — chatbot widget styles
   Vanilla CSS. Academic / Indian government college theme.
   ========================================================================= */

#gcd-chatbot-root {
  --gcd-navy: #0b3d63;
  --gcd-navy-dark: #082a45;
  --gcd-gold: #c8952c;
  --gcd-bg: #f4f7fa;
  --gcd-card: #ffffff;
  --gcd-text: #1c2b36;
  --gcd-muted: #64748b;
  --gcd-border: #e2e8f0;
  --gcd-user-bubble: #0b3d63;
  --gcd-bot-bubble: #eef3f8;
  --gcd-radius: 16px;
  --gcd-shadow: 0 10px 40px rgba(11, 61, 99, 0.25);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  --gcd-z: 999999;
  /* Reset typography the HOST page may set globally (body { letter-spacing;
     word-spacing; text-align: justify; text-transform } etc.), since this
     widget is embedded on arbitrary college pages and inherits from them. */
  font-size: 14px;
  font-weight: 400;
  font-style: normal;
  line-height: 1.5;
  letter-spacing: normal;
  word-spacing: normal;
  text-align: left;
  text-transform: none;
  text-indent: 0;
  hyphens: manual;
}

#gcd-chatbot-root * { box-sizing: border-box; }
#gcd-chatbot-root input, #gcd-chatbot-root button { font-family: inherit; letter-spacing: normal; word-spacing: normal; }

/* ---------- Floating Action Button ---------- */
#gcd-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(145deg, var(--gcd-navy), var(--gcd-navy-dark));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--gcd-shadow);
  z-index: var(--gcd-z);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
#gcd-fab:hover { transform: translateY(-2px) scale(1.04); }
#gcd-fab:focus-visible { outline: 3px solid var(--gcd-gold); outline-offset: 3px; }

.gcd-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #d1332f;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid #fff;
}

/* ---------- Chat Window ---------- */
#gcd-window {
  position: fixed;
  right: 22px;
  bottom: 96px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: min(640px, calc(100vh - 140px));
  background: var(--gcd-card);
  border-radius: var(--gcd-radius);
  box-shadow: var(--gcd-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: var(--gcd-z);
  border: 1px solid var(--gcd-border);
  animation: gcd-pop 0.18s ease-out;
}
@keyframes gcd-pop {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.gcd-hidden { display: none !important; }

/* ---------- Header ---------- */
#gcd-header {
  background: linear-gradient(120deg, var(--gcd-navy), var(--gcd-navy-dark));
  color: #fff;
  padding: 14px 12px 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.gcd-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--gcd-gold);
  color: #1c2b36;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.gcd-header-text { flex: 1; min-width: 0; }
.gcd-title { font-weight: 700; font-size: 15px; line-height: 1.2; }
.gcd-subtitle {
  font-size: 11.5px;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gcd-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34d399;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.25);
}
.gcd-icon-btn {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease;
}
.gcd-icon-btn:hover { background: rgba(255, 255, 255, 0.25); }
.gcd-icon-btn:focus-visible { outline: 2px solid var(--gcd-gold); }

/* ---------- Messages ---------- */
#gcd-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  background: var(--gcd-bg);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.gcd-msg { display: flex; max-width: 92%; }
.gcd-msg-bot { align-self: flex-start; flex-direction: column; }
.gcd-msg-user { align-self: flex-end; flex-direction: column; align-items: flex-end; }

.gcd-bubble {
  padding: 11px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.6;
  letter-spacing: 0.005em;
  word-spacing: 0.02em;
  color: var(--gcd-text);
  background: var(--gcd-bot-bubble);
  border-top-left-radius: 4px;
  overflow-wrap: anywhere; /* long URLs/PDF names wrap instead of overflowing */
  white-space: pre-line; /* user bubbles + older saved answers keep their line breaks */
}

/* ---------- Formatted bot answers (renderAnswerText in script.js) ---------- */
.gcd-bubble.gcd-answer { white-space: normal; }
.gcd-answer p { margin: 0; }
.gcd-answer p + p, .gcd-answer p + ul, .gcd-answer ul + p { margin-top: 8px; }
.gcd-answer strong { font-weight: 600; color: var(--gcd-navy); }
.gcd-answer a { color: var(--gcd-navy); text-decoration: underline; text-underline-offset: 2px; }
.gcd-answer-list {
  margin: 0;
  padding-left: 18px;
}
.gcd-answer-list > li { padding-left: 2px; }
.gcd-answer-list > li + li { margin-top: 7px; }
.gcd-answer-list > li::marker { color: var(--gcd-gold); }
.gcd-sublist {
  margin: 4px 0 0;
  padding-left: 16px;
  list-style: circle;
  font-size: 13.5px;
}
.gcd-sublist li + li { margin-top: 3px; }
.gcd-sublist li::marker { color: var(--gcd-muted); }
.gcd-msg-user .gcd-bubble {
  background: var(--gcd-user-bubble);
  color: #fff;
  border-top-left-radius: 14px;
  border-top-right-radius: 4px;
}
.gcd-bubble.gcd-muted { background: #fff7e6; color: #7a5b12; border: 1px dashed #e6c675; }

/* ---------- Welcome message ---------- */
.gcd-welcome { display: flex; flex-direction: column; gap: 5px; }
.gcd-welcome-greet { font-size: 15px; font-weight: 600; color: var(--gcd-navy); }
.gcd-welcome-line { color: var(--gcd-text); }
.gcd-welcome-hint { font-size: 12.5px; color: var(--gcd-muted); }

.gcd-source {
  margin-top: 6px;
  font-size: 12px;
  color: var(--gcd-muted);
  background: #fff;
  border: 1px solid var(--gcd-border);
  border-radius: 10px;
  padding: 7px 10px;
}
.gcd-source a {
  display: inline-block;
  margin-left: 6px;
  color: var(--gcd-navy);
  font-weight: 600;
  text-decoration: none;
}
.gcd-source a:hover { text-decoration: underline; }

.gcd-result-list {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.gcd-result-list > li {
  background: #fff;
  border: 1px solid var(--gcd-border);
  border-radius: 10px;
  padding: 8px 10px;
}
.gcd-result-list a { color: var(--gcd-navy); font-weight: 600; font-size: 13px; text-decoration: none; }
.gcd-result-list a:hover { text-decoration: underline; }
.gcd-snippet { font-size: 12.5px; line-height: 1.5; color: #475569; margin-top: 4px; }

/* Per-page card head (title + optional LIVE badge) in a multi-page answer */
.gcd-result-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.gcd-result-head .gcd-live-badge { font-size: 9px; padding: 1px 5px; }

/* 2-line snippet as its own compact bullet list, instead of one run-on sentence */
.gcd-snippet-list {
  margin: 4px 0 0;
  padding-left: 16px;
  font-size: 12.5px;
  color: #475569;
}
.gcd-snippet-list li { line-height: 1.5; }
.gcd-snippet-list li + li { margin-top: 3px; }

/* ---------- Quick-option chips (Show images / Related documents) ---------- */
.gcd-option-row {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.gcd-option-chip {
  background: #fff;
  border: 1px solid var(--gcd-navy);
  color: var(--gcd-navy);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.gcd-option-chip:hover:not(:disabled) { background: #eef3f8; }
.gcd-option-chip:disabled { opacity: 0.5; cursor: default; }

/* ---------- Document / PDF links ---------- */
.gcd-doc-list {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.gcd-doc-list li {
  background: #fff;
  border: 1px solid var(--gcd-border);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.gcd-doc-list a { color: var(--gcd-navy); font-weight: 600; font-size: 13px; text-decoration: none; }
.gcd-doc-list a:hover { text-decoration: underline; }
.gcd-doc-type {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--gcd-muted);
  background: #eef3f8;
  border-radius: 6px;
  padding: 2px 6px;
}

/* ---------- Image gallery ---------- */
.gcd-gallery {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 6px;
  max-width: 100%;
}
.gcd-figure {
  margin: 0;
  flex: 0 0 auto;
  width: 170px;
  background: #fff;
  border: 1px solid var(--gcd-border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.gcd-figure:hover { transform: translateY(-2px); }
.gcd-figure img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  display: block;
  background: #dfe7ee;
}
.gcd-figure figcaption {
  font-size: 11px;
  color: var(--gcd-muted);
  padding: 6px 8px;
  line-height: 1.3;
}
.gcd-figure.gcd-broken-img { display: none; }

/* ---------- Typing indicator ---------- */
.gcd-typing {
  display: flex;
  gap: 4px;
  padding: 0 16px 8px;
  align-items: center;
}
.gcd-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gcd-muted);
  animation: gcd-bounce 1.1s infinite ease-in-out;
}
.gcd-typing span:nth-child(2) { animation-delay: 0.15s; }
.gcd-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes gcd-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ---------- Live web-fallback status line ---------- */
.gcd-status {
  padding: 0 16px 8px;
  font-size: 11.5px;
  color: var(--gcd-muted);
  font-style: italic;
  display: flex;
  align-items: center;
  gap: 6px;
}
.gcd-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gcd-gold);
  animation: gcd-pulse 1s infinite ease-in-out;
  flex-shrink: 0;
}
@keyframes gcd-pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}
.gcd-source-live {
  border-color: #bfe3cf;
  background: #f2fbf6;
}
.gcd-source-live strong { color: #1c7a45; }
.gcd-live-badge {
  display: inline-block;
  background: #1c7a45;
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 1px 6px;
  border-radius: 999px;
  vertical-align: middle;
}

/* ---------- FAQ chips ---------- */
.gcd-faqs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 12px;
  border-top: 1px solid var(--gcd-border);
  background: #fff;
  flex-shrink: 0;
}
.gcd-faq-chip {
  flex: 0 0 auto;
  background: #eef3f8;
  border: 1px solid var(--gcd-border);
  color: var(--gcd-navy);
  font-size: 12px;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}
.gcd-faq-chip:hover { background: #dfe9f3; }
.gcd-faq-chip:focus-visible { outline: 2px solid var(--gcd-navy); }

/* ---------- Input form ---------- */
#gcd-form {
  position: relative;
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid var(--gcd-border);
  flex-shrink: 0;
}
#gcd-input {
  flex: 1;
  border: 1px solid var(--gcd-border);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 13.8px;
  outline: none;
  min-width: 0;
}
#gcd-input:focus { border-color: var(--gcd-navy); box-shadow: 0 0 0 3px rgba(11, 61, 99, 0.12); }
#gcd-send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--gcd-navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease;
}
#gcd-send:hover { background: var(--gcd-navy-dark); }
#gcd-send:focus-visible { outline: 2px solid var(--gcd-gold); }

/* ---------- Voice search mic ---------- */
#gcd-mic {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--gcd-border);
  background: #fff;
  color: var(--gcd-navy);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}
#gcd-mic[hidden] { display: none; }
#gcd-mic:hover { background: var(--gcd-bot-bubble); }
#gcd-mic:focus-visible { outline: 2px solid var(--gcd-gold); }
#gcd-mic.gcd-listening {
  background: #d93025;
  border-color: #d93025;
  color: #fff;
  animation: gcd-mic-pulse 1.2s ease-out infinite;
}
@keyframes gcd-mic-pulse {
  0% { box-shadow: 0 0 0 0 rgba(217, 48, 37, 0.45); }
  100% { box-shadow: 0 0 0 12px rgba(217, 48, 37, 0); }
}

/* ---------- Autocomplete suggestions ----------
   The input sits at the very bottom of the window, so the list opens
   upward, attached right over the input bar. */
#gcd-suggest {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(100% - 4px);
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: #fff;
  border: 1px solid var(--gcd-border);
  border-radius: 12px;
  box-shadow: 0 -6px 20px rgba(11, 61, 99, 0.14);
  max-height: 230px;
  overflow-y: auto;
  z-index: 2;
}
.gcd-suggest-item {
  padding: 8px 14px;
  font-size: 13.2px;
  color: var(--gcd-text);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gcd-suggest-item:hover, .gcd-suggest-item.gcd-active { background: var(--gcd-bot-bubble); }
.gcd-suggest-item mark { background: none; color: var(--gcd-navy); font-weight: 700; }

/* ---------- Lightbox ---------- */
#gcd-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(8, 15, 22, 0.88);
  z-index: calc(var(--gcd-z) + 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
#gcd-lightbox-img {
  max-width: min(92vw, 900px);
  max-height: 78vh;
  border-radius: 10px;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}
#gcd-lightbox-caption {
  color: #fff;
  margin-top: 12px;
  font-size: 13px;
  text-align: center;
  max-width: 600px;
}
#gcd-lightbox-close {
  position: absolute;
  top: 18px;
  right: 22px;
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
#gcd-lightbox-close:hover { background: rgba(255, 255, 255, 0.25); }

/* ---------- Scrollbars (subtle) ---------- */
#gcd-messages, .gcd-gallery, .gcd-faqs { scrollbar-width: thin; scrollbar-color: #c7d3de transparent; }
#gcd-messages::-webkit-scrollbar, .gcd-gallery::-webkit-scrollbar, .gcd-faqs::-webkit-scrollbar { height: 4px; width: 4px; }
#gcd-messages::-webkit-scrollbar-thumb, .gcd-gallery::-webkit-scrollbar-thumb, .gcd-faqs::-webkit-scrollbar-thumb { background: #c7d3de; border-radius: 999px; }
#gcd-messages::-webkit-scrollbar-track, .gcd-gallery::-webkit-scrollbar-track, .gcd-faqs::-webkit-scrollbar-track { background: transparent; }

/* ---------- Mobile: near full-screen ---------- */
@media (max-width: 480px) {
  #gcd-window {
    right: 8px;
    left: 8px;
    bottom: 8px;
    top: 8px;
    width: auto;
    height: auto;
    max-width: none;
    border-radius: 14px;
  }
  #gcd-fab { right: 16px; bottom: 16px; }
  .gcd-figure { width: 140px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  #gcd-window, #gcd-fab, #gcd-mic, .gcd-figure, .gcd-typing span { animation: none !important; transition: none !important; }
}
