/* ==========================================================================
   Al-Falah School Kikambala - AI Website Assistant Widget Styles
   Inspired by modern Baraka AI design: Pill Launcher on Left, Rich Emerald Theme
   ========================================================================== */

:root {
  --af-chat-primary: #095c32;
  --af-chat-primary-dark: #064022;
  --af-chat-primary-light: #0c6d3b;
  --af-chat-gradient: linear-gradient(135deg, #111111 0%, #266e00 100%);
  --af-chat-gradient-hover: linear-gradient(135deg, #1a1a1a 0%, #2e8000 100%);
  --af-chat-gold: #f59e0b;
  --af-chat-bg: #ffffff;
  --af-chat-border: #e2e8f0;
  --af-chat-shadow: 0 20px 60px -10px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(0, 0, 0, 0.06);
}

/* 1. Floating Launcher Button - Capsule / Pill on the Bottom LEFT */
.af-chat-launcher {
  position: fixed !important;
  bottom: 24px !important;
  left: 24px !important;
  right: auto !important;
  height: 48px;
  padding: 5px 20px 5px 6px;
  border-radius: 9999px;
  background: linear-gradient(135deg, #111111 0%, #266e00 100%);
  color: #ffffff;
  display: inline-flex !important;
  align-items: center;
  gap: 11px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.2);
  z-index: 999999 !important;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease, background 0.25s ease;
  outline: none;
  user-select: none;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  text-decoration: none;
}

.af-chat-launcher:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.3);
  background: linear-gradient(135deg, #1a1a1a 0%, #2e8000 100%);
  color: #ffffff;
}

.af-chat-launcher:active {
  transform: translateY(0) scale(0.97);
}

/* Avatar icon inside the launcher */
.af-launcher-avatar {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.af-launcher-avatar .af-mascot-svg {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: block;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Online beacon dot on the mascot */
.af-online-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #064022;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  animation: afOnlinePulse 2s infinite;
}

@keyframes afOnlinePulse {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

/* Launcher text label */
.af-launcher-label {
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: #ffffff;
  white-space: nowrap;
}

/* 2. Chat Window Panel - Opens from Bottom LEFT */
.af-chat-window {
  position: fixed !important;
  bottom: 84px !important;
  left: 24px !important;
  right: auto !important;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 590px;
  max-height: calc(100vh - 105px);
  background: var(--af-chat-bg);
  border-radius: 20px;
  box-shadow: var(--af-chat-shadow);
  display: flex;
  flex-direction: column;
  z-index: 999998 !important;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.96);
  transform-origin: bottom left;
  transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1), transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.28s;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

/* 3. Header - Baraka Style with Mascot, Titles & Modern Controls */
.af-chat-header {
  background: var(--af-chat-gradient);
  color: #ffffff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  user-select: none;
}

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

.af-chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.af-chat-avatar .af-mascot-svg {
  width: 42px;
  height: 42px;
  display: block;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.2));
}

.af-chat-title-group h4 {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
  line-height: 1.2;
}

.af-chat-status {
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.82);
  margin-top: 3px;
  font-weight: 400;
}

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

.af-header-btn {
  background: rgba(255, 255, 255, 0.16);
  border: none;
  color: #ffffff;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.af-header-btn.af-btn-reset {
  border-radius: 50%;
}

.af-header-btn.af-btn-close {
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.2);
}

.af-header-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

/* 4. Mode Navigation Tabs */
.af-chat-tabs {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.af-tab-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 9999px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.af-tab-btn svg {
  flex-shrink: 0;
}

.af-tab-btn:hover:not(.active) {
  background: #f1f5f9;
  color: #0f172a;
}

.af-tab-btn.active {
  background: #eef8ee;
  border-color: var(--af-chat-primary);
  color: var(--af-chat-primary);
  box-shadow: 0 1px 3px rgba(9, 92, 50, 0.12);
}

/* 5. Messages Body */
.af-chat-body {
  flex: 1;
  padding: 14px 14px;
  overflow-y: auto;
  background: #fbfcfd;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.af-chat-body::-webkit-scrollbar {
  width: 6px;
}

.af-chat-body::-webkit-scrollbar-thumb {
  background: rgba(9, 92, 50, 0.2);
  border-radius: 4px;
}

/* Welcome Card (Baraka Style) */
.af-chat-welcome {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.af-welcome-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

.af-welcome-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 8px;
}

.af-wave-emoji {
  font-size: 16px;
}

.af-welcome-intro {
  font-size: 13px;
  color: #334155;
  margin: 0 0 10px;
  line-height: 1.5;
}

.af-welcome-bullets {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  font-size: 12.5px;
  color: #334155;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.af-welcome-bullets li {
  position: relative;
  padding-left: 14px;
}

.af-welcome-bullets li::before {
  content: "•";
  position: absolute;
  left: 2px;
  color: var(--af-chat-primary);
  font-weight: bold;
}

.af-welcome-prompt {
  font-size: 12.5px;
  color: #64748b;
  margin: 0;
}

/* Quick Prompt Pills */
.af-quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.af-quick-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #1e293b;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 9999px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.af-quick-btn:hover {
  background: #eef8ee;
  border-color: var(--af-chat-primary);
  color: var(--af-chat-primary);
  transform: translateY(-1px);
}

