/* KB Live Chat — chat-widget.css */
#kbc-widget * { box-sizing: border-box; font-family: -apple-system, 'Segoe UI', Roboto, sans-serif; }

/* ── Trigger Button ── */
.kbc-trigger {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--accent, #f9572e);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(249,87,46,.45);
  z-index: 9998;
  transition: transform .2s, box-shadow .2s;
  color: #fff;
}
.kbc-trigger:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(249,87,46,.55); }
.kbc-unread-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e53935;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}

/* ── Chat Panel ── */
.kbc-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 360px;
  max-height: 580px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 8px 48px rgba(0,0,0,.18);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  animation: kbc-slide-up .25s ease;
}
.kbc-panel.open { display: flex; }
@keyframes kbc-slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Panel Header ── */
.kbc-panel__header {
  background: var(--accent, #f9572e);
  padding: 16px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
  flex-shrink: 0;
}
.kbc-panel__header-info { display: flex; align-items: center; gap: 12px; }
.kbc-panel__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.kbc-panel__title { font-weight: 700; font-size: 14px; }
.kbc-panel__subtitle { font-size: 11px; opacity: .85; display: flex; align-items: center; gap: 5px; margin-top: 2px; }
.kbc-online-dot { width: 7px; height: 7px; border-radius: 50%; background: #69f0ae; display: inline-block; }
.kbc-panel__close { background: none; border: none; color: rgba(255,255,255,.8); cursor: pointer; padding: 4px; border-radius: 4px; display: flex; }
.kbc-panel__close:hover { color: #fff; }

/* ── Start Form ── */
.kbc-start-form { padding: 16px; overflow-y: auto; flex: 1; }
.kbc-greeting {
  background: #f0f7ff;
  border-left: 3px solid var(--accent, #f9572e);
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
  font-size: 13px;
  color: #333;
  margin-bottom: 16px;
  line-height: 1.5;
}
.kbc-form-group { margin-bottom: 12px; }
.kbc-form-group label { display: block; font-size: 11px; color: #666; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; font-weight: 600; }
.kbc-form-group input,
.kbc-form-group select {
  width: 100%;
  border: 1.5px solid #e0e0e0;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  color: #1a1a1a;
  outline: none;
  transition: border .15s;
  background: #fafafa;
}
.kbc-form-group input:focus,
.kbc-form-group select:focus { border-color: var(--accent, #f9572e); background: #fff; }
.kbc-form-error { background: #ffeaea; color: #c62828; font-size: 12px; padding: 8px 12px; border-radius: 6px; margin-bottom: 10px; }
.kbc-start-btn {
  width: 100%;
  background: var(--accent, #f9572e);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 13px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s;
  text-align: center;
  display: block;
}
.kbc-start-btn:hover { opacity: .9; }
.kbc-start-btn:disabled { opacity: .6; cursor: not-allowed; }

/* ── Chat View ── */
.kbc-chat-view { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.kbc-chat-info-bar {
  background: #f5f5f5;
  padding: 6px 14px;
  font-size: 11px;
  color: #777;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}
.kbc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}

/* Message bubbles */
.kbc-msg { display: flex; flex-direction: column; max-width: 80%; }
.kbc-msg--visitor { align-self: flex-end; align-items: flex-end; }
.kbc-msg--agent   { align-self: flex-start; align-items: flex-start; }
.kbc-msg--system  { align-self: center; }
.kbc-msg__bubble {
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}
.kbc-msg--visitor .kbc-msg__bubble { background: var(--accent, #f9572e); color: #fff; border-radius: 14px 14px 4px 14px; }
.kbc-msg--agent .kbc-msg__bubble   { background: #f0f0f0; color: #1a1a1a; border-radius: 14px 14px 14px 4px; }
.kbc-msg--system .kbc-msg__bubble  { background: #fff3cd; color: #7a5a00; font-size: 11px; padding: 5px 12px; border-radius: 12px; }
.kbc-msg__time { font-size: 10px; color: #aaa; margin-top: 3px; padding: 0 4px; }
.kbc-msg__sender { font-size: 11px; color: #888; margin-bottom: 3px; padding: 0 4px; }

/* Input bar */
.kbc-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #eee;
  flex-shrink: 0;
}
.kbc-input-bar textarea {
  flex: 1;
  border: 1.5px solid #e0e0e0;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  resize: none;
  outline: none;
  font-family: inherit;
  max-height: 100px;
  overflow-y: auto;
  transition: border .15s;
}
.kbc-input-bar textarea:focus { border-color: var(--accent, #f9572e); }
.kbc-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent, #f9572e);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  transition: opacity .15s;
}
.kbc-send-btn:hover { opacity: .85; }
.kbc-end-bar { padding: 6px 12px 10px; text-align: center; flex-shrink: 0; }
.kbc-end-btn { background: none; border: none; color: #e53935; font-size: 12px; cursor: pointer; text-decoration: underline; }
.kbc-ended-msg { padding: 32px 20px; text-align: center; color: #555; }
.kbc-ended-msg strong { display: block; font-size: 16px; color: #1a1a1a; margin-bottom: 8px; }
.kbc-ended-msg p { font-size: 13px; line-height: 1.6; }

/* Typing indicator */
.kbc-typing { align-self: flex-start; }
.kbc-typing__dots { display: flex; gap: 4px; padding: 10px 14px; background: #f0f0f0; border-radius: 14px 14px 14px 4px; }
.kbc-typing__dots span { width: 6px; height: 6px; background: #aaa; border-radius: 50%; animation: kbc-bounce .9s infinite; }
.kbc-typing__dots span:nth-child(2) { animation-delay: .15s; }
.kbc-typing__dots span:nth-child(3) { animation-delay: .3s; }
@keyframes kbc-bounce { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-6px)} }

@media (max-width: 480px) {
  .kbc-panel { right: 12px; left: 12px; width: auto; bottom: 88px; }
  .kbc-trigger { right: 16px; bottom: 16px; }
}
