/* ─── BkAI Chat Widget Styles v1.2 ─── */
:root {
  --bkai-primary: #004899;
  --bkai-primary-hover: #003b80;
  --bkai-primary-light: #e8f0fe;
  --bkai-bg: #ffffff;
  --bkai-text: #1a1a2e;
  --bkai-text-muted: #6b7280;
  --bkai-border: #e2e8f0;
  --bkai-shadow: 0 4px 24px rgba(0,0,0,.1);
  --bkai-radius: 12px;
  --bkai-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ─── Chat Button (floating icon) ─── */
#bkai-root .bkai-button {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bkai-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  z-index: 2147483647;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,72,153,.35);
  transition: transform .2s ease, opacity .3s ease;
  user-select: none;
}
#bkai-root .bkai-button:hover {
  transform: scale(1.08);
}
#bkai-root .bkai-button svg {
  width: 26px;
  height: 26px;
}
#bkai-root .bkai-button.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(.85);
}

/* ─── Chat Window ─── */
#bkai-root .bkai-window {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 380px;
  height: 600px;
  max-height: calc(100vh - 100px);
  background: var(--bkai-bg);
  border-radius: var(--bkai-radius);
  box-shadow: var(--bkai-shadow);
  display: flex;
  flex-direction: column;
  z-index: 2147483646;
  overflow: hidden;
  font-family: var(--bkai-font);
  line-height: 1.5;
  color: var(--bkai-text);
  opacity: 0;
  transform: translateY(16px) scale(.96);
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: none;
}
#bkai-root .bkai-window.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ─── Header ─── */
#bkai-root .bkai-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--bkai-primary);
  color: #fff;
  flex-shrink: 0;
  user-select: none;
}
#bkai-root .bkai-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
  font-weight: 700;
}
#bkai-root .bkai-header-info { flex: 1; min-width: 0; }
#bkai-root .bkai-header-name { font-size: 14px; font-weight: 600; }
#bkai-root .bkai-header-status {
  font-size: 11px;
  opacity: .8;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}
#bkai-root .bkai-header-status .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34d399;
  display: inline-block;
}
#bkai-root .bkai-close-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px;
  opacity: .8;
  transition: opacity .2s;
  display: flex;
}
#bkai-root .bkai-close-btn:hover { opacity: 1; }
#bkai-root .bkai-close-btn svg { width: 18px; height: 18px; }

/* ─── Messages Area ─── */
#bkai-root .bkai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}
#bkai-root .bkai-messages::-webkit-scrollbar { width: 4px; }
#bkai-root .bkai-messages::-webkit-scrollbar-thumb { background: var(--bkai-border); border-radius: 2px; }

/* ─── Message Bubbles ─── */
#bkai-root .bkai-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  word-wrap: break-word;
  animation: bkai-fade-in .2s ease;
}
#bkai-root .bkai-msg.user {
  align-self: flex-end;
  background: var(--bkai-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
#bkai-root .bkai-msg.bot {
  align-self: flex-start;
  background: #fff;
  color: var(--bkai-text);
  border: 1px solid var(--bkai-border);
  border-bottom-left-radius: 4px;
}
#bkai-root .bkai-msg.bot a { color: var(--bkai-primary); text-decoration: underline; }
#bkai-root .bkai-msg .time {
  display: block;
  font-size: 10px;
  margin-top: 4px;
  opacity: .6;
}
#bkai-root .bkai-msg.user .time { text-align: right; }

/* ─── Welcome Message ─── */
#bkai-root .bkai-welcome {
  text-align: center;
  padding: 32px 12px;
  color: var(--bkai-text-muted);
}
#bkai-root .bkai-welcome-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bkai-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
}
#bkai-root .bkai-welcome-icon svg { width: 24px; height: 24px; color: var(--bkai-primary); }
#bkai-root .bkai-welcome h3 { font-size: 15px; font-weight: 600; color: var(--bkai-text); margin-bottom: 4px; }
#bkai-root .bkai-welcome p { font-size: 13px; line-height: 1.5; }

/* ─── Typing Indicator ─── */
#bkai-root .bkai-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid var(--bkai-border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}
#bkai-root .bkai-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--bkai-text-muted);
  animation: bkai-typing 1.2s ease-in-out infinite;
}
#bkai-root .bkai-typing span:nth-child(2) { animation-delay: .2s; }
#bkai-root .bkai-typing span:nth-child(3) { animation-delay: .4s; }

/* ─── Input Area (no send button) ─── */
#bkai-root .bkai-input-area {
  padding: 12px 16px 8px;
  border-top: 1px solid var(--bkai-border);
  background: #fff;
  flex-shrink: 0;
}
#bkai-root .bkai-input-wrap {
  position: relative;
}
#bkai-root .bkai-input {
  width: 100%;
  border: none;
  padding: 10px 0;
  font-size: 13px;
  font-family: var(--bkai-font);
  resize: none;
  outline: none;
  line-height: 1.5;
  max-height: 100px;
  min-height: 20px;
  color: var(--bkai-text);
  background: transparent;
  box-sizing: border-box;
  display: block;
}
#bkai-root .bkai-input::placeholder { color: var(--bkai-text-muted); }
/* Bottom divider line */
#bkai-root .bkai-divider {
  height: 1px;
  background: var(--bkai-border);
  margin-top: 2px;
  transition: background .2s;
}
#bkai-root .bkai-input:focus + .bkai-divider {
  background: var(--bkai-primary);
}

/* ─── Error Message ─── */
#bkai-root .bkai-msg.error {
  align-self: center;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  font-size: 12px;
  max-width: 90%;
  text-align: center;
}

/* ─── Animations ─── */
@keyframes bkai-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes bkai-typing {
  0%, 80%, 100% { opacity: .3; transform: scale(.85); }
  40% { opacity: 1; transform: scale(1); }
}

/* ─── Responsive ─── */
@media(max-width: 480px) {
  #bkai-root .bkai-window {
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }
  #bkai-root .bkai-button {
    bottom: 16px;
    right: 16px;
  }
}
