/**
 * Persistent Chatbot Styles
 * Modular CSS for chatbot component across all pages
 */

/* Main chatbot container */
#chatbot-container {
    position: fixed !important;
    bottom: 1.5rem !important;
    right: 1.5rem !important;
    z-index: 9999 !important;
    contain: layout style;
}

/* Chat toggle button */
#chatbot-toggle {
    width: 4rem;
    height: 4rem;
    background: linear-gradient(to right, var(--brand-color, #3b82f6), var(--brand-light-color, #60a5fa));
    border-radius: 9999px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
}

#chatbot-toggle:hover {
    box-shadow: 0 25px 50px -12px rgba(59, 130, 246, 0.3);
    transform: scale(1.1);
}

/* Chat toggle button effects */
#chatbot-toggle::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #3b82f6, #60a5fa, #3b82f6);
    border-radius: inherit;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#chatbot-toggle::after {
    content: '';
    position: absolute;
    inset: 0;
    background: inherit;
    border-radius: inherit;
    z-index: -1;
}

/* Chat window container */
#chatbot-window {
    position: absolute;
    bottom: 5rem;
    right: 0;
    width: 24rem;
    height: 24rem;
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    transition: transform 0.3s ease, opacity 0.3s ease;
    will-change: transform, opacity;
    contain: content;
}

/* Chatbot window visible state */
#chatbot-window.chatbot-open {
    display: flex !important;
    flex-direction: column;
    visibility: visible !important;
    opacity: 1 !important;
    transform: scale(1) translateY(0);
}

/* Chatbot window hidden state */
#chatbot-window:not(.chatbot-open) {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    transform: scale(0.95) translateY(20px);
}

/* Chat messages area */
#chat-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    max-height: calc(100% - 120px);
    scroll-behavior: smooth;
    contain: strict;
}

#chat-messages::-webkit-scrollbar {
    width: 4px;
}

#chat-messages::-webkit-scrollbar-track {
    background: rgba(75, 85, 99, 0.3);
    border-radius: 2px;
}

#chat-messages::-webkit-scrollbar-thumb {
    background: rgba(59, 130, 246, 0.5);
    border-radius: 2px;
}

#chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(59, 130, 246, 0.7);
}

/* Chat input area */
#chat-input {
    flex: 1;
    background: rgba(31, 41, 55, 0.5);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    color: white;
    font-size: 0.875rem;
    transition: border-color 0.2s ease;
}

#chat-input:focus {
    outline: none;
    border-color: rgba(59, 130, 246, 1);
}

#chat-input::placeholder {
    color: rgba(156, 163, 175, 0.7);
}

/* Chat send button */
#chat-send {
    background: linear-gradient(to right, var(--brand-color, #3b82f6), var(--brand-light-color, #60a5fa));
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

#chat-send:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* Chat header */
.chatbot-header {
    padding: 1rem;
    border-bottom: 1px solid rgba(59, 130, 246, 0.2);
}

/* Chat close button */
#chatbot-close {
    background: none;
    border: none;
    color: rgba(156, 163, 175, 1);
    cursor: pointer;
    transition: color 0.2s ease;
    padding: 0.25rem;
}

#chatbot-close:hover {
    color: white;
}

/* Message bubbles */
.message-user {
    justify-content: flex-end;
}

.message-bot {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 75%;
    padding: 0.75rem;
    border-radius: 0.75rem;
    word-wrap: break-word;
}

.message-bubble.user {
    background: linear-gradient(to right, var(--brand-color, #3b82f6), var(--brand-light-color, #60a5fa));
    color: white;
}

.message-bubble.bot {
    background: rgba(31, 41, 55, 0.5);
    color: white;
}

/* Responsive design */
@media (max-width: 768px) {
    #chatbot-container {
        bottom: 1rem;
        right: 1rem;
    }
    
    #chatbot-window {
        width: 90vw !important;
        max-width: 400px !important;
        height: 500px !important;
        right: 5vw !important;
        left: 5vw !important;
        bottom: 5rem !important;
        min-width: 320px !important;
        position: fixed;
    }
    
    #chatbot-toggle {
        width: 3.5rem;
        height: 3.5rem;
    }
    
    #chat-messages {
        max-height: calc(100% - 140px);
    }
}

@media (max-width: 480px) {
    #chatbot-container,
    #chatbot-toggle {
        bottom: 1rem;
        right: 1rem;
    }
    
    #chatbot-window {
        width: 95vw !important;
        right: 2.5vw !important;
        left: 2.5vw !important;
        height: 70vh !important;
        max-height: 500px !important;
    }
}


/* Dark mode compatibility */
@media (prefers-color-scheme: dark) {
    #chatbot-window {
        background: rgba(17, 24, 39, 0.98);
        border-color: rgba(59, 130, 246, 0.4);
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    #chatbot-toggle {
        border: 2px solid white;
    }
    
    #chatbot-window {
        border: 2px solid rgba(59, 130, 246, 0.8);
    }
    
    #chat-input {
        border: 1px solid rgba(59, 130, 246, 0.6);
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    #chatbot-toggle,
    #chatbot-window,
    .chatbot-fade-in,
    .chatbot-fade-out {
        transition: none;
        animation: none;
    }
}