/* ==========================================================================
   AFW Team - Secure AI Website Discovery, Search & Sales Chatbot Styles
   AskForWrite Academic (https://askforwrite.in)
   ========================================================================== */

:root {
  --afw-primary: #0a2540;
  --afw-primary-dark: #061727;
  --afw-accent: #00a8e8;
  --afw-accent-cyan: #00c2ff;
  --afw-accent-gold: #f59e0b;
  --afw-accent-gold-dark: #d97706;
  --afw-accent-green: #10b981;
  --afw-text: #1e293b;
  --afw-text-muted: #64748b;
  --afw-bg: #ffffff;
  --afw-bg-subtle: #f8fafc;
  --afw-border: #e2e8f0;
  --afw-font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --afw-font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --afw-shadow: 0 12px 36px -4px rgba(10, 37, 64, 0.22), 0 4px 12px rgba(0, 0, 0, 0.08);
  --afw-radius: 16px;
  --afw-transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Floating Launcher */
#afw-chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999990;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px 10px 12px;
  background: linear-gradient(135deg, var(--afw-primary) 0%, var(--afw-primary-dark) 100%);
  color: #ffffff;
  border: 1px solid rgba(0, 168, 232, 0.35);
  border-radius: 9999px;
  box-shadow: 0 8px 24px rgba(10, 37, 64, 0.28);
  cursor: pointer;
  font-family: var(--afw-font-body);
  font-size: 0.95rem;
  font-weight: 600;
  transition: var(--afw-transition);
  outline: none;
}

#afw-chat-launcher:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 14px 30px rgba(0, 168, 232, 0.35);
  border-color: var(--afw-accent-cyan);
}

#afw-chat-launcher:focus-visible {
  outline: 3px solid var(--afw-accent-cyan);
  outline-offset: 3px;
}

.afw-launcher-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--afw-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.afw-launcher-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.afw-launcher-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  background: var(--afw-accent-green);
  border: 2px solid #ffffff;
  border-radius: 50%;
  animation: afwPulse 2s infinite;
}

.afw-launcher-text {
  display: flex;
  flex-direction: column;
  text-align: left;
  line-height: 1.2;
}

.afw-launcher-title {
  font-family: var(--afw-font-heading);
  font-weight: 700;
  font-size: 0.95rem;
  color: #ffffff;
  letter-spacing: 0.2px;
}

.afw-launcher-sub {
  font-size: 0.72rem;
  color: var(--afw-accent-cyan);
  font-weight: 500;
}

/* Chat Main Window */
#afw-chat-container {
  position: fixed;
  bottom: 84px;
  right: 24px;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 110px);
  background: var(--afw-bg);
  border-radius: var(--afw-radius);
  box-shadow: var(--afw-shadow);
  border: 1px solid var(--afw-border);
  z-index: 999995;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--afw-font-body);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
  transform-origin: bottom right;
}

#afw-chat-container.afw-hidden {
  transform: scale(0.85) translateY(20px);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

/* Chat Header */
.afw-header {
  background: linear-gradient(135deg, var(--afw-primary-dark) 0%, var(--afw-primary) 100%);
  color: #ffffff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid rgba(0, 168, 232, 0.4);
}

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

.afw-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--afw-accent-cyan);
  overflow: hidden;
}

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

.afw-header-text h3 {
  font-family: var(--afw-font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
}

.afw-header-status {
  font-size: 0.72rem;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 5px;
}

.afw-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--afw-accent-green);
  display: inline-block;
}

.afw-header-actions {
  display: flex;
  gap: 6px;
}

.afw-btn-icon {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #ffffff;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: var(--afw-transition);
}

.afw-btn-icon:hover {
  background: rgba(255, 255, 255, 0.22);
  color: var(--afw-accent-cyan);
}

/* Chat Messages Scroll Area */
.afw-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  background: var(--afw-bg-subtle);
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.afw-msg {
  display: flex;
  flex-direction: column;
  max-width: 90%;
  animation: afwFadeIn 0.3s ease;
}

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

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

