/* Keta FAQ Chatbot — frontend styles */

#keta-chatbot, #keta-chatbot *, #keta-chatbot *::before, #keta-chatbot *::after {
  box-sizing: border-box;
}

#keta-chatbot {
  position: fixed;
  z-index: 99999;
  font-family: 'Raleway', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--kcb-primary, #3E5076);
  --kcb-radius: 16px;
  --kcb-line: #E0E4ED;
  --kcb-bg: #FFFFFF;
  --kcb-msg-bg: #F4F6FB;
  --kcb-text: #3E5076;
  --kcb-muted: #7E8AAB;
}

#keta-chatbot.kcb--bottom-right { right: 20px; bottom: 20px; }
#keta-chatbot.kcb--bottom-left  { left: 20px;  bottom: 20px; }

/* ============ Bubble ============ */
#keta-chatbot .kcb__bubble {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px 14px 18px;
  background: #FDD060 !important;
  color: #fff !important;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 2px rgba(62, 80, 118, 0.35);
  box-shadow: 0 6px 24px rgba(253, 208, 96, 0.45);
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
#keta-chatbot .kcb__bubble:hover {
  transform: translateY(-1px);
  background: #F0C040 !important;
  box-shadow: 0 8px 28px rgba(253, 208, 96, 0.55);
}
.kcb__bubble-icon {
  display: inline-flex;
  width: 22px; height: 22px;
  align-items: center; justify-content: center;
}
.kcb__bubble-label {
  white-space: nowrap;
}
@media (max-width: 480px) {
  .kcb__bubble-label { display: none; }
  .kcb__bubble { padding: 14px; }
}

/* ============ Panel ============ */
.kcb__panel {
  position: absolute;
  bottom: 70px;
  width: 380px;
  max-width: calc(100vw - 32px);
  max-height: 70vh;
  min-height: 420px;
  background: var(--kcb-bg);
  border: 1px solid var(--kcb-line);
  border-radius: var(--kcb-radius);
  box-shadow: 0 18px 50px rgba(62, 80, 118, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px) scale(.98);
  transform-origin: bottom right;
  transition: opacity .18s ease, transform .18s ease;
}
.kcb--bottom-right .kcb__panel { right: 0; }
.kcb--bottom-left  .kcb__panel { left: 0; transform-origin: bottom left; }

.kcb--open .kcb__panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* ============ Header ============ */
.kcb__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--kcb-primary, #3E5076);
  color: #fff;
  flex: 0 0 auto;
}
.kcb__header strong {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.kcb__close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background .15s;
}
.kcb__close:hover { background: rgba(255,255,255,.18); }

/* ============ Messages ============ */
.kcb__messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #FAFBFE;
}
.kcb__msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 14px;
  line-height: 1.45;
  font-size: 13.5px;
  word-wrap: break-word;
  animation: kcb-fade-in .18s ease;
}
.kcb__msg p { margin: 0 0 6px; }
.kcb__msg p:last-child { margin-bottom: 0; }
.kcb__msg ul, .kcb__msg ol { margin: 6px 0 6px 18px; padding: 0; }
.kcb__msg li { margin: 2px 0; }
.kcb__msg a { color: inherit; text-decoration: underline; }

.kcb__msg--bot {
  align-self: flex-start;
  background: var(--kcb-msg-bg);
  color: var(--kcb-text);
  border-bottom-left-radius: 4px;
}
.kcb__msg--user {
  align-self: flex-end;
  background: var(--kcb-primary, #3E5076);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.kcb__msg--suggestion {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--kcb-accent, #7CA1EF);
  color: var(--kcb-primary);
  cursor: pointer;
  font-weight: 600;
  transition: background .12s;
}
.kcb__msg--suggestion:hover {
  background: #EAF0FC;
}
#keta-chatbot .kcb__msg--matched-followup {
  align-self: flex-start;
  background: transparent;
  border: none;
  padding: 8px 0 0;
  color: #3E5076 !important;
  font-size: 12.5px;
  font-weight: 600;
}
#keta-chatbot .kcb__msg--matched-followup button {
  background: #fff !important;
  border: 1.5px solid #3E5076 !important;
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: #3E5076 !important;
  cursor: pointer;
  margin-right: 6px;
  margin-top: 6px;
  font-family: inherit;
  transition: all .12s;
}
#keta-chatbot .kcb__msg--matched-followup button:hover {
  background: #FDD060 !important;
  border-color: #FDD060 !important;
  color: #fff !important;
  text-shadow: 0 1px 2px rgba(62, 80, 118, 0.35);
}

.kcb__typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 4px;
  padding: 12px 14px;
  background: var(--kcb-msg-bg);
  border-radius: 14px;
}
.kcb__typing span {
  display: block;
  width: 7px;
  height: 7px;
  background: var(--kcb-muted);
  border-radius: 50%;
  animation: kcb-typing 1.2s infinite ease-in-out;
}
.kcb__typing span:nth-child(2) { animation-delay: .2s; }
.kcb__typing span:nth-child(3) { animation-delay: .4s; }

