/* Key AI Chat - Widget Styles */
:root { --kac-color: #2563eb; }

#kac-chat-bubble {
  position: fixed;
  bottom: 20px;
  width: 56px;
  height: 56px;
  background: var(--kac-color);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0,0,0,.25);
  z-index: 99998;
  transition: transform .2s, box-shadow .2s;
}
#kac-chat-bubble:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(0,0,0,.3); }

#kac-unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  display: none;
}

#kac-chat-window {
  position: fixed;
  bottom: 90px;
  width: 360px;
  max-height: 580px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  overflow: hidden;
  animation: kac-slide-up .25s ease;
}
@keyframes kac-slide-up {
  from { opacity:0; transform:translateY(16px); }
  to   { opacity:1; transform:translateY(0); }
}

#kac-chat-header {
  background: var(--kac-color);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
#kac-header-info { display: flex; align-items: center; gap: 10px; }
#kac-avatar {
  width: 36px; height: 36px;
  background: rgba(255,255,255,.25);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
#kac-bot-name  { font-weight: 700; font-size: 15px; }
#kac-status-text { font-size: 12px; opacity: .85; }
#kac-close-btn {
  background: rgba(255,255,255,.2);
  border: none; color: #fff;
  width: 28px; height: 28px;
  border-radius: 50%; cursor: pointer;
  font-size: 14px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
#kac-close-btn:hover { background: rgba(255,255,255,.35); }

#kac-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 200px;
  max-height: 320px;
}

.kac-msg { display: flex; flex-direction: column; max-width: 85%; }
.kac-msg.kac-user  { align-self: flex-end; align-items: flex-end; }
.kac-msg.kac-bot   { align-self: flex-start; align-items: flex-start; }
.kac-msg.kac-agent { align-self: flex-start; align-items: flex-start; }
.kac-msg.kac-system { align-self: center; }

.kac-bubble {
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
}
.kac-msg.kac-user  .kac-bubble { background: var(--kac-color); color: #fff; border-bottom-right-radius: 4px; }
.kac-msg.kac-bot   .kac-bubble { background: #f1f5f9; color: #1e293b; border-bottom-left-radius: 4px; }
.kac-msg.kac-agent .kac-bubble { background: #d1fae5; color: #064e3b; border-bottom-left-radius: 4px; }
.kac-msg.kac-system .kac-bubble { background: #fef3c7; color: #92400e; font-size: 12px; border-radius: 20px; }

.kac-msg-meta { font-size: 11px; color: #9ca3af; margin-top: 3px; }
.kac-agent-label { font-size: 11px; color: #047857; font-weight: 600; margin-bottom: 3px; }

#kac-typing-indicator {
  padding: 0 16px 8px;
  display: flex;
  gap: 4px;
  align-items: center;
}
#kac-typing-indicator span {
  width: 7px; height: 7px;
  background: #9ca3af;
  border-radius: 50%;
  animation: kac-bounce .9s infinite ease-in-out;
}
#kac-typing-indicator span:nth-child(2) { animation-delay: .15s; }
#kac-typing-indicator span:nth-child(3) { animation-delay: .3s; }
@keyframes kac-bounce {
  0%,80%,100% { transform: scale(0.6); opacity:.5; }
  40% { transform: scale(1); opacity:1; }
}

/* Visitor form */
#kac-visitor-form {
  padding: 16px;
  border-top: 1px solid #f1f5f9;
  background: #f8fafc;
}
#kac-visitor-form p { font-size: 13px; color: #64748b; margin-bottom: 10px; }
#kac-visitor-form input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 8px;
  outline: none;
  font-family: inherit;
}
#kac-visitor-form input:focus { border-color: var(--kac-color); }
#kac-visitor-submit {
  width: 100%;
  background: var(--kac-color);
  color: #fff;
  border: none;
  padding: 10px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 600;
}
#kac-visitor-submit:hover { opacity: .9; }

/* Input area */
#kac-input-area {
  padding: 12px;
  border-top: 1px solid #f1f5f9;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}
#kac-input {
  flex: 1;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 14px;
  resize: none;
  outline: none;
  font-family: inherit;
  max-height: 100px;
  overflow-y: auto;
  line-height: 1.4;
}
#kac-input:focus { border-color: var(--kac-color); }
#kac-send-btn {
  background: var(--kac-color);
  border: none;
  border-radius: 10px;
  width: 38px; height: 38px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#kac-send-btn:hover { opacity: .85; }

/* Agent request bar */
#kac-agent-request-bar {
  padding: 8px 12px;
  border-top: 1px solid #f1f5f9;
  text-align: center;
}
#kac-request-agent {
  background: none;
  border: 1px solid var(--kac-color);
  color: var(--kac-color);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: .15s;
}
#kac-request-agent:hover { background: var(--kac-color); color: #fff; }

/* Mobile */
@media (max-width: 480px) {
  #kac-chat-window {
    width: calc(100vw - 20px);
    bottom: 80px;
    left: 10px !important;
    right: 10px !important;
  }
}
