/* ═══════════════════════════════════════════════════════════
   KRAFTOR CHATBOT — FAANG LEVEL UI
   Namespace: .kf-chat-* to avoid any CSS leaks
═══════════════════════════════════════════════════════════ */

/* ── VARIABLES ────────────────────────────────────────────── */
:root {
  --kfc-navy:        #0D1B3D;
  --kfc-blue:        #0066FF;
  --kfc-orange:      #FF6A00;
  --kfc-orange-2:    #FF9E00;
  --kfc-white:       #FFFFFF;
  --kfc-bg:          rgba(255, 255, 255, 0.97);
  --kfc-border:      rgba(13, 27, 61, 0.10);
  --kfc-shadow:      0 24px 80px rgba(13, 27, 61, 0.22), 0 4px 16px rgba(0, 0, 0, 0.08);
  --kfc-radius:      20px;
  --kfc-font:        'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ── LAUNCHER BUBBLE ─────────────────────────────────────── */
#kf-chat-launcher {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 8px 32px rgba(13, 27, 61, 0.15), 0 2px 8px rgba(0,0,0,0.08);
  cursor: pointer;
  z-index: 900;
  border: none;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
  overflow: hidden;
}

#kf-chat-launcher:hover {
  transform: scale(1.10);
  box-shadow: 0 12px 40px rgba(255, 106, 0, 0.55), 0 4px 12px rgba(0,0,0,0.18);
}

#kf-chat-launcher img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 50%;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

/* Pulse ring around launcher */
#kf-chat-launcher::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(255,106,0,0.35), rgba(255,158,0,0.20));
  animation: kfc-pulse-ring 2.5s ease-out infinite;
  z-index: -1;
}

@keyframes kfc-pulse-ring {
  0%   { transform: scale(1);   opacity: 0.8; }
  70%  { transform: scale(1.5); opacity: 0; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* Unread dot */
#kf-chat-launcher .kfc-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 14px;
  height: 14px;
  background: #22C55E;
  border: 2px solid #fff;
  border-radius: 50%;
  animation: kfc-badge-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes kfc-badge-pop {
  from { transform: scale(0); }
  to   { transform: scale(1); }
}

/* Close icon inside launcher (shown when panel is open) */
#kf-chat-launcher .kfc-close-icon {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--kfc-navy), #1a2f6b);
  border-radius: 50%;
}

#kf-chat-launcher.kf-open .kfc-close-icon  { display: flex; }
#kf-chat-launcher.kf-open img              { opacity: 0; }
#kf-chat-launcher.kf-open .kfc-badge       { display: none; }
#kf-chat-launcher.kf-open::before          { animation: none; opacity: 0; }

/* ── CHAT PANEL ──────────────────────────────────────────── */
#kf-chat-panel {
  position: fixed;
  bottom: 104px;
  right: 28px;
  width: 360px;
  height: 540px;
  background: var(--kfc-bg);
  border-radius: var(--kfc-radius);
  box-shadow: var(--kfc-shadow);
  border: 1px solid var(--kfc-border);
  display: flex;
  flex-direction: column;
  z-index: 901;
  overflow: hidden;
  transform-origin: bottom right;

  /* Hidden state */
  opacity: 0;
  transform: scale(0.85) translateY(20px);
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
              transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#kf-chat-panel.kf-panel-open {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: all;
}

/* ── PANEL HEADER ────────────────────────────────────────── */
.kfc-header {
  background: linear-gradient(135deg, var(--kfc-navy) 0%, #1a3a7a 100%);
  padding: 18px 20px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

/* Decorative ring in header */
.kfc-header::after {
  content: '';
  position: absolute;
  width: 140px;
  height: 140px;
  top: -60px;
  right: -40px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(255,106,0,0.4), rgba(255,158,0,0.1), rgba(255,106,0,0.4));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 14px), #fff calc(100% - 13px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 14px), #fff calc(100% - 13px));
  animation: kfc-ring-spin 12s linear infinite;
}

