/* ============================================================
   KYRAO WEB SOLUTIONS — AI Chat Agent & Enrolled Questions System
   ============================================================ */

/* --- Widget Container --- */
.kyrao-chat-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  pointer-events: none;
}

.kyrao-chat-container * {
  box-sizing: border-box;
}

/* --- Proactive Teaser Bubble (Pop-up) --- */
.kyrao-chat-proactive {
  position: absolute;
  bottom: 74px;
  right: 0;
  width: 320px;
  max-width: calc(100vw - 48px);
  background: var(--surface, #ffffff);
  color: var(--text, #0f172a);
  border-radius: 18px;
  padding: 16px 18px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(99, 102, 241, 0.15);
  display: flex;
  flex-direction: column;
  gap: 10px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.95);
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s;
  pointer-events: none;
  cursor: pointer;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.kyrao-chat-proactive.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.kyrao-chat-proactive-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kyrao-chat-proactive-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kyrao-chat-avatar-mini {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--gradient-accent, linear-gradient(135deg, #6366F1 0%, #8B5CF6 50%, #EC4899 100%));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  position: relative;
}

.kyrao-chat-avatar-mini::after {
  content: '';
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 8px;
  height: 8px;
  background: #10B981;
  border-radius: 50%;
  border: 1.5px solid var(--surface, #fff);
}

.kyrao-chat-proactive-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text, #0f172a);
}

.kyrao-chat-proactive-close {
  background: transparent;
  border: none;
  color: var(--color-text-muted, #64748B);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s ease;
}

.kyrao-chat-proactive-close:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text, #0f172a);
}

.kyrao-chat-proactive-text {
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--color-text-secondary, #475569);
  margin: 0;
}

.kyrao-chat-proactive-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.kyrao-chat-chip-btn {
  background: var(--color-primary-light, rgba(99, 102, 241, 0.08));
  color: var(--color-primary, #6366F1);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.kyrao-chat-chip-btn:hover {
  background: var(--color-primary, #6366F1);
  color: #ffffff;
  transform: translateY(-1px);
}

/* --- Launcher Button --- */
.kyrao-chat-launcher {
  pointer-events: auto;
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--gradient-accent, linear-gradient(135deg, #6366F1 0%, #8B5CF6 50%, #EC4899 100%));
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px var(--color-primary-glow, rgba(99, 102, 241, 0.35)), 0 2px 6px rgba(0, 0, 0, 0.12);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

.kyrao-chat-launcher:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 30px var(--color-primary-glow, rgba(99, 102, 241, 0.5));
}

.kyrao-chat-launcher:active {
  transform: scale(0.95);
}

.kyrao-chat-launcher-icon {
  width: 28px;
  height: 28px;
  fill: currentColor;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.kyrao-chat-launcher.is-active .icon-chat {
  display: none;
}

.kyrao-chat-launcher .icon-close {
  display: none;
}

.kyrao-chat-launcher.is-active .icon-close {
  display: block;
}

/* Launcher Badge */
.kyrao-chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 22px;
  height: 22px;
  background: #EF4444;
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--surface, #fff);
  animation: kyrao-pulse 2s infinite;
}

@keyframes kyrao-pulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* --- Full Chat Window --- */
.kyrao-chat-window {
  position: absolute;
  bottom: 74px;
  right: 0;
  width: 390px;
  height: 600px;
  max-height: calc(100vh - 100px);
  max-width: calc(100vw - 36px);
  background: var(--surface, #ffffff);
  border-radius: 20px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(99, 102, 241, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s;
}

.kyrao-chat-window.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
.kyrao-chat-header {
  background: var(--gradient-accent, linear-gradient(135deg, #6366F1 0%, #8B5CF6 50%, #EC4899 100%));
  color: #ffffff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.kyrao-chat-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  border: 1.5px solid rgba(255, 255, 255, 0.4);
}

.kyrao-chat-header-text h3 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 700;
  color: #ffffff;
}

.kyrao-chat-header-text p {
  margin: 1px 0 0;
  font-size: 11px;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 5px;
}

.kyrao-chat-status-dot {
  width: 6px;
  height: 6px;
  background: #10B981;
  border-radius: 50%;
  display: inline-block;
}

.kyrao-chat-header-actions button {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  border-radius: 8px;
  padding: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.kyrao-chat-header-actions button:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* --- Navigation / Mode Switcher Bar --- */
.kyrao-chat-tabs {
  display: flex;
  background: var(--bg-alt, #f1f5f9);
  padding: 6px;
  gap: 4px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.kyrao-chat-tab-btn {
  flex: 1;
  padding: 6px 4px;
  font-size: 11.5px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--color-text-secondary, #475569);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.kyrao-chat-tab-btn.active {
  background: var(--surface, #ffffff);
  color: var(--color-primary, #6366F1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

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

.kyrao-chat-msg {
  display: flex;
  gap: 10px;
  max-width: 90%;
  animation: kyrao-msg-fade 0.3s ease-out;
}

@keyframes kyrao-msg-fade {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.kyrao-chat-msg.msg-ai {
  align-self: flex-start;
}

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

.kyrao-chat-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gradient-accent, linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%));
  color: #fff;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.kyrao-chat-msg-content {
  background: var(--surface, #ffffff);
  color: var(--text, #0f172a);
  padding: 12px 14px;
  border-radius: 16px 16px 16px 4px;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04), 0 0 0 1px rgba(0, 0, 0, 0.05);
  word-break: break-word;
}

.kyrao-chat-msg.msg-user .kyrao-chat-msg-content {
  background: var(--color-primary, #6366F1);
  color: #ffffff;
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 4px 12px var(--color-primary-glow, rgba(99, 102, 241, 0.25));
}

.kyrao-chat-msg-content a {
  color: var(--color-primary, #6366F1);
  font-weight: 600;
  text-decoration: underline;
}

.kyrao-chat-msg.msg-user .kyrao-chat-msg-content a {
  color: #ffffff;
}

.kyrao-chat-msg-content ul, 
.kyrao-chat-msg-content ol {
  margin: 6px 0;
  padding-left: 18px;
}

.kyrao-chat-msg-time {
  font-size: 10px;
  color: var(--color-text-muted, #64748B);
  margin-top: 4px;
  text-align: right;
}

/* Typing Indicator */
.kyrao-chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: var(--surface, #ffffff);
  border-radius: 14px;
  width: fit-content;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.kyrao-chat-dot {
  width: 6px;
  height: 6px;
  background: var(--color-primary, #6366F1);
  border-radius: 50%;
  animation: kyrao-typing 1.4s infinite ease-in-out;
}

.kyrao-chat-dot:nth-child(1) { animation-delay: 0s; }
.kyrao-chat-dot:nth-child(2) { animation-delay: 0.2s; }
.kyrao-chat-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes kyrao-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* --- Interactive Options & Question Chips inside Messages --- */
.kyrao-chat-msg-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed rgba(0, 0, 0, 0.1);
}

.kyrao-chat-msg-option-btn {
  background: var(--color-primary-light, rgba(99, 102, 241, 0.1));
  color: var(--color-primary, #6366F1);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 12px;
  padding: 5px 10px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.kyrao-chat-msg-option-btn:hover {
  background: var(--color-primary, #6366F1);
  color: #ffffff;
  transform: translateY(-1px);
}

/* --- Questionnaire Card Flow UI --- */
.kyrao-survey-card {
  background: var(--surface, #ffffff);
  border-radius: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(99, 102, 241, 0.2);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.08);
  margin-top: 8px;
}

.kyrao-survey-badge {
  display: inline-flex;
  align-items: center;
  background: var(--color-primary-light, rgba(99, 102, 241, 0.1));
  color: var(--color-primary, #6366F1);
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kyrao-survey-progress {
  height: 4px;
  background: rgba(99, 102, 241, 0.15);
  border-radius: 10px;
  margin: 6px 0 10px;
  overflow: hidden;
}

.kyrao-survey-progress-bar {
  height: 100%;
  background: var(--gradient-accent, linear-gradient(135deg, #6366F1, #EC4899));
  transition: width 0.3s ease;
}

.kyrao-survey-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}

.kyrao-survey-opt-btn {
  background: var(--bg-alt, #f8fafc);
  color: var(--text, #0f172a);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 11.5px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.kyrao-survey-opt-btn:hover {
  background: var(--color-primary-light, rgba(99, 102, 241, 0.12));
  border-color: var(--color-primary, #6366F1);
  color: var(--color-primary, #6366F1);
}

.kyrao-survey-lead-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.kyrao-survey-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 8px;
  font-size: 12.5px;
  outline: none;
  background: var(--bg-subtle, #f8fafc);
  color: var(--text, #0f172a);
}

.kyrao-survey-input:focus {
  border-color: var(--color-primary, #6366F1);
  background: var(--surface, #fff);
}

.kyrao-survey-submit-btn {
  background: var(--gradient-accent, linear-gradient(135deg, #6366F1 0%, #8B5CF6 50%, #EC4899 100%));
  color: #fff;
  border: none;
  padding: 9px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s;
}

.kyrao-survey-submit-btn:hover {
  transform: translateY(-1px);
}

.kyrao-survey-summary-box {
  background: var(--color-primary-light, rgba(99, 102, 241, 0.08));
  border-left: 3px solid var(--color-primary, #6366F1);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.5;
  margin-top: 6px;
}

/* --- FAQ Questions View Panel --- */
.kyrao-faq-panel {
  display: none;
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  background: var(--bg-subtle, #f8fafc);
  flex-direction: column;
  gap: 8px;
}

.kyrao-faq-panel.is-active {
  display: flex;
}

.kyrao-faq-header {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-muted, #64748B);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 4px;
}

.kyrao-faq-item {
  background: var(--surface, #ffffff);
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.kyrao-faq-item:hover {
  border-color: var(--color-primary, #6366F1);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
  transform: translateY(-1px);
}

.kyrao-faq-item-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text, #0f172a);
}

.kyrao-faq-item-icon {
  color: var(--color-primary, #6366F1);
  font-size: 14px;
}

/* Quick Prompts Box at Bottom */
.kyrao-chat-prompts {
  padding: 8px 12px;
  background: var(--surface, #ffffff);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 95px;
  overflow-y: auto;
}

.kyrao-chat-prompt-label {
  width: 100%;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--color-text-muted, #64748B);
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.kyrao-chat-prompt-pill {
  background: var(--bg-alt, #f1f5f9);
  color: var(--color-text-secondary, #475569);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 14px;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.kyrao-chat-prompt-pill:hover {
  background: var(--color-primary-light, rgba(99, 102, 241, 0.12));
  color: var(--color-primary, #6366F1);
  border-color: var(--color-primary, #6366F1);
  transform: translateY(-1px);
}

/* Footer / Input Area */
.kyrao-chat-footer {
  padding: 10px 14px;
  background: var(--surface, #ffffff);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  gap: 8px;
}

.kyrao-chat-input-wrapper {
  flex: 1;
  position: relative;
}

.kyrao-chat-input {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 20px;
  font-size: 13px;
  outline: none;
  background: var(--bg-subtle, #f8fafc);
  color: var(--text, #0f172a);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.kyrao-chat-input:focus {
  border-color: var(--color-primary, #6366F1);
  box-shadow: 0 0 0 3px var(--color-primary-light, rgba(99, 102, 241, 0.12));
  background: var(--surface, #ffffff);
}

.kyrao-chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gradient-accent, linear-gradient(135deg, #6366F1 0%, #8B5CF6 50%, #EC4899 100%));
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, opacity 0.2s;
  flex-shrink: 0;
}

.kyrao-chat-send-btn:hover:not(:disabled) {
  transform: scale(1.06);
}

.kyrao-chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.kyrao-chat-powered {
  text-align: center;
  font-size: 9.5px;
  color: var(--color-text-muted, #64748B);
  padding: 4px 0 6px;
  background: var(--surface, #ffffff);
}

/* --- Dark Mode Adaptation --- */
[data-theme="dark"] .kyrao-chat-proactive,
[data-theme="dark"] .kyrao-chat-window,
[data-theme="dark"] .kyrao-chat-tabs,
[data-theme="dark"] .kyrao-chat-prompts,
[data-theme="dark"] .kyrao-chat-footer,
[data-theme="dark"] .kyrao-chat-powered,
[data-theme="dark"] .kyrao-survey-card,
[data-theme="dark"] .kyrao-faq-item {
  background: #0f172a;
  color: #f8fafc;
  border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .kyrao-chat-tab-btn.active {
  background: #1e293b;
  color: #818cf8;
}

[data-theme="dark"] .kyrao-chat-tab-btn {
  color: #94a3b8;
}

[data-theme="dark"] .kyrao-chat-messages,
[data-theme="dark"] .kyrao-faq-panel {
  background: #090d16;
}

[data-theme="dark"] .kyrao-chat-msg.msg-ai .kyrao-chat-msg-content,
[data-theme="dark"] .kyrao-chat-typing,
[data-theme="dark"] .kyrao-survey-opt-btn {
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .kyrao-chat-input,
[data-theme="dark"] .kyrao-survey-input {
  background: #1e293b;
  color: #f8fafc;
  border-color: rgba(255, 255, 255, 0.12);
}

[data-theme="dark"] .kyrao-chat-prompt-pill {
  background: #1e293b;
  color: #cbd5e1;
  border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .kyrao-chat-prompt-pill:hover {
  background: rgba(99, 102, 241, 0.2);
  color: #818cf8;
  border-color: #818cf8;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 480px) {
  .kyrao-chat-container {
    bottom: 16px;
    right: 16px;
  }
  
  .kyrao-chat-proactive {
    bottom: 68px;
    right: 0;
    max-width: calc(100vw - 32px);
  }

  .kyrao-chat-window {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
}
