/* Chatbot-specific styles */

#chatbot-embed {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    /* Ensure the fixed container doesn't block clicks elsewhere */
    pointer-events: none;
}

#chat-widget {
    transition: all 0.3s ease-in-out;
    transform-origin: bottom right;
    transform: scale(0.95) translateY(10px);
    opacity: 0;
    visibility: hidden;
    margin-bottom: 1rem; /* Keep close to toggle so top stays visible */
    /* Disable interactions when closed */
    pointer-events: none;
    /* Ensure the widget always fits the viewport */
    height: auto;
    max-height: calc(100vh - 180px); /* ensure the top never goes off-screen */
    width: min(95vw, 24rem);
    overflow: hidden; /* contain inner scroll area */
}

#chat-widget.is-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    visibility: visible;
    /* Re-enable interactions when open */
    pointer-events: auto;
}

/* Small screens: slightly smaller height to avoid header overlaps */
@media (max-width: 640px) {
  #chat-widget {
    max-height: calc(100vh - 200px);
    width: min(96vw, 22rem);
  }
}

/* The floating toggle should always be clickable */
#chat-toggle {
    pointer-events: auto;
    z-index: 1001; /* above container but below cart modal (1002) */
}


#chat-container::-webkit-scrollbar {
    width: 8px;
}

#chat-container::-webkit-scrollbar-track {
    background: #1f2937;
}

#chat-container::-webkit-scrollbar-thumb {
    background-color: #4f46e5;
    border-radius: 20px;
    border: 3px solid #1f2937;
}

.ai-message .avatar {
    box-shadow: 0 0 15px rgba(79, 70, 229, 0.7);
}

.loader {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #4f46e5;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Add Orbitron and Inter fonts */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&family=Inter:wght@400;500;600&display=swap');

.orbitron {
    font-family: 'Orbitron', sans-serif;
}

/* Ensure the chatbot uses the Inter font */
#chat-widget,
#chat-widget input,
#chat-widget button {
    font-family: 'Inter', sans-serif;
}

/* Ambient pulse for chat toggle */
#chat-toggle img {
    animation: breathe 3.5s ease-in-out infinite;
    filter: drop-shadow(0 0 6px rgba(0, 255, 255, 0.25));
    transition: transform 0.2s ease, filter 0.2s ease;
}

#chat-toggle:hover img {
    transform: scale(1.04);
    filter: drop-shadow(0 0 10px rgba(0, 255, 255, 0.45));
}

@keyframes breathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

/* Typing state styles */
#chat-widget.is-typing .avatar {
    box-shadow: 0 0 18px rgba(0, 255, 255, 0.55);
    animation: pulse-glow 1.4s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 8px rgba(0, 255, 255, 0.35); }
    50% { box-shadow: 0 0 18px rgba(0, 255, 255, 0.75); }
}

/* Three-dot typing indicator */
.typing-dots { display: inline-flex; gap: 4px; align-items: center; }
.typing-dots span {
    width: 6px; height: 6px; border-radius: 50%;
    background: #9ca3af;
    opacity: 0.6;
    animation: bounce 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.6; }
    40% { transform: translateY(-4px); opacity: 1; }
}

/* Error status morph */
#chat-widget.has-error .avatar {
    background: #ef4444 !important;
    box-shadow: 0 0 14px rgba(239, 68, 68, 0.7);
}
#chat-widget.has-error .ai-bubble,
#chat-widget.has-error .bg-indigo-500\/20 { /* keep compatibility with existing classes */
    outline: 2px solid rgba(239, 68, 68, 0.4);
}

/* Mobile refinements: keep effects active but tuned for small screens */
@media (max-width: 640px) {
    #chat-toggle img {
        animation-duration: 3s; /* slightly quicker but still subtle */
        filter: drop-shadow(0 0 4px rgba(0, 255, 255, 0.25));
    }

    #chat-widget.is-typing .avatar {
        animation-duration: 1.2s;
        box-shadow: 0 0 14px rgba(0, 255, 255, 0.55);
    }

    .typing-dots span {
        width: 5px;
        height: 5px;
    }
}