/* Home-page chatbot (app/Views/partials/chatbot.php, public/assets/js/chatbot.js). Uses the tokens in style.css. */

.gtib-chat[hidden],
.gtib-chat [hidden] { display: none !important; }

.gtib-chat {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 150;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
  font-family: var(--font-body);
  pointer-events: none; /* the wrapper spans the width on phones; only its children take clicks */
}
.gtib-chat > * { pointer-events: auto; }

.gtib-chat__launcher {
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 50%;
  background: var(--gold);
  color: var(--white);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(245, 130, 32, 0.38);
  transition: transform 300ms var(--ease), background 300ms var(--ease);
}
.gtib-chat__launcher:hover { background: var(--gold-deep); transform: translateY(-2px); }
.gtib-chat__launcher:focus-visible { outline: 2px solid var(--navy); outline-offset: 3px; }
.gtib-chat__icon-close { display: none; }
.gtib-chat.is-open .gtib-chat__icon-open { display: none; }
.gtib-chat.is-open .gtib-chat__icon-close { display: block; }

.gtib-chat__panel {
  width: 380px;
  height: min(580px, calc(100vh - 120px));
  height: min(580px, calc(100dvh - 120px));
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: gtib-chat-in 260ms var(--ease);
}
@keyframes gtib-chat-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.gtib-chat__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  background: var(--navy);
  color: var(--white);
  border-bottom: 3px solid var(--gold);
}
.gtib-chat__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
}
.gtib-chat__sub {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.68);
}
.gtib-chat__close {
  flex: none;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--white);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.gtib-chat__close:hover { background: rgba(255, 255, 255, 0.1); }
.gtib-chat__close:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }

.gtib-chat__log {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--off-white);
  overscroll-behavior: contain;
}
.gtib-chat__msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.gtib-chat__msg--bot {
  align-self: flex-start;
  background: var(--white);
  color: var(--ink);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}
.gtib-chat__msg--user {
  align-self: flex-end;
  background: var(--gold);
  color: var(--white);
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
}
.gtib-chat__msg--error { border-color: rgba(216, 108, 18, 0.45); color: var(--slate); }
.gtib-chat__msg a { color: var(--gold-deep); font-weight: 600; text-decoration: underline; }
.gtib-chat__msg strong { font-weight: 600; }

/* Bot replies: a clear gap between paragraphs, lists kept close to the line that introduces them. */
.gtib-chat__msg p,
.gtib-chat__msg ul,
.gtib-chat__msg ol { margin: 0; font-size: inherit; line-height: inherit; color: inherit; }
.gtib-chat__msg p + p,
.gtib-chat__msg ul + p,
.gtib-chat__msg ol + p { margin-top: 1.3em; }
.gtib-chat__msg ul,
.gtib-chat__msg ol { margin-top: 0.35em; padding-left: 1.25em; }
.gtib-chat__msg > ul:first-child,
.gtib-chat__msg > ol:first-child { margin-top: 0; }
.gtib-chat__msg ul { list-style: disc; }
.gtib-chat__msg ol { list-style: decimal; }
.gtib-chat__msg li { margin: 0.2em 0 0; padding: 0; }

.gtib-chat__typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 14px 16px;
}
.gtib-chat__typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--slate-soft);
  animation: gtib-chat-dot 1.2s infinite ease-in-out;
}
.gtib-chat__typing span:nth-child(2) { animation-delay: 0.15s; }
.gtib-chat__typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes gtib-chat-dot {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

.gtib-chat__form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: var(--white);
}
.gtib-chat__label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.gtib-chat__form textarea {
  flex: 1;
  min-height: 42px;
  max-height: 120px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--white);
  resize: none;
  overflow-y: hidden; /* chatbot.js turns scrolling on once the text outgrows max-height */
}
.gtib-chat__form textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(245, 130, 32, 0.15); }
.gtib-chat__send {
  flex: none;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: var(--radius);
  background: var(--gold);
  color: var(--white);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 200ms var(--ease);
}
.gtib-chat__send:hover { background: var(--gold-deep); }
.gtib-chat__send:disabled { background: var(--gray); color: var(--slate-soft); cursor: default; }
.gtib-chat__send:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }

.gtib-chat__foot {
  margin: 0;
  padding: 0 12px 12px;
  background: var(--white);
  font-size: 12px;
  color: var(--slate-soft);
  text-align: center;
}
.gtib-chat__foot a { color: var(--gold-deep); font-weight: 600; }

@media (max-width: 480px) {
  .gtib-chat { right: 16px; bottom: 16px; left: 16px; }
  .gtib-chat__panel { width: 100%; height: calc(100vh - 100px); height: calc(100dvh - 100px); }
  .gtib-chat__launcher { width: 56px; height: 56px; }
  .gtib-chat__form textarea { font-size: 16px; } /* no zoom-on-focus in iOS Safari */
}

@media (prefers-reduced-motion: reduce) {
  .gtib-chat__panel,
  .gtib-chat__typing span { animation: none; }
  .gtib-chat__launcher { transition: none; }
}