/* Message Rows */
.af-msg-row {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  animation: afFadeIn 0.25s ease-out;
}

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

.af-msg-row.user {
  align-self: flex-end;
}

.af-msg-row.assistant {
  align-self: flex-start;
}

.af-msg-bubble {
  padding: 10px 14px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}

.af-msg-row.user .af-msg-bubble {
  background: var(--af-chat-primary);
  color: #ffffff;
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 2px 8px rgba(9, 92, 50, 0.25);
}

.af-msg-row.assistant .af-msg-bubble {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.af-msg-row.assistant .af-msg-bubble p {
  margin: 0 0 8px;
}

.af-msg-row.assistant .af-msg-bubble p:last-child {
  margin-bottom: 0;
}

.af-msg-row.assistant .af-msg-bubble ul,
.af-msg-row.assistant .af-msg-bubble ol {
  margin: 6px 0 8px 18px;
  padding: 0;
}

.af-msg-row.assistant .af-msg-bubble li {
  margin-bottom: 4px;
}

.af-msg-row.assistant .af-msg-bubble a {
  color: var(--af-chat-primary);
  font-weight: 600;
  text-decoration: underline;
  transition: color 0.15s ease;
}

.af-msg-row.assistant .af-msg-bubble a:hover {
  color: #0f172a;
}

.af-msg-row.assistant .af-msg-bubble strong {
  color: #0f172a;
}

.af-msg-time {
  font-size: 10.5px;
  color: #94a3b8;
  margin-top: 4px;
  align-self: flex-end;
}

.af-msg-row.assistant .af-msg-time {
  align-self: flex-start;
}

/* Typing Indicator */
.af-typing-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px 16px 16px 4px;
  width: fit-content;
}

.af-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--af-chat-primary);
  opacity: 0.6;
  animation: afTypingBounce 1.4s infinite ease-in-out both;
}

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

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

/* 6. Composer & Subfooter */
.af-chat-footer {
  padding: 12px 14px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
}

.af-composer-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  padding: 6px 8px 6px 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.af-composer-wrap:focus-within {
  border-color: var(--af-chat-primary);
  box-shadow: 0 0 0 3px rgba(9, 92, 50, 0.12);
  background: #ffffff;
}

.af-composer-input {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  max-height: 100px;
  min-height: 24px;
  height: 24px;
  font-size: 13.5px;
  font-family: inherit;
  color: #1e293b;
  outline: none;
  line-height: 1.4;
  padding: 2px 0;
}

.af-composer-input::placeholder {
  color: #94a3b8;
}

.af-composer-send {
  background: var(--af-chat-primary);
  color: #ffffff;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease, opacity 0.2s ease;
  flex-shrink: 0;
}

.af-composer-send:hover:not(:disabled) {
  background: var(--af-chat-primary-light);
  transform: scale(1.06);
}

.af-composer-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.af-composer-send svg {
  transform: rotate(0deg);
}

/* Subfooter Bar (Image 2 style) */
.af-chat-subfooter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  margin-top: 8px;
  border-top: 1px solid #f1f5f9;
  font-size: 11.5px;
  color: #64748b;
}

.af-subfooter-info {
  white-space: nowrap;
}

.af-subfooter-whatsapp {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #16a34a;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.15s ease;
}

.af-subfooter-whatsapp i {
  font-size: 13px;
}

.af-subfooter-whatsapp:hover {
  color: #15803d;
  text-decoration: underline;
}

/* 7. Mobile Responsiveness */
@media (max-width: 480px) {
  .af-chat-window {
    bottom: 0;
    left: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
  .af-chat-launcher {
    bottom: 16px;
    left: 16px;
    height: 44px;
    padding: 4px 16px 4px 5px;
  }
  .af-launcher-label {
    font-size: 13.5px;
  }
}

/* Scroll-to-top button stays clean on bottom RIGHT */
.scroll-top {
  right: 25px !important;
  bottom: 25px !important;
}
