/*
 * FingerScan Digital — Chatbot Widget Styles
 * File: chatbot.css
 *
 * Design: Professional, authoritative — dark navy with gold accent
 * Matches the trustworthy identity of a fingerprinting/document services company
 */

/* ── CSS Variables ──────────────────────────────────────────────────────────── */
:root {
  --chat-primary:     #0d2240;   /* Deep navy — authority & trust */
  --chat-accent:      #c9a84c;   /* Gold — premium service */
  --chat-accent-dark: #a8893a;
  --chat-bg:          #ffffff;
  --chat-surface:     #f4f6f9;
  --chat-border:      #dde3ed;
  --chat-text:        #1a2535;
  --chat-subtext:     #6b7a91;
  --chat-bot-bubble:  #eef1f7;
  --chat-user-bubble: #0d2240;
  --chat-user-text:   #ffffff;
  --chat-shadow:      0 8px 40px rgba(13, 34, 64, 0.18);
  --chat-radius:      16px;
  --chat-btn-size:    58px;
  --chat-width:       370px;
  --chat-height:      540px;
  --chat-font:        'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ── Toggle Button ──────────────────────────────────────────────────────────── */
#fs-chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: var(--chat-btn-size);
  height: var(--chat-btn-size);
  border-radius: 50%;
  background: var(--chat-primary);
  border: 2.5px solid var(--chat-accent);
  box-shadow: var(--chat-shadow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  outline: none;
}

#fs-chat-toggle:hover {
  transform: scale(1.08);
  background: #162f54;
  box-shadow: 0 10px 48px rgba(13, 34, 64, 0.28);
}

#fs-chat-toggle svg {
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#fs-chat-toggle .icon-chat { opacity: 1; transform: scale(1) rotate(0deg); }
#fs-chat-toggle .icon-close { opacity: 0; transform: scale(0.5) rotate(-45deg); position: absolute; }

#fs-chat-toggle.is-open .icon-chat  { opacity: 0; transform: scale(0.5) rotate(45deg); }
#fs-chat-toggle.is-open .icon-close { opacity: 1; transform: scale(1) rotate(0deg); }

/* Notification dot */
#fs-chat-toggle .fs-notif-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 12px;
  height: 12px;
  background: var(--chat-accent);
  border-radius: 50%;
  border: 2px solid var(--chat-bg);
  animation: fsPulse 1.8s ease-in-out infinite;
}

@keyframes fsPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.3); opacity: 0.7; }
}

/* ── Chat Window ────────────────────────────────────────────────────────────── */
#fs-chat-window {
  position: fixed;
  bottom: calc(var(--chat-btn-size) + 36px);
  right: 24px;
  width: var(--chat-width);
  height: var(--chat-height);
  max-height: 80vh;
  background: var(--chat-bg);
  border-radius: var(--chat-radius);
  box-shadow: var(--chat-shadow);
  border: 1px solid var(--chat-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  font-family: var(--chat-font);

  /* Hidden state */
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transform-origin: bottom right;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

#fs-chat-window.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
#fs-chat-header {
  background: var(--chat-primary);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  border-bottom: 2px solid var(--chat-accent);
}

.fs-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(201, 168, 76, 0.18);
  border: 1.5px solid var(--chat-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.fs-header-info {
  flex: 1;
}

.fs-header-name {
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.fs-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.fs-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4caf83;
  flex-shrink: 0;
}

.fs-header-status span {
  font-size: 11.5px;
  color: rgba(255,255,255,0.65);
}

/* ── Messages Area ──────────────────────────────────────────────────────────── */
#fs-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

#fs-chat-messages::-webkit-scrollbar { width: 4px; }
#fs-chat-messages::-webkit-scrollbar-track { background: transparent; }
#fs-chat-messages::-webkit-scrollbar-thumb { background: var(--chat-border); border-radius: 4px; }

/* Bubbles */
.fs-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: fsMsgIn 0.2s ease forwards;
}

@keyframes fsMsgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fs-msg.bot  { align-self: flex-start; }
.fs-msg.user { align-self: flex-end; }

.fs-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--chat-text);
}

.fs-msg.bot  .fs-bubble { background: var(--chat-bot-bubble); border-bottom-left-radius: 4px; }
.fs-msg.user .fs-bubble { background: var(--chat-user-bubble); color: var(--chat-user-text); border-bottom-right-radius: 4px; }

.fs-bubble a { color: var(--chat-accent-dark); text-decoration: underline; }
.fs-msg.user .fs-bubble a { color: #c9deff; }

.fs-bubble ul, .fs-bubble ol { margin: 6px 0 4px 16px; padding: 0; }
.fs-bubble li { margin-bottom: 2px; }

.fs-msg-time {
  font-size: 10.5px;
  color: var(--chat-subtext);
  margin-top: 3px;
  padding: 0 4px;
}
.fs-msg.user .fs-msg-time { text-align: right; }

/* ── Typing Indicator ───────────────────────────────────────────────────────── */
.fs-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
  background: var(--chat-bot-bubble);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.fs-typing span {
  width: 7px;
  height: 7px;
  background: var(--chat-subtext);
  border-radius: 50%;
  animation: fsTyping 1.2s ease-in-out infinite;
}
.fs-typing span:nth-child(2) { animation-delay: 0.18s; }
.fs-typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes fsTyping {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%            { transform: translateY(-5px); opacity: 1; }
}

/* ── Quick Replies ──────────────────────────────────────────────────────────── */
#fs-quick-replies {
  padding: 0 14px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
}

