/* =========================================
   AFC AI Chatbot Widget — Styles
   Design: Awards For Creators identity
   Colors: #FFC864 (gold), #191918 (dark), #fff
   Font: Circular Std (inherited from site)
   Corners: sharp (0 radius on buttons)
   ========================================= */

/* --- FAB Button --- */
.afc-chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #191918;
  color: #FFC864;
  border: 2px solid #FFC864;
  padding: 14px 22px;
  font-family: 'Circular Std', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
  outline: none;
}

.afc-chat-fab:hover {
  background: #FFC864;
  color: #191918;
  box-shadow: 0 12px 40px rgba(255, 200, 100, 0.25);
}

.afc-chat-fab svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.afc-chat-fab .fab-close {
  display: none;
}

.afc-chat-fab.active .fab-open { display: none; }
.afc-chat-fab.active .fab-close { display: block; }
.afc-chat-fab.active .fab-label { display: none; }
.afc-chat-fab.active {
  padding: 14px;
}

/* Pulse animation on load */
@keyframes afcFabPulse {
  0%, 100% { box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4); }
  50% { box-shadow: 0 8px 32px rgba(255, 200, 100, 0.3); }
}
.afc-chat-fab:not(.active) {
  animation: afcFabPulse 3s ease-in-out infinite;
}
.afc-chat-fab:hover {
  animation: none;
}

/* --- Chat Window --- */
.afc-chat-window {
  position: fixed;
  bottom: 90px;
  right: 24px;
  z-index: 9999;
  width: 400px;
  max-height: 600px;
  height: 70vh;
  background: #191918;
  border: 1px solid rgba(255, 200, 100, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* --- Header --- */
.afc-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: #191918;
  border-bottom: 1px solid rgba(255, 200, 100, 0.1);
  flex-shrink: 0;
}

.afc-chat-avatar {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #FFC864, #e6a832);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.afc-chat-avatar svg {
  width: 20px;
  height: 20px;
  fill: #191918;
}

.afc-chat-header-info {
  flex: 1;
  min-width: 0;
}

.afc-chat-header-title {
  color: #fff;
  font-family: 'Circular Std', -apple-system, sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.afc-chat-header-status {
  color: #FFC864;
  font-size: 11px;
  font-weight: 400;
  opacity: 0.8;
  margin-top: 2px;
}

.afc-chat-header-close {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  padding: 6px;
  transition: color 0.2s;
  display: none; /* shown on mobile via media query */
  flex-shrink: 0;
}
.afc-chat-header-close svg {
  width: 22px;
  height: 22px;
}
.afc-chat-header-close:hover { color: #FFC864; }

/* --- Messages area --- */
.afc-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 200, 100, 0.2) transparent;
}

.afc-chat-messages::-webkit-scrollbar { width: 4px; }
.afc-chat-messages::-webkit-scrollbar-track { background: transparent; }
.afc-chat-messages::-webkit-scrollbar-thumb { background: rgba(255, 200, 100, 0.2); }

/* --- Message bubbles --- */
.afc-msg {
  max-width: 85%;
  font-family: 'Circular Std', -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  animation: afcMsgIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.afc-msg.assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  color: #e0e0e0;
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.afc-msg.user {
  align-self: flex-end;
  background: #FFC864;
  color: #191918;
  padding: 12px 16px;
  font-weight: 500;
}

/* Links in messages */
.afc-msg a {
  color: #FFC864;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.afc-msg.user a {
  color: #191918;
  font-weight: 700;
}

/* Bold text */
.afc-msg strong {
  font-weight: 700;
}
.afc-msg.assistant strong {
  color: #FFC864;
}

/* --- Typing indicator --- */
.afc-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.afc-typing-dot {
  width: 6px;
  height: 6px;
  background: #FFC864;
  border-radius: 50%;
  animation: afcTyping 1.4s ease-in-out infinite;
}
.afc-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.afc-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes afcTyping {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
  30% { opacity: 1; transform: scale(1); }
}

/* --- Suggestion chips --- */
.afc-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 20px 12px;
  flex-shrink: 0;
}

.afc-chip {
  background: transparent;
  color: #FFC864;
  border: 1px solid rgba(255, 200, 100, 0.3);
  padding: 8px 14px;
  font-family: 'Circular Std', -apple-system, sans-serif;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  outline: none;
}

.afc-chip:hover {
  background: rgba(255, 200, 100, 0.1);
  border-color: #FFC864;
  color: #FFC864;
}

/* --- Input area --- */
.afc-chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 200, 100, 0.1);
  background: #191918;
  flex-shrink: 0;
}

.afc-chat-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #e0e0e0;
  padding: 10px 14px;
  font-family: 'Circular Std', -apple-system, sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  resize: none;
  min-height: 40px;
  max-height: 100px;
  line-height: 1.4;
}

.afc-chat-input::placeholder {
  color: #666;
}

.afc-chat-input:focus {
  border-color: rgba(255, 200, 100, 0.3);
}

.afc-chat-send {
  background: #FFC864;
  color: #191918;
  border: none;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  outline: none;
}

.afc-chat-send:hover {
  background: #e6a832;
}

.afc-chat-send:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.afc-chat-send svg {
  width: 18px;
  height: 18px;
}

/* --- Powered by --- */
.afc-chat-footer {
  text-align: center;
  padding: 6px;
  font-size: 10px;
  color: #555;
  background: #191918;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  flex-shrink: 0;
}

.afc-chat-footer a {
  color: #777;
  text-decoration: none;
}

/* =========================================
   Mobile full-screen
   ========================================= */
@media (max-width: 768px) {
  .afc-chat-fab {
    bottom: 16px;
    right: 16px;
    padding: 12px;
    width: 48px;
    height: 48px;
    justify-content: center;
    gap: 0;
    border-radius: 50%;
  }

  .afc-chat-fab .fab-label {
    display: none;
  }

  .afc-chat-fab.active {
    padding: 12px;
    display: none;
  }

  .afc-chat-window {
    /* JS sets --afc-vh to actual visible height */
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: 100%;
    max-height: none;
    height: var(--afc-vh, 100vh);
    border: none;
    box-shadow: none;
  }

  .afc-chat-header-close {
    display: flex;
  }

  /* Prevent messages area from over-expanding */
  .afc-chat-messages {
    min-height: 0;
    flex: 1 1 0;
    overflow-y: auto;
  }

  /* Keep input area compact and always visible */
  .afc-chat-input-area {
    flex-shrink: 0;
  }

  /* Prevent iOS auto-zoom on focus (requires >= 16px) */
  .afc-chat-input {
    font-size: 16px;
  }

  /* Suggestions: allow wrap, reduce padding on mobile */
  .afc-suggestions {
    padding: 0 12px 8px;
    gap: 6px;
  }
  .afc-chip {
    white-space: normal;
    font-size: 11px;
    padding: 6px 10px;
  }

  /* Footer: compact */
  .afc-chat-footer {
    padding: 4px;
    font-size: 9px;
  }

}

/* =========================================
   Reduced motion
   ========================================= */
@media (prefers-reduced-motion: reduce) {
  .afc-chat-fab,
  .afc-chat-window,
  .afc-msg,
  .afc-chip {
    transition: none;
    animation: none;
  }
  .afc-typing-dot {
    animation: none;
    opacity: 0.5;
  }
}