@keyframes kfc-ring-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.kfc-header-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 158, 0, 0.7);
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 0 0 4px rgba(255,106,0,0.15);
  position: relative;
  z-index: 1;
}

.kfc-header-info {
  flex: 1;
  position: relative;
  z-index: 1;
}

.kfc-header-name {
  font-family: var(--kfc-font);
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.kfc-header-sub {
  font-family: var(--kfc-font);
  font-size: 0.72rem;
  color: rgba(255,255,255,0.7);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.kfc-online-dot {
  width: 7px;
  height: 7px;
  background: #22C55E;
  border-radius: 50%;
  display: inline-block;
  animation: kfc-online-blink 2s ease-in-out infinite;
}

@keyframes kfc-online-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.kfc-header-close {
  background: rgba(255,255,255,0.12);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: rgba(255,255,255,0.85);
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.kfc-header-close:hover {
  background: rgba(255,255,255,0.22);
  color: #fff;
}

/* ── MESSAGE AREA ────────────────────────────────────────── */
.kfc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.kfc-messages::-webkit-scrollbar {
  width: 4px;
}
.kfc-messages::-webkit-scrollbar-track {
  background: transparent;
}
.kfc-messages::-webkit-scrollbar-thumb {
  background: rgba(13,27,61,0.12);
  border-radius: 4px;
}

/* ── MESSAGE BUBBLES ─────────────────────────────────────── */
.kfc-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: kfc-msg-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes kfc-msg-in {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

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

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

.kfc-msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1.5px solid rgba(255,106,0,0.35);
}

.kfc-bubble {
  max-width: 240px;
  padding: 11px 15px;
  border-radius: 18px;
  font-family: var(--kfc-font);
  font-size: 0.855rem;
  line-height: 1.55;
  position: relative;
}

.kfc-msg-bot .kfc-bubble {
  background: var(--kfc-navy);
  color: rgba(255,255,255,0.92);
  border-bottom-left-radius: 5px;
}

.kfc-msg-user .kfc-bubble {
  background: linear-gradient(135deg, var(--kfc-orange), var(--kfc-orange-2));
  color: #fff;
  border-bottom-right-radius: 5px;
  font-weight: 500;
}

/* Link inside bubble */
.kfc-bubble a {
  color: rgba(255,200,80,0.95);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── TYPING INDICATOR ────────────────────────────────────── */
.kfc-typing {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  align-self: flex-start;
  animation: kfc-msg-in 0.3s ease both;
}

.kfc-typing-bubble {
  background: var(--kfc-navy);
  padding: 12px 16px;
  border-radius: 18px;
  border-bottom-left-radius: 5px;
  display: flex;
  gap: 5px;
  align-items: center;
}

.kfc-typing-dot {
  width: 7px;
  height: 7px;
  background: rgba(255,255,255,0.5);
  border-radius: 50%;
  animation: kfc-bounce 1.2s ease-in-out infinite;
}

.kfc-typing-dot:nth-child(1) { animation-delay: 0s; }
.kfc-typing-dot:nth-child(2) { animation-delay: 0.18s; }
.kfc-typing-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes kfc-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30%            { transform: translateY(-6px); opacity: 1; }
}

/* ── OPTION CHIPS AREA ───────────────────────────────────── */
.kfc-options {
  padding: 4px 16px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

.kfc-option-chip {
  background: transparent;
  border: 1.5px solid var(--kfc-border);
  border-radius: 100px;
  padding: 8px 16px;
  font-family: var(--kfc-font);
  font-size: 0.80rem;
  font-weight: 500;
  color: var(--kfc-navy);
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, color 0.18s, transform 0.18s;
  white-space: nowrap;
  outline: none;
  animation: kfc-chip-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.kfc-option-chip:hover {
  background: var(--kfc-navy);
  border-color: var(--kfc-navy);
  color: #fff;
  transform: translateY(-1px);
}

.kfc-option-chip.kfc-cta-wa {
  background: #25D366;
  border-color: #25D366;
  color: #fff;
  font-weight: 600;
}

.kfc-option-chip.kfc-cta-wa:hover {
  background: #1ea855;
  border-color: #1ea855;
}

.kfc-option-chip.kfc-cta-call {
  background: linear-gradient(135deg, var(--kfc-orange), var(--kfc-orange-2));
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}

.kfc-option-chip.kfc-cta-call:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

@keyframes kfc-chip-in {
  from { opacity: 0; transform: scale(0.85) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── FOOTER BRANDING ─────────────────────────────────────── */
.kfc-footer {
  padding: 8px 16px 12px;
  text-align: center;
  font-family: var(--kfc-font);
  font-size: 0.68rem;
  color: rgba(13,27,61,0.35);
  flex-shrink: 0;
  border-top: 1px solid rgba(13,27,61,0.06);
}

.kfc-footer span {
  font-weight: 600;
  color: rgba(13,27,61,0.5);
}

/* ── CONTACT CARD (special rich message) ─────────────────── */
.kfc-contact-card {
  background: linear-gradient(135deg, var(--kfc-navy), #1a3a7a);
  border-radius: 14px;
  padding: 16px;
  color: rgba(255,255,255,0.9);
  font-family: var(--kfc-font);
  font-size: 0.8rem;
  line-height: 1.6;
  max-width: 260px;
}

.kfc-contact-card .kfc-card-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--kfc-orange-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

.kfc-contact-card .kfc-card-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  color: rgba(255,255,255,0.8);
}

.kfc-contact-card .kfc-card-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.85;
}

/* ── SERVICE INFO CARD ───────────────────────────────────── */
.kfc-service-card {
  background: linear-gradient(135deg, rgba(0,102,255,0.07), rgba(0,102,255,0.03));
  border: 1px solid rgba(0,102,255,0.15);
  border-radius: 14px;
  padding: 14px 16px;
  font-family: var(--kfc-font);
  font-size: 0.80rem;
  color: var(--kfc-navy);
  line-height: 1.55;
  max-width: 260px;
}

.kfc-service-card .kfc-sc-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--kfc-navy);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.kfc-service-card .kfc-sc-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 10px;
}

.kfc-service-card .kfc-sc-tag {
  background: rgba(0,102,255,0.10);
  color: var(--kfc-blue);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 100px;
  letter-spacing: 0.02em;
}

/* ── PRICING CARD ────────────────────────────────────────── */
.kfc-pricing-card {
  border-radius: 14px;
  padding: 14px 16px;
  font-family: var(--kfc-font);
  font-size: 0.80rem;
  color: var(--kfc-navy);
  max-width: 260px;
  border: 1px solid rgba(13,27,61,0.10);
  background: #fff;
}

.kfc-pricing-card .kfc-pc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.kfc-pricing-card .kfc-pc-name {
  font-weight: 700;
  font-size: 0.84rem;
}

.kfc-pricing-card .kfc-pc-price {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--kfc-orange);
  font-feature-settings: 'tnum';
}

.kfc-pricing-card .kfc-pc-features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.kfc-pricing-card .kfc-pc-features li {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 0.765rem;
  color: rgba(13,27,61,0.75);
  line-height: 1.45;
}

.kfc-pricing-card .kfc-pc-features li::before {
  content: '✓';
  color: #22C55E;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 0.5px;
}

/* ── MOBILE RESPONSIVE ───────────────────────────────────── */
@media (max-width: 480px) {
  #kf-chat-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 88vh;
    border-radius: var(--kfc-radius) var(--kfc-radius) 0 0;
    transform-origin: bottom center;
  }

  #kf-chat-launcher {
    bottom: 20px;
    right: 20px;
  }
}

@media (max-width: 360px) {
  .kfc-bubble {
    max-width: 200px;
    font-size: 0.82rem;
  }
}
