
/* AI Chatbot Frontend Styles */
:root {
    --chatbot-primary: #3B82F6;
    --chatbot-primary-dark: #1D4ED8;
    --chatbot-secondary: #F3F4F6;
    --chatbot-text: #374151;
    --chatbot-text-light: #6B7280;
    --chatbot-white: #FFFFFF;
    --chatbot-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    --chatbot-border-radius: 16px;
    --chatbot-animation-speed: 0.3s;
}

.chatbot-widget {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.chatbot-widget.chatbot-bottom-right {
    bottom: 20px;
    right: 20px;
}

.chatbot-widget.chatbot-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Chat Button */
.chatbot-button {
    position: relative;
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--chatbot-shadow);
    transition: all var(--chatbot-animation-speed) cubic-bezier(0.4, 0, 0.2, 1);
    animation: chatbotPulse 2s infinite;
}

.chatbot-button:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 30px rgba(59, 130, 246, 0.4);
}

.chatbot-button-icon {
    position: relative;
    width: 24px;
    height: 24px;
}

.chatbot-button-icon svg {
    position: absolute;
    top: 0;
    left: 0;
    transition: all var(--chatbot-animation-speed) ease;
}

.chatbot-button-icon img {
    position: absolute;
    top: 0;
    left: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    transition: all var(--chatbot-animation-speed) ease;
}

.chatbot-notification {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    background: #EF4444;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 600;
    border: 2px solid white;
    animation: chatbotBounce 0.6s ease;
}

/* Chat Window - Enhanced positioning */
.chatbot-window {
    position: fixed;
    bottom: 100px;
    width: 380px;
    height: 500px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 140px);
    background: var(--chatbot-white);
    border-radius: var(--chatbot-border-radius);
    box-shadow: var(--chatbot-shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.8) translateY(20px);
    opacity: 0;
    transition: all var(--chatbot-animation-speed) cubic-bezier(0.4, 0, 0.2, 1);
}

.chatbot-widget.chatbot-bottom-right .chatbot-window {
    right: 0;
}

.chatbot-widget.chatbot-bottom-left .chatbot-window {
    left: 0;
}

.chatbot-window.chatbot-open {
    display: flex;
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* Chat Header */
.chatbot-header {
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-primary-dark) 100%);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    color: white;
    flex-shrink: 0;
}

.chatbot-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    overflow: hidden;
}

.chatbot-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.chatbot-info {
    flex: 1;
}

.chatbot-info h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chatbot-info .status {
    font-size: 12px;
    opacity: 0.8;
    display: flex;
    align-items: center;
}

.chatbot-info .status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #10B981;
    border-radius: 50%;
    margin-right: 6px;
    animation: chatbotStatusPulse 2s infinite;
}

.chatbot-minimize {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.chatbot-minimize:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Messages Area - Fixed scrolling */
.chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    background: #F9FAFB;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
    scroll-behavior: smooth;
    /* Enhanced cross-browser scrollbar styling */
    scrollbar-width: thin;
}

/* Webkit browsers (Chrome, Safari, Edge) */
.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #D1D5DB;
    border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #9CA3AF;
}

/* Firefox - using supported properties only */
@supports (scrollbar-width: thin) {
    .chatbot-messages {
        scrollbar-width: thin;
        scrollbar-color: #D1D5DB transparent;
    }
}

.message {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    animation: chatbotMessageSlide 0.3s ease;
    max-width: 100%;
}

