/**
 * NILWALA CEYLON — Nilwala AI Assistant Stylesheet
 * =================================================
 * Luxury dark charcoal, metallic gold, and liquid-glass chat interface.
 * Matches Nilwala Ceylon's brand design system:
 * - Playfair Display serif headers
 * - Poppins body & UI typography
 * - Gold accents (#D4AF37 / #E6C76A)
 * - Translucent backdrop blur & specular borders
 */

/* ==========================================================================
   1. FLOATING DOCK TRIGGER
   ========================================================================== */
.nilwala-ai-dock {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 990;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 1.25rem 0.75rem 0.95rem;
  background: rgba(26, 20, 16, 0.88);
  border: 1px solid var(--color-gold-primary);
  border-radius: var(--radius-full);
  color: var(--color-warm-ivory);
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(212, 175, 55, 0.25);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.3s ease, background-color 0.3s ease;
}

.nilwala-ai-dock:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.7), 0 0 28px rgba(212, 175, 55, 0.4);
  background: rgba(33, 24, 19, 0.95);
  border-color: var(--color-gold-soft);
}

.nilwala-ai-dock.active {
  background: var(--color-gold-primary);
  color: #14100D;
  border-color: var(--color-gold-soft);
}

.ai-dock-sparkle {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: rgba(212, 175, 55, 0.18);
  border: 1px solid var(--glass-border);
  color: var(--color-gold-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  animation: aiPulse 3s infinite;
}

.nilwala-ai-dock.active .ai-dock-sparkle {
  background: #14100D;
  color: var(--color-gold-soft);
}

@keyframes aiPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.4); }
  50% { transform: scale(1.08); box-shadow: 0 0 14px 2px rgba(212, 175, 55, 0.3); }
}

.ai-dock-label {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.ai-dock-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: inherit;
}

.ai-dock-subtitle {
  font-size: 0.65rem;
  color: var(--color-gold-soft);
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nilwala-ai-dock.active .ai-dock-subtitle {
  color: #2e2118;
}

/* ==========================================================================
   2. AI CHAT WINDOW CONTAINER
   ========================================================================== */
.nilwala-ai-window {
  position: fixed;
  bottom: 84px;
  right: 24px;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 590px;
  max-height: calc(100vh - 110px);
  z-index: 995;
  background: rgba(22, 17, 14, 0.94);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.8), 0 0 30px rgba(212, 175, 55, 0.15);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.96);
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.nilwala-ai-window.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* ==========================================================================
   3. CHAT HEADER
   ========================================================================== */
.ai-header {
  padding: 1rem 1.25rem;
  background: linear-gradient(180deg, rgba(33, 24, 19, 0.9) 0%, rgba(22, 17, 14, 0.95) 100%);
  border-bottom: 1px solid var(--glass-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-shrink: 0;
}

.ai-header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ai-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: rgba(212, 175, 55, 0.15);
  border: 1px solid var(--color-gold-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-gold-soft);
  flex-shrink: 0;
}

.ai-header-text h3 {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin: 0;
  line-height: 1.2;
}

.ai-status-indicator {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-sans);
  font-size: 0.68rem;
  color: var(--color-gold-soft);
}

.ai-status-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: #66BB6A;
  box-shadow: 0 0 6px #66BB6A;
}

.ai-header-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.ai-control-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: transparent;
  border: 1px solid transparent;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--duration-fast);
}

.ai-control-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-text-primary);
}

/* Mode Banner */
.ai-mode-banner {
  padding: 0.4rem 1rem;
  background: rgba(45, 32, 24, 0.7);
  border-bottom: 1px solid var(--glass-border-subtle);
  font-family: var(--font-sans);
  font-size: 0.68rem;
  color: var(--color-text-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.ai-mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--color-gold-soft);
  font-weight: 500;
  transition: color var(--duration-fast);
}

.ai-mode-badge.live {
  color: #81C784;
}

.ai-mode-badge.live .ai-badge-sparkle {
  color: #A5D6A7;
  display: inline-block;
  animation: aiPulse 2s infinite;
}

/* ==========================================================================
   4. CHAT MESSAGE BODY
   ========================================================================== */
.ai-messages-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
}

.ai-msg {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  animation: aiFadeIn 0.3s ease;
}

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

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

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

.ai-bubble {
  padding: 0.85rem 1.05rem;
  border-radius: 14px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  line-height: 1.55;
}

.ai-msg-bot .ai-bubble {
  background: rgba(33, 24, 19, 0.85);
  border: 1px solid var(--glass-border-subtle);
  border-left: 3px solid var(--color-gold-primary);
  color: var(--color-text-secondary);
  border-bottom-left-radius: 4px;
}

