/* ── ChatBot Widget ────────────────────────────────────────── */
.cs-chatbot {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1200;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

/* ── Toggle Button ─────────────────────────────────────────── */
.cs-chatbot-toggle {
  position: relative;
  width: 62px;
  height: 62px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(145deg, #1a56db 0%, #0a3d91 60%, #072d6e 100%);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(10, 61, 145, 0.45), 0 2px 6px rgba(10, 61, 145, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.25s ease,
              background 0.25s ease;
  overflow: visible;
}

.cs-chatbot-toggle:hover {
  transform: scale(1.12) translateY(-2px);
  box-shadow: 0 12px 32px rgba(10, 61, 145, 0.55), 0 4px 10px rgba(10, 61, 145, 0.3);
  background: linear-gradient(145deg, #2563eb 0%, #1a4fc4 60%, #0a3d91 100%);
}

.cs-chatbot-toggle:active {
  transform: scale(0.96);
  box-shadow: 0 4px 12px rgba(10, 61, 145, 0.4);
}

.cs-chatbot.open .cs-chatbot-toggle {
  display: none;
}

.cs-chatbot-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.25));
}

.cs-chatbot-toggle:hover .cs-chatbot-icon {
  transform: rotate(-8deg) scale(1.08);
}

/* Pulse ring animation */
.cs-chatbot-pulse {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid rgba(26, 86, 219, 0.6);
  animation: cs-pulse 2.4s ease-out infinite;
  pointer-events: none;
}

.cs-chatbot.open .cs-chatbot-pulse {
  animation: none;
  opacity: 0;
}

@keyframes cs-pulse {
  0%   { transform: scale(1);    opacity: 0.7; }
  70%  { transform: scale(1.55); opacity: 0; }
  100% { transform: scale(1.55); opacity: 0; }
}

