/* ==========================================================================
   Jindal Naturecure Institute — FAQ Chatbot
   Stylesheet. All rules are namespaced under .jni-chat to avoid collisions
   with the host site. Colours match the original ASP.NET control exactly;
   change them once via the custom properties below.
   ========================================================================== */

.jni-chat {
  /* Brand */
  --jni-green: #2e7d32;
  --jni-green-dark: #1b5e20;
  --jni-green-tint: #e8f5e9;
  --jni-green-wash: #f1f8e9;
  --jni-green-border: #a5d6a7;

  /* Status colours */
  --jni-warn-bg: #fff8e1;
  --jni-warn-bar: #f9a825;
  --jni-alert-bg: #fce4ec;
  --jni-alert-bar: #c62828;

  /* Neutrals */
  --jni-white: #fff;
  --jni-border: #ccc;
  --jni-rule: #e0e0e0;
  --jni-text: #333;
  --jni-muted: #777;

  /* Metrics */
  --jni-width: 420px;
  --jni-offset-bottom: 120px;   /* clears the MyLiveChat launcher */
  --jni-offset-right: 20px;
  --jni-radius: 10px;
  --jni-radius-sm: 6px;
  --jni-font: Arial, Helvetica, sans-serif;
  --jni-z: 9999;
}

/* ── WRAPPER ─────────────────────────────────────────────────────────── */

.jni-chat {
  position: fixed;
  bottom: var(--jni-offset-bottom);
  right: var(--jni-offset-right);
  width: var(--jni-width);
  max-width: calc(100vw - 24px);
  z-index: var(--jni-z);
  font-family: var(--jni-font);
  font-size: 13px;
  line-height: 1.5;
  color: var(--jni-text);
}

.jni-chat *,
.jni-chat *::before,
.jni-chat *::after {
  box-sizing: border-box;
}

/* Shared focus ring — keyboard users only, so mouse clicks stay clean. */
.jni-chat :focus-visible {
  outline: 2px solid var(--jni-green-dark);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ── LAUNCHER ────────────────────────────────────────────────────────── */

.jni-chat__launcher {
  display: flex;
  float: right;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  border-radius: 30px;
  background-color: var(--jni-green);
  color: var(--jni-white);
  font: bold 13px/1.2 var(--jni-font);
  text-align: center;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
  transition: background-color 0.2s ease;
}

.jni-chat__launcher:hover {
  background-color: var(--jni-green-dark);
}

.jni-chat__launcher-icon {
  font-style: normal;
  color: var(--jni-white);
}

/* ── PANEL ───────────────────────────────────────────────────────────── */

.jni-chat__panel {
  display: none;
  margin-bottom: 8px;
  max-height: min(520px, calc(100vh - 160px));
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--jni-white);
  border: 1px solid var(--jni-border);
  border-radius: var(--jni-radius);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.jni-chat.is-open .jni-chat__panel {
  display: block;
  animation: jni-panel-in 0.18s ease-out;
}

@keyframes jni-panel-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── HEADER ──────────────────────────────────────────────────────────── */

.jni-chat__header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background-color: var(--jni-green);
  color: var(--jni-white);
}

.jni-chat__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: bold;
  font-size: 14px;
}