.message.user-message {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.bot-message .message-avatar {
    background: var(--chatbot-primary);
    color: white;
}

.user-message .message-avatar {
    background: #6B7280;
    color: white;
}

.message-content {
    max-width: calc(100% - 44px);
    background: var(--chatbot-white);
    border-radius: 16px;
    padding: 12px 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    position: relative;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.user-message .message-content {
    background: var(--chatbot-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.bot-message .message-content {
    border-bottom-left-radius: 4px;
}

.message-content p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: inherit;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message-content p a {
    color: inherit;
    text-decoration: underline;
}

.user-message .message-content p a {
    color: rgba(255, 255, 255, 0.9);
}

.bot-message.error-message .message-content {
    background: #FEE2E2;
    border-left: 4px solid #EF4444;
    color: #B91C1C;
}

.message-time {
    font-size: 11px;
    opacity: 0.6;
    margin-top: 8px;
    display: block;
}

/* Typing Indicator */
.chatbot-typing {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--chatbot-white);
    border-top: 1px solid #E5E7EB;
    flex-shrink: 0;
}

.typing-indicator {
    display: flex;
    gap: 4px;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--chatbot-primary);
    border-radius: 50%;
    animation: chatbotTyping 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

.typing-text {
    font-size: 12px;
    color: var(--chatbot-text-light);
}

/* Input Area */
.chatbot-input {
    padding: 20px;
    background: var(--chatbot-white);
    border-top: 1px solid #E5E7EB;
    flex-shrink: 0;
}

.input-container {
    display: flex;
    align-items: center;
    background: #F3F4F6;
    border-radius: 24px;
    padding: 4px 4px 4px 16px;
    transition: box-shadow 0.2s;
}

.input-container:focus-within {
    box-shadow: 0 0 0 2px var(--chatbot-primary);
}

.chatbot-message-input {
    flex: 1;
    border: none;
    background: none;
    padding: 12px 0;
    font-size: 14px;
    outline: none;
    color: var(--chatbot-text);
    min-width: 0;
}

.chatbot-message-input::placeholder {
    color: var(--chatbot-text-light);
}

.chatbot-send-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--chatbot-primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chatbot-send-button:hover:not(:disabled) {
    background: var(--chatbot-primary-dark);
    transform: scale(1.05);
}

.chatbot-send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Animations */
@keyframes chatbotPulse {
    0% {
        box-shadow: 0 4px 20px rgba(59, 130, 246, 0.3);
    }
    50% {
        box-shadow: 0 4px 30px rgba(59, 130, 246, 0.5);
    }
    100% {
        box-shadow: 0 4px 20px rgba(59, 130, 246, 0.3);
    }
}

@keyframes chatbotBounce {
    0%, 20%, 53%, 80%, 100% {
        transform: translate(0, 0);
    }
    40%, 43% {
        transform: translate(0, -8px);
    }
    70% {
        transform: translate(0, -4px);
    }
    90% {
        transform: translate(0, -2px);
    }
}

@keyframes chatbotStatusPulse {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes chatbotTyping {
    0%, 80%, 100% {
        opacity: 0.5;
        transform: translateY(0);
    }
    40% {
        opacity: 1;
        transform: translateY(-6px);
    }
}

@keyframes chatbotMessageSlide {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Enhanced Mobile Responsiveness */
@media (max-width: 480px) {
    .chatbot-widget.chatbot-bottom-right,
    .chatbot-widget.chatbot-bottom-left {
        bottom: 10px;
        left: 10px;
        right: 10px;
    }
    
    .chatbot-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 120px);
        bottom: 80px;
        left: 10px !important;
        right: 10px !important;
        margin: 0;
    }
    
    .message-content {
        max-width: calc(100% - 44px);
        font-size: 14px;
    }
    
    .chatbot-messages {
        padding: 15px;
        gap: 12px;
    }
    
    .chatbot-input {
        padding: 15px;
    }
}

@media (max-width: 320px) {
    .chatbot-window {
        height: calc(100vh - 100px);
        bottom: 70px;
    }
    
    .chatbot-messages {
        padding: 12px;
    }
    
    .chatbot-input {
        padding: 12px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .chatbot-messages {
        background: #1F2937;
    }
    
    .message-content {
        background: #374151;
        color: #F9FAFB;
    }
    
    .user-message .message-content {
        background: var(--chatbot-primary);
        color: white;
    }
    
    .chatbot-input {
        background: #374151;
        border-color: #4B5563;
    }
    
    .input-container {
        background: #4B5563;
    }
    
    .chatbot-message-input {
        color: #F9FAFB;
    }
    
    .chatbot-message-input::placeholder {
        color: #9CA3AF;
    }
}

/* Focus styles for accessibility */
.chatbot-button:focus,
.chatbot-send-button:focus,
.chatbot-minimize:focus {
    outline: 2px solid #3B82F6;
    outline-offset: 2px;
}

.chatbot-message-input:focus {
    outline: none;
}

/* Loading states */
.chatbot-send-button.loading svg {
    animation: spin 1s linear infinite;
}

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

/* Error message specific styling */
.error-message .message-content {
    background: #FEE2E2 !important;
    border-left: 4px solid #EF4444 !important;
    color: #B91C1C !important;
}