.afw-msg-bubble {
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 0.92rem;
  line-height: 1.5;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.afw-bot .afw-msg-bubble {
  background: #ffffff;
  color: var(--afw-text);
  border: 1px solid var(--afw-border);
  border-top-left-radius: 4px;
}

.afw-user .afw-msg-bubble {
  background: linear-gradient(135deg, var(--afw-primary) 0%, #183b63 100%);
  color: #ffffff;
  border-top-right-radius: 4px;
}

.afw-msg-time {
  font-size: 0.68rem;
  color: var(--afw-text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

.afw-user .afw-msg-time {
  text-align: right;
}

/* Welcome Intro Card */
.afw-welcome-box {
  background: #ffffff;
  border: 1px solid rgba(0, 168, 232, 0.25);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 4px;
}

.afw-welcome-box h4 {
  font-family: var(--afw-font-heading);
  color: var(--afw-primary);
  margin-bottom: 8px;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.afw-welcome-box p {
  font-size: 0.88rem;
  color: var(--afw-text-muted);
  line-height: 1.45;
  margin-bottom: 12px;
}

/* Suggestion Chips */
.afw-chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.afw-chip {
  background: #ffffff;
  border: 1px solid rgba(0, 168, 232, 0.4);
  color: var(--afw-primary);
  padding: 6px 12px;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--afw-transition);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.afw-chip:hover {
  background: rgba(0, 168, 232, 0.1);
  border-color: var(--afw-accent);
  color: var(--afw-accent);
  transform: translateY(-1px);
}

/* Compact Catalog Resource Card */
.afw-card {
  background: #ffffff;
  border: 1px solid var(--afw-border);
  border-left: 4px solid var(--afw-accent);
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: var(--afw-transition);
}

.afw-card:hover {
  box-shadow: 0 6px 16px rgba(10, 37, 64, 0.08);
  border-color: var(--afw-accent);
}

.afw-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 6px;
  gap: 8px;
}

.afw-card-title {
  font-family: var(--afw-font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--afw-primary);
  line-height: 1.3;
}

.afw-card-badge {
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 4px;
  background: #e0f2fe;
  color: #0284c7;
  font-weight: 700;
  white-space: nowrap;
}

.afw-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.76rem;
  color: var(--afw-text-muted);
  margin-bottom: 8px;
}

.afw-card-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.afw-card-summary {
  font-size: 0.84rem;
  color: #475569;
  line-height: 1.4;
  margin-bottom: 10px;
}

.afw-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--afw-border);
  padding-top: 8px;
  margin-top: 6px;
}

.afw-card-price {
  font-family: var(--afw-font-heading);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--afw-primary);
}

.afw-card-price small {
  font-size: 0.72rem;
  color: var(--afw-text-muted);
  font-weight: 400;
}

.afw-card-actions {
  display: flex;
  gap: 6px;
}

.afw-btn-action {
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: var(--afw-transition);
}

.afw-btn-gold {
  background: var(--afw-accent-gold);
  color: #000000;
}

.afw-btn-gold:hover {
  background: var(--afw-accent-gold-dark);
  color: #ffffff;
}

.afw-btn-primary {
  background: var(--afw-accent);
  color: #ffffff;
}

.afw-btn-primary:hover {
  background: #0092ca;
}

.afw-btn-outline {
  border: 1px solid var(--afw-border);
  color: var(--afw-primary);
  background: transparent;
}

.afw-btn-outline:hover {
  background: #f1f5f9;
}

/* Chat Input Area */
.afw-input-area {
  padding: 12px 16px;
  background: #ffffff;
  border-top: 1px solid var(--afw-border);
  display: flex;
  gap: 10px;
  align-items: center;
}

.afw-input-field {
  flex: 1;
  border: 1px solid var(--afw-border);
  border-radius: 9999px;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-family: var(--afw-font-body);
  outline: none;
  transition: var(--afw-transition);
}

.afw-input-field:focus {
  border-color: var(--afw-accent);
  box-shadow: 0 0 0 3px rgba(0, 168, 232, 0.15);
}

.afw-send-btn {
  background: var(--afw-accent);
  color: #ffffff;
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: var(--afw-transition);
  flex-shrink: 0;
}

.afw-send-btn:hover {
  background: #0092ca;
  transform: scale(1.05);
}

.afw-send-btn:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
  transform: none;
}

/* Loading Dots Indicator */
.afw-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
}

.afw-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  animation: afwBounce 1.4s infinite ease-in-out both;
}

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

/* Security & Disclaimer Footer */
.afw-footer-note {
  font-size: 0.7rem;
  color: var(--afw-text-muted);
  text-align: center;
  padding: 6px 12px;
  background: #f8fafc;
  border-top: 1px solid #f1f5f9;
}

/* Animations */
@keyframes afwFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes afwPulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
  70% { box-shadow: 0 0 0 7px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

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

/* Mobile Responsiveness */
@media (max-width: 640px) {
  #afw-chat-container {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100dvh;
    border-radius: 0;
  }

  #afw-chat-launcher {
    bottom: 16px;
    right: 16px;
    padding: 8px 14px;
  }
}