.jni-chat__close {
  padding: 0 4px;
  border: none;
  background: none;
  color: var(--jni-white);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

/* ── BODY ────────────────────────────────────────────────────────────── */

.jni-chat__body {
  padding: 12px;
}

.jni-chat__label {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  color: var(--jni-muted);
}

.jni-chat__divider {
  border: none;
  border-top: 1px solid var(--jni-rule);
  margin: 10px 0;
}

/* ── CATEGORY BUTTONS ────────────────────────────────────────────────── */

.jni-chat__categories {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.jni-chat__category {
  padding: 5px 10px;
  background-color: var(--jni-green-tint);
  color: var(--jni-green);
  border: 1px solid var(--jni-green-border);
  border-radius: 20px;
  font: bold 12px/1.3 var(--jni-font);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.jni-chat__category:hover,
.jni-chat__category[aria-pressed="true"] {
  background-color: var(--jni-green);
  color: var(--jni-white);
  border-color: var(--jni-green);
}

/* ── QUESTION LIST ───────────────────────────────────────────────────── */

.jni-chat__questions {
  display: none;
  margin-top: 8px;
  max-height: 200px;
  overflow-y: auto;
  background: var(--jni-white);
  border: 1px solid var(--jni-border);
  border-radius: var(--jni-radius-sm);
}

.jni-chat__questions:not(:empty) {
  display: block;
}

.jni-chat__question {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-bottom: 1px solid #f0f0f0;
  background: none;
  color: var(--jni-text);
  font: 12px/1.4 var(--jni-font);
  text-align: left;
  cursor: pointer;
}

.jni-chat__question:last-child {
  border-bottom: none;
}

.jni-chat__question:hover {
  background-color: var(--jni-green-tint);
  color: var(--jni-green);
}

/* ── SEARCH ──────────────────────────────────────────────────────────── */

.jni-chat__search {
  display: flex;
  gap: 5px;
  margin-top: 10px;
}

.jni-chat__input {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  border: 1px solid var(--jni-border);
  border-radius: var(--jni-radius-sm);
  font: 12px/1.4 var(--jni-font);
  color: var(--jni-text);
}

.jni-chat__search-btn {
  padding: 6px 12px;
  border: none;
  border-radius: var(--jni-radius-sm);
  background-color: var(--jni-green);
  color: var(--jni-white);
  font-size: 12px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.jni-chat__search-btn:hover {
  background-color: var(--jni-green-dark);
}

/* ── ANSWER ──────────────────────────────────────────────────────────── */

.jni-chat__answer {
  display: none;
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--jni-green-wash);
  border-left: 4px solid var(--jni-green);
  border-radius: var(--jni-radius-sm);
  font-size: 12px;
  color: var(--jni-text);
  line-height: 1.6;
}

.jni-chat__answer:not(:empty) {
  display: block;
}

/* Answers carry authored HTML from the FAQ table — tables, links, lists. */
.jni-chat__answer a {
  color: var(--jni-green);
}

.jni-chat__answer table {
  width: 100%;
  margin: 8px 0;
  border-collapse: collapse;
  font-size: 11px;
}

.jni-chat__answer th,
.jni-chat__answer td {
  padding: 4px 6px;
  border: 1px solid var(--jni-border);
  text-align: left;
}

.jni-chat__answer th {
  background: var(--jni-green-tint);
  color: var(--jni-green);
}

.jni-chat__answer ul,
.jni-chat__answer ol {
  margin: 6px 0;
  padding-left: 20px;
}

/* Wide charge tables scroll horizontally instead of breaking the layout. */
.jni-chat__scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── MULTIPLE MATCHES ────────────────────────────────────────────────── */

.jni-chat__option {
  display: block;
  width: 100%;
  margin-bottom: 6px;
  padding: 8px 12px;
  background: var(--jni-green-tint);
  border: 1px solid var(--jni-green-border);
  border-radius: var(--jni-radius-sm);
  color: var(--jni-green);
  font: bold 12px/1.4 var(--jni-font);
  text-align: left;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.jni-chat__option:hover {
  background: var(--jni-green);
  color: var(--jni-white);
}

/* ── NO ANSWER / OFFLINE PANELS ──────────────────────────────────────── */

.jni-chat__no-answer,
.jni-chat__offline {
  display: none;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--jni-radius-sm);
  font-size: 12px;
}

.jni-chat__no-answer {
  background: var(--jni-warn-bg);
  border-left: 4px solid var(--jni-warn-bar);
  color: #555;
}

.jni-chat__offline {
  background: var(--jni-alert-bg);
  border-left: 4px solid var(--jni-alert-bar);
  color: var(--jni-text);
}

.jni-chat__offline a {
  color: var(--jni-alert-bar);
}

.jni-chat__no-answer.is-visible,
.jni-chat__offline.is-visible {
  display: block;
}

.jni-chat__btn {
  margin-top: 8px;
  margin-right: 6px;
  padding: 5px 14px;
  border: none;
  border-radius: 20px;
  color: var(--jni-white);
  font: 12px/1.4 var(--jni-font);
  cursor: pointer;
}

.jni-chat__btn--primary {
  background-color: var(--jni-green);
}

.jni-chat__btn--primary:hover {
  background-color: var(--jni-green-dark);
}

.jni-chat__btn--muted {
  background-color: #aaa;
}

.jni-chat__btn--muted:hover {
  background-color: #8f8f8f;
}

/* ── LIVE CHAT PANEL (appended to <body>, so not nested under .jni-chat) ─ */

.jni-livechat {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  width: 550px;
  max-width: calc(100vw - 24px);
  height: 620px;
  max-height: 80vh;
  overflow: hidden;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
  z-index: 999999;
  font-family: Arial, Helvetica, sans-serif;
}

.jni-livechat[hidden] {
  display: none;
}

.jni-livechat__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #2e7d32;
  color: #fff;
  font-weight: bold;
  cursor: move;
  user-select: none;
  touch-action: none;
}

.jni-livechat__close {
  padding: 0 4px;
  border: none;
  background: none;
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.jni-livechat__frame {
  flex: 1;
  width: 100%;
  border: 0;
}

/* ── RESPONSIVE ──────────────────────────────────────────────────────── */

@media (max-width: 600px) {
  .jni-chat {
    --jni-width: 100%;
    --jni-offset-bottom: 84px;
    --jni-offset-right: 12px;
    left: 12px;
  }

  .jni-chat__panel {
    max-height: calc(100vh - 140px);
  }

  /* 16px prevents iOS Safari from zooming the page on focus. */
  .jni-chat__input {
    font-size: 16px;
  }

  .jni-livechat {
    right: 12px;
    left: 12px;
    bottom: 12px;
    width: auto;
    height: 78vh;
    cursor: default;
  }

  .jni-livechat__header {
    cursor: default;
  }
}

/* ── MOTION PREFERENCES ──────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .jni-chat *,
  .jni-chat.is-open .jni-chat__panel {
    animation: none !important;
    transition: none !important;
  }
}

/* ── PRINT ───────────────────────────────────────────────────────────── */

@media print {
  .jni-chat,
  .jni-livechat {
    display: none !important;
  }
}
