/* ── KIARA AI CHAT WIDGET STYLES ──
   Showroom Digital Tunas Toyota Kiaracondong
   Clean corporate styling, dark-mode aware, fully responsive
*/

.kiara-chat-wrapper {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
}

@media (max-width: 1023px) {
  .kiara-chat-wrapper {
    bottom: 80px;
    right: 16px;
  }
}

/* Floating Action Button (FAB) */
.kiara-fab-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
  color: #ffffff;
  border: 2.5px solid #ffffff;
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
  padding: 0;
}

.kiara-fab-btn:hover {
  transform: translateY(-4px) scale(1.06);
  box-shadow: 0 12px 28px rgba(239, 68, 68, 0.5);
}

.kiara-fab-btn:active {
  transform: scale(0.95);
}

.kiara-fab-btn img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}

.kiara-fab-badge {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 13px;
  height: 13px;
  background: #22c55e;
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

/* Chat Window Modal */
.kiara-chat-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: var(--bg-surface, #ffffff);
  border-radius: 20px;
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.2), 0 0 0 1px var(--border-color, rgba(0,0,0,0.08));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.96);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (max-width: 1023px) {
  .kiara-chat-window {
    bottom: 84px;
    right: 16px;
    width: calc(100vw - 32px);
    height: calc(100vh - 170px);
  }
}

.kiara-chat-window.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Chat Header */
.kiara-chat-header {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #ffffff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.2);
}

.kiara-chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.kiara-header-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  overflow: hidden;
  background: #ffffff;
  flex-shrink: 0;
}

.kiara-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.kiara-header-status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #ffffff;
}

.kiara-header-titles strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.2px;
  line-height: 1.2;
}

.kiara-header-titles span {
  display: block;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.88);
  font-weight: 500;
}

.kiara-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.kiara-header-btn {
  background: rgba(255, 255, 255, 0.18);
  border: none;
  color: #ffffff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  outline: none;
}

.kiara-header-btn:hover {
  background: rgba(255, 255, 255, 0.32);
  transform: scale(1.08);
}

/* Chat Body (Messages) */
.kiara-chat-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-body, #f8fafc);
  scroll-behavior: smooth;
}

/* Message Bubble */
.kiara-msg {
  display: flex;
  gap: 10px;
  max-width: 88%;
  animation: fadeInMsg 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeInMsg {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.kiara-msg.bot {
  align-self: flex-start;
}

.kiara-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.kiara-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--border-color, rgba(0,0,0,0.1));
  flex-shrink: 0;
  background: #ffffff;
}

.kiara-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.kiara-msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

.kiara-msg.bot .kiara-msg-bubble {
  background: var(--bg-card, #ffffff);
  color: var(--text-dark, #0f172a);
  border: 1px solid var(--border-color, rgba(0,0,0,0.08));
  border-top-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

.kiara-msg.user .kiara-msg-bubble {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #ffffff;
  border-top-right-radius: 4px;
  box-shadow: 0 3px 12px rgba(239, 68, 68, 0.25);
}

.kiara-msg-bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 11.5px;
}

.kiara-msg-bubble th, 
.kiara-msg-bubble td {
  padding: 5px 8px;
  border: 1px solid var(--border-color, #e2e8f0);
  text-align: left;
}

.kiara-msg-bubble th {
  background: rgba(0,0,0,0.04);
  font-weight: 700;
}

.kiara-msg-bubble ul, 
.kiara-msg-bubble ol {
  margin: 6px 0 6px 18px;
  padding: 0;
}

.kiara-msg-time {
  font-size: 10px;
  color: var(--text-muted, #94a3b8);
  margin-top: 4px;
  text-align: right;
}

/* Typing Indicator */
.kiara-typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: var(--bg-card, #ffffff);
  border-radius: 14px;
  border-top-left-radius: 4px;
  width: fit-content;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  border: 1px solid var(--border-color, rgba(0,0,0,0.06));
}

.kiara-typing-dot {
  width: 6px;
  height: 6px;
  background: #ef4444;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.kiara-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.kiara-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Quick Suggestion Chips */
.kiara-quick-chips {
  padding: 8px 12px;
  background: var(--bg-surface, #ffffff);
  border-top: 1px solid var(--border-color, rgba(0,0,0,0.06));
  display: flex;
  gap: 8px;
  overflow-x: auto;
  white-space: nowrap;
  flex-shrink: 0;
  scrollbar-width: none;
}

.kiara-quick-chips::-webkit-scrollbar {
  display: none;
}

.kiara-chip-btn {
  background: rgba(239, 68, 68, 0.08);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 50px;
  padding: 6px 12px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  outline: none;
  white-space: nowrap;
}

.kiara-chip-btn:hover {
  background: #ef4444;
  color: #ffffff;
  transform: translateY(-1px);
}

/* Chat Footer & Input */
.kiara-chat-footer {
  padding: 10px 14px;
  background: var(--bg-surface, #ffffff);
  border-top: 1px solid var(--border-color, rgba(0,0,0,0.08));
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.kiara-chat-input-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kiara-chat-input {
  flex: 1;
  background: var(--bg-body, #f1f5f9);
  border: 1.5px solid transparent;
  border-radius: 50px;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-dark, #0f172a);
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  font-family: inherit;
}

.kiara-chat-input:focus {
  background: #ffffff;
  border-color: #ef4444;
}

.kiara-chat-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #ef4444;
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: transform 0.2s, background 0.2s;
  outline: none;
  flex-shrink: 0;
}

.kiara-chat-send-btn:hover {
  background: #dc2626;
  transform: scale(1.06);
}

.kiara-chat-send-btn:active {
  transform: scale(0.92);
}

.kiara-chat-wa-direct {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 11px;
  color: #15803d;
  font-weight: 600;
  text-decoration: none;
  padding: 4px;
  border-radius: 6px;
  transition: background 0.2s;
}

.kiara-chat-wa-direct:hover {
  background: rgba(34, 197, 94, 0.08);
}

/* Dark Mode Overrides */
[data-theme="dark"] .kiara-chat-window {
  background: #1e293b;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .kiara-chat-body {
  background: #0f172a;
}

[data-theme="dark"] .kiara-msg.bot .kiara-msg-bubble {
  background: #1e293b;
  color: #f1f5f9;
  border-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .kiara-chat-footer,
[data-theme="dark"] .kiara-quick-chips {
  background: #1e293b;
  border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .kiara-chat-input {
  background: #0f172a;
  color: #f8fafc;
}

[data-theme="dark"] .kiara-chat-input:focus {
  background: #1e293b;
  border-color: #ef4444;
}

[data-theme="dark"] .kiara-typing-indicator {
  background: #1e293b;
  border-color: rgba(255, 255, 255, 0.1);
}