.fs-qr-btn {
  background: var(--chat-surface);
  border: 1px solid var(--chat-border);
  color: var(--chat-primary);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
  font-family: var(--chat-font);
}

.fs-qr-btn:hover {
  background: var(--chat-primary);
  color: #fff;
  border-color: var(--chat-primary);
}

/* ── Input Area ─────────────────────────────────────────────────────────────── */
#fs-chat-input-area {
  border-top: 1px solid var(--chat-border);
  padding: 10px 12px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
  background: var(--chat-bg);
}

#fs-chat-input {
  flex: 1;
  border: 1px solid var(--chat-border);
  border-radius: 22px;
  padding: 9px 14px;
  font-size: 13.5px;
  font-family: var(--chat-font);
  resize: none;
  outline: none;
  background: var(--chat-surface);
  color: var(--chat-text);
  max-height: 90px;
  line-height: 1.4;
  transition: border-color 0.15s;
}

#fs-chat-input:focus { border-color: var(--chat-primary); }
#fs-chat-input::placeholder { color: var(--chat-subtext); }

#fs-chat-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--chat-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.15s;
  flex-shrink: 0;
}

#fs-chat-send:hover { background: #162f54; transform: scale(1.06); }
#fs-chat-send:disabled { opacity: 0.45; cursor: default; transform: none; }

/* ── Footer ─────────────────────────────────────────────────────────────────── */
#fs-chat-footer {
  padding: 5px 14px 8px;
  text-align: center;
  font-size: 10.5px;
  color: var(--chat-subtext);
  flex-shrink: 0;
  background: var(--chat-bg);
}

/* ── Mobile Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 440px) {
  :root {
    --chat-width: calc(100vw - 24px);
    --chat-height: 70vh;
  }

  #fs-chat-window {
    right: 12px;
    bottom: calc(var(--chat-btn-size) + 24px);
  }

  #fs-chat-toggle {
    right: 14px;
    bottom: 16px;
  }
}

/* ── Escalation Form ────────────────────────────────────────────────────────── */
.fs-escalate-form {
  background: var(--chat-bg);
  border: 1.5px solid var(--chat-accent);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  padding: 14px 16px;
  max-width: 90%;
  align-self: flex-start;
  animation: fsMsgIn 0.2s ease forwards;
}

.fs-escalate-form h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--chat-primary);
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.fs-escalate-form h4::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--chat-accent);
  flex-shrink: 0;
}

.fs-field {
  margin-bottom: 9px;
}

.fs-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--chat-subtext);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 3px;
}

.fs-field input,
.fs-field select,
.fs-field textarea {
  width: 100%;
  border: 1px solid var(--chat-border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: var(--chat-font);
  color: var(--chat-text);
  background: var(--chat-surface);
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s;
}

.fs-field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7a91' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}

.fs-field select:invalid,
.fs-field select option[value=""] {
  color: var(--chat-subtext);
}

.fs-field input:focus,
.fs-field select:focus,
.fs-field textarea:focus {
  border-color: var(--chat-primary);
}

/* Purpose field slide-in animation */
#fse-purpose-wrap {
  overflow: hidden;
  transition: max-height 0.2s ease, opacity 0.2s ease, margin-bottom 0.2s ease;
  max-height: 0;
  opacity: 0;
  margin-bottom: 0 !important;
}

#fse-purpose-wrap.visible {
  max-height: 80px;
  opacity: 1;
  margin-bottom: 9px !important;
}

.fs-field textarea {
  resize: none;
  height: 60px;
  line-height: 1.4;
}

.fs-field .fs-optional {
  font-weight: 400;
  opacity: 0.65;
  font-size: 10px;
  text-transform: none;
  letter-spacing: 0;
}

.fs-escalate-submit {
  width: 100%;
  margin-top: 10px;
  padding: 9px 0;
  background: var(--chat-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--chat-font);
  cursor: pointer;
  transition: background 0.15s;
}

.fs-escalate-submit:hover   { background: #162f54; }
.fs-escalate-submit:disabled { opacity: 0.5; cursor: default; }

.fs-escalate-error {
  font-size: 12px;
  color: #b92b2b;
  margin-top: 6px;
  display: none;
}
/* ── Booking Button (renders inside bot bubble) ─────────────────────────────── */
.fs-book-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--chat-primary);
  color: #ffffff !important;
  text-decoration: none !important;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  margin: 8px 0 4px;
  transition: background 0.15s;
  border: 1.5px solid transparent;
}
.fs-book-btn:hover {
  background: #162f54 !important;
  color: #ffffff !important;
}

/* ── Inline "Talk to a Person" Escalation Button ────────────────────────────── */
.fs-inline-escalate {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--chat-accent);
  color: var(--chat-primary);
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--chat-font);
  cursor: pointer;
  margin-top: 6px;
  align-self: flex-start;
  transition: background 0.15s, transform 0.1s;
}
.fs-inline-escalate:hover {
  background: var(--chat-accent-dark);
  transform: scale(1.03);
}