/* ── Chat Panel ────────────────────────────────────────────── */
.cs-chatbot-panel {
  display: none;
  width: min(430px, calc(100vw - 24px));
  height: min(600px, calc(100vh - 90px));
  background: var(--cs-surface-ffffff, #fff);
  border: 1px solid var(--cs-line-dbe3f1, #dbe3f1);
  border-radius: 18px;
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.2), 0 4px 12px rgba(15, 23, 42, 0.1);
  margin-bottom: 12px;
  overflow: hidden;
  transform-origin: bottom right;
  animation: cs-panel-in 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cs-chatbot.open .cs-chatbot-panel {
  display: flex;
  flex-direction: column;
}

@keyframes cs-panel-in {
  from { opacity: 0; transform: scale(0.85) translateY(12px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

/* ── Header ────────────────────────────────────────────────── */
.cs-chatbot-header {
  padding: 13px 16px;
  background: linear-gradient(135deg, #1a56db 0%, #0a3d91 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}

.cs-chatbot-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cs-chatbot-header-avatar {
  width: 34px;
  height: 34px;
  background: var(--cs-surface-white-018, rgba(255,255,255,0.18));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1.5px solid rgba(255,255,255,0.3);
}

.cs-chatbot-title {
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.2px;
}

.cs-chatbot-subtitle {
  font-size: 11px;
  opacity: 0.85;
  margin-top: 1px;
}

.cs-chatbot-close {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: var(--cs-surface-white-015, rgba(255, 255, 255, 0.15));
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
  flex-shrink: 0;
}

.cs-chatbot-close:hover {
  background: var(--cs-surface-white-03, rgba(255, 255, 255, 0.3));
  transform: rotate(90deg) scale(1.1);
}

.cs-chatbot-close:active {
  transform: rotate(90deg) scale(0.95);
}

/* ── Body / Messages ───────────────────────────────────────── */
.cs-chatbot-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  background: var(--cs-surface-f5f8ff, #f5f8ff);
  scroll-behavior: smooth;
}

.cs-chatbot-body::-webkit-scrollbar {
  width: 4px;
}
.cs-chatbot-body::-webkit-scrollbar-track {
  background: transparent;
}
.cs-chatbot-body::-webkit-scrollbar-thumb {
  background: var(--cs-surface-c6d4ef, #c6d4ef);
  border-radius: 4px;
}

.cs-chatbot-msg {
  max-width: 92%;
  padding: 11px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  animation: cs-msg-in 0.22s ease;
}

@keyframes cs-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.cs-chatbot-msg.bot {
  align-self: flex-start;
  background: var(--cs-surface-ffffff, #fff);
  color: var(--cs-ink-0f172a, #0f172a);
  border: 1px solid var(--cs-line-e2eaf8, #e2eaf8);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(10, 61, 145, 0.08);
}

.cs-chatbot-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #1a56db 0%, #0a3d91 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(10, 61, 145, 0.3);
}

/* ── Suggest Chips ─────────────────────────────────────────── */
.cs-chatbot-suggest {
  padding: 0;
  border-top: 1px solid var(--cs-line-e8eef8, #e8eef8);
  background: var(--cs-surface-fafbfc, #fafbfc);
  flex-shrink: 0;
  max-height: 180px;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.cs-chatbot-suggest:empty {
  display: none;
}

.cs-chatbot-suggest.hidden {
  max-height: 32px;
  padding: 0;
}

.cs-chatbot-suggest-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--cs-surface-fafbfc, #fafbfc);
  gap: 8px;
  border-bottom: 1px solid var(--cs-line-e8eef8, #e8eef8);
}

.cs-chatbot-suggest-header:hover {
  background: var(--cs-surface-f0f4f8, #f0f4f8);
}

.cs-chatbot-suggest-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--cs-ink-334155, #334155);
  flex: 1;
  letter-spacing: 0.3px;
}

.cs-chatbot-suggest-btn {
  border: none;
  background: none;
  color: var(--cs-ink-0a3d91, #0a3d91);
  padding: 4px 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  font-size: 14px;
}

.cs-chatbot-suggest-btn:hover {
  color: var(--cs-ink-1a56db, #1a56db);
  transform: scale(1.15);
}

.cs-chatbot-suggest-btn:active {
  transform: scale(0.95);
}

.cs-chatbot-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px 10px;
}

.cs-chatbot-chip {
  border: 1.5px solid var(--cs-line-c6d4ef, #c6d4ef);
  background: var(--cs-surface-f0f5ff, #f0f5ff);
  color: var(--cs-ink-1a56db, #1a56db);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease,
              color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.cs-chatbot-chip:hover {
  background: #1a56db;
  color: #fff;
  border-color: #1a56db;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(26, 86, 219, 0.3);
}

.cs-chatbot-chip:active {
  transform: translateY(0);
  box-shadow: none;
}

/* ── Form / Input ──────────────────────────────────────────── */
.cs-chatbot-form {
  border-top: 1px solid var(--cs-line-e8eef8, #e8eef8);
  background: var(--cs-surface-ffffff, #fff);
  padding: 10px 12px;
  display: block;
  flex-shrink: 0;
}

.cs-chatbot-voice-status {
  min-width: 0;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 8px;
  color: var(--cs-ink-475569, #475569);
  font-size: 11px;
  line-height: 1.35;
}

.cs-chatbot-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cs-chatbot-input {
  flex: 1;
  border: 1.5px solid var(--cs-line-cbd5e1, #cbd5e1);
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  color: var(--cs-ink-0f172a, #0f172a);
  background: var(--cs-surface-f8fafc, #f8fafc);
}

.cs-chatbot-input:focus {
  border-color: #1a56db;
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.12);
  background: var(--cs-surface-ffffff, #fff);
}

.cs-chatbot-send {
  border: none;
  border-radius: 12px;
  width: 38px;
  height: 38px;
  min-width: 38px;
  background: linear-gradient(135deg, #1a56db 0%, #0a3d91 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.2s ease,
              background 0.2s ease;
  box-shadow: 0 3px 10px rgba(10, 61, 145, 0.35);
}

.cs-chatbot-send:hover {
  transform: scale(1.1) translateY(-1px);
  box-shadow: 0 6px 16px rgba(10, 61, 145, 0.45);
  background: linear-gradient(135deg, #2563eb 0%, #1a4fc4 100%);
}

.cs-chatbot-send:active {
  transform: scale(0.95);
  box-shadow: 0 2px 6px rgba(10, 61, 145, 0.3);
}

.cs-chatbot-send.listening {
  background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
  animation: cs-chatbot-listening 1.15s ease-in-out infinite;
}

.cs-chatbot-send:disabled {
  background: #94a3b8;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.7;
  transform: none;
}

@keyframes cs-chatbot-listening {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.45); }
  50% { box-shadow: 0 0 0 7px rgba(239, 68, 68, 0); }
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .cs-chatbot {
    right: 14px;
    bottom: 14px;
  }

  .cs-chatbot-toggle {
    width: 56px;
    height: 56px;
  }

  .cs-chatbot-panel {
    width: min(370px, calc(100vw - 20px));
    height: min(560px, calc(100vh - 80px));
  }

  .cs-chatbot-input-row {
    gap: 6px;
  }
}

/* Device-safe sizing: mobile browser chrome and notches must not cover controls. */
.cs-chatbot,
.cs-chatbot * {
  box-sizing: border-box;
}

.cs-chatbot-panel {
  max-width: calc(100vw - 16px);
  max-height: calc(100dvh - 24px);
}

.cs-chatbot-title,
.cs-chatbot-subtitle,
.cs-chatbot-msg,
.cs-chatbot-voice-status,
.cs-chatbot-input-row {
  min-width: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 640px) {
  .cs-chatbot {
    right: max(8px, env(safe-area-inset-right)) !important;
    bottom: max(8px, env(safe-area-inset-bottom)) !important;
  }

  .cs-chatbot-panel {
    right: 0;
    bottom: 62px;
    width: calc(100vw - 16px) !important;
    height: min(560px, calc(100dvh - 86px)) !important;
    max-height: calc(100dvh - 86px) !important;
  }

  .cs-chatbot-header {
    padding: 10px 12px;
  }

  .cs-chatbot-voice-status { white-space: normal; }
}

@media (max-width: 360px) {
  .cs-chatbot-panel {
    width: calc(100vw - 12px) !important;
  }

  .cs-chatbot-subtitle {
    display: none;
  }

  .cs-chatbot-form {
    padding-inline: 8px;
  }

  .cs-chatbot-input-row {
    gap: 4px;
  }

  .cs-chatbot-send {
    min-width: 38px;
    padding-inline: 8px;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .cs-chatbot-panel {
    height: calc(100dvh - 16px) !important;
    max-height: calc(100dvh - 16px) !important;
    bottom: 0;
  }
}

/* One viewport budget, including the software keyboard, on every page. */
.cs-chatbot { bottom:calc(var(--assistant-keyboard, 0px) + max(8px, env(safe-area-inset-bottom))) !important; right:max(8px, env(safe-area-inset-right)) !important; }
.cs-chatbot .cs-chatbot-panel {
  width:min(430px, calc(100vw - 16px)) !important;
  height:min(600px, calc(var(--assistant-height, 100dvh) - 24px)) !important;
  max-height:calc(var(--assistant-height, 100dvh) - 24px) !important;
  margin-bottom:0 !important; bottom:auto !important;
}
.cs-chatbot-header, .cs-chatbot-form { flex-shrink:0; }
.cs-chatbot-body { flex:1 1 auto; min-height:0; }
.cs-chatbot-close { flex:0 0 44px; width:44px; height:44px; padding:0; -webkit-appearance:none; appearance:none; }
.cs-chatbot-close svg { flex:none; width:20px; height:20px; display:block; }
.cs-chatbot-input { min-width:0; font-size:16px; }
.cs-chatbot-send { min-width:44px; min-height:44px; padding:0; }
.cs-chatbot-send svg { flex:none; }
.cs-chatbot .cs-chatbot-listen { align-self:flex-start; min-height:44px; padding:8px 12px; margin:0 0 4px; border:1px solid var(--cs-line-dbe3f1,#dbe3f1); border-radius:9px; color:var(--cs-ink-0a3d91,#0a3d91); background:var(--cs-surface-ffffff,#fff); font:inherit; font-size:13px; font-weight:600; cursor:pointer; }
.cs-chatbot .cs-chatbot-listen[hidden] { display:none; }
.cs-chatbot .cs-chatbot-listen:focus-visible { outline:2px solid #2563eb; outline-offset:2px; }
@media (max-height:520px) { .cs-chatbot-suggest, .cs-chatbot-subtitle { display:none; } .cs-chatbot-header, .cs-chatbot-form { padding:8px 12px; } }
.cs-chatbot .cs-chatbot-privacy {
  margin: 0;
  padding: 6px 14px;
  font-size: 11px;
  line-height: 1.4;
  color: inherit;
  opacity: .8;
}
.cs-chatbot .cs-chatbot-match-action {
  display: block;
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  background: #176b50;
  color: #fff;
  text-decoration: none;
  font-weight: 600;
}
.cs-chatbot .cs-chatbot-match-action:focus-visible {
  outline: 3px solid #e7ab22;
  outline-offset: 2px;
}