.ai-msg-bot .ai-bubble strong {
  color: var(--color-warm-ivory);
}

.ai-msg-bot .ai-bubble em {
  color: var(--color-gold-soft);
  font-style: italic;
}

.ai-msg-user .ai-bubble {
  background: linear-gradient(135deg, var(--color-gold-primary) 0%, var(--color-gold-soft) 100%);
  color: #14100D;
  font-weight: 500;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 14px rgba(212, 175, 55, 0.25);
}

.ai-msg-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.25rem;
  padding: 0 0.35rem;
}

.ai-msg-source-tag {
  font-family: var(--font-sans);
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
}

.ai-msg-source-tag.preview {
  color: var(--color-gold-soft);
  background: rgba(212, 175, 55, 0.1);
  border: 1px solid rgba(212, 175, 55, 0.25);
}

.ai-msg-source-tag.live {
  color: #81C784;
  background: rgba(129, 199, 132, 0.12);
  border: 1px solid rgba(129, 199, 132, 0.3);
}

.ai-msg-time {
  font-size: 0.65rem;
  color: var(--color-text-dim);
}

.ai-msg-user .ai-msg-meta-row {
  justify-content: flex-end;
}

/* Bot Message Action Buttons */
.ai-msg-action-btn {
  margin-top: 0.65rem;
  padding: 0.5rem 0.95rem;
  border-radius: var(--radius-full);
  background: rgba(212, 175, 55, 0.15);
  border: 1px solid var(--color-gold-primary);
  color: var(--color-gold-soft);
  font-family: var(--font-sans);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: all var(--duration-fast);
  text-decoration: none;
}

.ai-msg-action-btn:hover {
  background: var(--color-gold-primary);
  color: #14100D;
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.35);
}

/* Typing Bubble Indicator */
.ai-typing-indicator {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.75rem 1rem;
  background: rgba(33, 24, 19, 0.75);
  border: 1px solid var(--glass-border-subtle);
  border-radius: 14px;
  width: fit-content;
}

.ai-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--color-gold-primary);
  animation: aiDotPulse 1.4s infinite ease-in-out;
}

.ai-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes aiDotPulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1.1); opacity: 1; }
}

/* ==========================================================================
   5. SUGGESTIONS TRAY
   ========================================================================== */
.ai-suggestions-tray {
  padding: 0.5rem 1rem;
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  flex-shrink: 0;
  background: rgba(18, 14, 11, 0.9);
  border-top: 1px solid var(--glass-border-subtle);
  scrollbar-width: none;
}

.ai-suggestions-tray::-webkit-scrollbar {
  display: none;
}

.ai-chip {
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  background: rgba(33, 24, 19, 0.85);
  border: 1px solid var(--glass-border-subtle);
  color: var(--color-text-secondary);
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all var(--duration-fast);
}

.ai-chip:hover {
  border-color: var(--color-gold-primary);
  color: var(--color-gold-soft);
  background: rgba(212, 175, 55, 0.1);
}

/* ==========================================================================
   6. INPUT FORM & FOOTER
   ========================================================================== */
.ai-input-wrapper {
  padding: 0.75rem 1rem 0.5rem;
  background: rgba(22, 17, 14, 0.98);
  border-top: 1px solid var(--glass-border-subtle);
  flex-shrink: 0;
}

.ai-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(15, 12, 10, 0.85);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  padding: 0.25rem 0.45rem 0.25rem 1rem;
  transition: border-color var(--duration-fast);
}

.ai-form:focus-within {
  border-color: var(--color-gold-primary);
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.2);
}

.ai-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  font-size: 0.84rem;
  outline: none;
}

.ai-input::placeholder {
  color: var(--color-text-dim);
}

.ai-send-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--color-gold-primary);
  border: none;
  color: #14100D;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--duration-fast);
  flex-shrink: 0;
}

.ai-send-btn:hover:not(:disabled) {
  background: var(--color-gold-soft);
  transform: scale(1.08);
}

.ai-send-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.ai-footer-disclaimer {
  font-family: var(--font-sans);
  font-size: 0.64rem;
  color: var(--color-text-dim);
  text-align: center;
  padding: 0.25rem 1rem 0.6rem;
  line-height: 1.35;
}

/* ==========================================================================
   7. RESPONSIVE MEDIA QUERIES FOR AI WINDOW
   ========================================================================== */
@media (max-width: 480px) {
  .nilwala-ai-dock {
    bottom: 18px;
    right: 18px;
    padding: 0.65rem 0.95rem 0.65rem 0.75rem;
  }

  .nilwala-ai-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100vw;
    max-width: 100vw;
    height: 85vh;
    max-height: 85vh;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
  }
}