@keyframes kcb-typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30%           { opacity: 1;   transform: translateY(-3px); }
}
@keyframes kcb-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============ Compose ============ */
.kcb__compose {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--kcb-line);
  background: #fff;
}
.kcb__input {
  flex: 1 1 auto;
  width: 100%;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 14px;
  color: var(--kcb-text);
  background: #fff;
  border: 1px solid #C9D2E8;
  border-radius: 999px;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.kcb__input::placeholder { color: var(--kcb-muted); }
.kcb__input:focus {
  border-color: var(--kcb-primary);
  box-shadow: 0 0 0 3px rgba(124, 161, 239, 0.25);
}
#keta-chatbot .kcb__send {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  background: #FDD060 !important;
  color: #fff !important;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(253, 208, 96, 0.4);
  transition: background .15s, transform .1s, box-shadow .15s;
}
#keta-chatbot .kcb__send:hover {
  background: #F0C040 !important;
  box-shadow: 0 3px 8px rgba(253, 208, 96, 0.55);
}
#keta-chatbot .kcb__send:active { transform: scale(0.95); }
#keta-chatbot .kcb__send:disabled { opacity: 0.5; cursor: wait; }

/* ============ Email fallback form ============ */
.kcb__email-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--kcb-line);
  border-radius: 12px;
  margin: 6px 0;
  animation: kcb-fade-in .2s ease;
}
.kcb__email-intro {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--kcb-text);
}
.kcb__email-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kcb__email-form label span {
  font-size: 12px;
  font-weight: 600;
  color: var(--kcb-text);
}
.kcb__email-form label em {
  color: #C56565;
  font-style: normal;
  margin-left: 2px;
}
.kcb__email-form input,
.kcb__email-form textarea {
  width: 100%;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--kcb-text);
  background: #fff;
  border: 1px solid #C9D2E8;
  border-radius: 8px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  resize: vertical;
}
.kcb__email-form input:focus,
.kcb__email-form textarea:focus {
  border-color: var(--kcb-primary);
  box-shadow: 0 0 0 3px rgba(124, 161, 239, 0.25);
}
.kcb__email-form button {
  padding: 10px 18px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  border-radius: 999px;
  cursor: pointer;
  border: none;
  transition: background .15s;
}
.kcb__email-form button[type="submit"] {
  background: var(--kcb-primary, #3E5076);
  color: #fff;
}
.kcb__email-form button[type="submit"]:hover { background: #2D3A55; }
.kcb__email-form button[type="submit"]:disabled { opacity: .6; cursor: wait; }
.kcb__email-cancel {
  background: transparent !important;
  color: var(--kcb-muted) !important;
  border: 1px solid var(--kcb-line) !important;
}

.kcb__email-error {
  font-size: 12.5px;
  color: #9C2929;
  background: #FCEAEA;
  border: 1px solid #E9B8B8;
  padding: 8px 10px;
  border-radius: 6px;
}

.kcb__email-success {
  font-size: 13px;
  color: #1F6B3E;
  background: #E8F5EC;
  border: 1px solid #B9DDC2;
  padding: 10px 12px;
  border-radius: 8px;
}

/* ============ Mobile ============ */
@media (max-width: 480px) {
  .kcb__panel {
    width: calc(100vw - 24px);
    bottom: 70px;
    min-height: 60vh;
    max-height: calc(100vh - 100px);
  }
}

/* ─────────────────────────────────────────────
 * v1.5.0 — Identity gate (pre-chat name/email collection)
 * ───────────────────────────────────────────── */
#keta-chatbot .kcb__gate {
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 20px;
	overflow-y: auto;
	max-height: 100%;
}
#keta-chatbot .kcb__gate[hidden] {
	display: none !important;
}
#keta-chatbot .kcb__gate-intro {
	margin: 0 0 4px;
	font-size: 14px;
	line-height: 1.45;
	color: var(--kcb-primary, #3E5076);
}
#keta-chatbot .kcb__gate label {
	display: flex;
	flex-direction: column;
	gap: 4px;
	font-size: 13px;
	color: var(--kcb-primary, #3E5076);
}
#keta-chatbot .kcb__gate label span {
	font-weight: 600;
}
#keta-chatbot .kcb__gate label em {
	color: #c0392b;
	font-style: normal;
	margin-left: 2px;
}
#keta-chatbot .kcb__gate input[type="text"],
#keta-chatbot .kcb__gate input[type="email"] {
	width: 100%;
	padding: 10px 12px;
	border: 1px solid #C9D2E8;
	border-radius: 8px;
	font-size: 14px;
	font-family: inherit;
	background: #fff;
	color: var(--kcb-primary, #3E5076);
	box-sizing: border-box;
}
#keta-chatbot .kcb__gate input:focus {
	outline: none;
	border-color: var(--kcb-accent, #7CA1EF);
	box-shadow: 0 0 0 3px rgba(124, 161, 239, 0.18);
}
#keta-chatbot .kcb__gate-submit {
	background: #FDD060 !important;
	color: var(--kcb-primary, #3E5076) !important;
	border: none;
	padding: 12px 16px;
	border-radius: 8px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	margin-top: 4px;
	text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
	transition: filter 0.18s ease;
	font-family: inherit;
}
#keta-chatbot .kcb__gate-submit:hover {
	filter: brightness(0.96);
}
#keta-chatbot .kcb__gate-submit:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}
#keta-chatbot .kcb__gate-privacy {
	margin: 4px 0 0;
	font-size: 11px;
	line-height: 1.4;
	color: #7E8AAB;
}
#keta-chatbot .kcb__gate-error {
	background: #fff3f2;
	border: 1px solid #ffd1cd;
	color: #b3261e;
	padding: 8px 10px;
	border-radius: 6px;
	font-size: 12px;
	line-height: 1.4;
}
