/* AI Chatbot Styles */
#chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Toggle Button */
.chatbot-toggle {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    border: none;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
}

.chatbot-toggle:active {
    transform: scale(0.95);
}

.chatbot-toggle svg {
    width: 32px;
    height: 32px;
    color: white;
    transition: all 0.3s ease;
}

.chatbot-toggle .chat-icon {
    opacity: 1;
    transform: rotate(0deg);
}

.chatbot-toggle .close-icon {
    position: absolute;
    opacity: 0;
    transform: rotate(90deg);
}

.chatbot-toggle.active .chat-icon {
    opacity: 0;
    transform: rotate(-90deg);
}

.chatbot-toggle.active .close-icon {
    opacity: 1;
    transform: rotate(0deg);
}

/* Notification Badge */
.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: bold;
    border: 2px solid white;
    animation: badgePulse 2s ease-in-out infinite;
}

.notification-badge.hidden {
    display: none;
}

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

/* Friendly attention animation - subtle bounce */
.chatbot-toggle.attention-grab {
    animation: gentleBounce 0.6s ease-in-out 2;
}

@keyframes gentleBounce {
    0%, 100% {
        transform: translateY(0) scale(1);
    }
    25% {
        transform: translateY(-8px) scale(1.05);
    }
    50% {
        transform: translateY(-4px) scale(1.03);
    }
    75% {
        transform: translateY(-6px) scale(1.04);
    }
}

/* Subtle pulsing ring effect */
.chatbot-toggle::before {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid rgba(59, 130, 246, 0.3);
    opacity: 0;
    pointer-events: none;
}

.chatbot-toggle.attention-grab::before {
    animation: subtleRing 2s ease-out infinite;
}

@keyframes subtleRing {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }
    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

/* Welcome message bubble */
.chat-welcome-bubble {
    position: absolute;
    bottom: 85px;
    right: 0;
    background: white;
    padding: 16px 20px;
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    width: 280px;
    opacity: 0;
    transform: translateY(10px) scale(0.9);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-welcome-bubble.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.chat-welcome-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 20px;
    width: 16px;
    height: 16px;
    background: white;
    transform: rotate(45deg);
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.chat-welcome-bubble p {
    margin: 0;
    font-size: 14px;
    color: #1f2937;
    line-height: 1.5;
}

.chat-welcome-bubble strong {
    color: #3b82f6;
    font-weight: 600;
}

.chat-welcome-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 2px;
    line-height: 1;
    font-size: 18px;
    transition: color 0.2s;
}

.chat-welcome-close:hover {
    color: #4b5563;
}

/* Chat Window */
.chatbot-window {
    position: absolute;
    bottom: 90px;
    right: 0;
    width: 450px;
    max-width: calc(100vw - 40px);
    height: 700px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chatbot-window.active {
    display: flex;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Chat Header */
.chatbot-header {
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

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

.chatbot-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.chatbot-avatar svg {
    width: 24px;
    height: 24px;
    color: white;
}

.chatbot-header-text h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chatbot-status {
    margin: 4px 0 0 0;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0.9;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.chatbot-minimize {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

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

.chatbot-minimize svg {
    width: 20px;
    height: 20px;
    color: white;
}

/* Chat Messages */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.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;
}

/* Message Styles */
.message {
    display: flex;
    gap: 10px;
    animation: messageSlide 0.3s ease-out;
}

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

.message-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.message-avatar svg {
    width: 20px;
    height: 20px;
    color: white;
}

.message-content {
    flex: 1;
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    font-size: 14px;
    line-height: 1.6;
}

.message-content p {
    margin: 0 0 8px 0;
    line-height: 1.6;
    color: #374151;
}

.message-content p:last-child {
    margin-bottom: 0;
}

/* Headers */
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
    margin: 12px 0 8px 0;
    font-weight: 600;
    color: #1f2937;
    line-height: 1.4;
}

.message-content h3:first-child,
.message-content h4:first-child,
.message-content h5:first-child,
.message-content h6:first-child {
    margin-top: 0;
}

.message-content h3 {
    font-size: 16px;
}

.message-content h4 {
    font-size: 15px;
}

.message-content h5,
.message-content h6 {
    font-size: 14px;
}

/* Lists */
.message-content ul,
.message-content ol {
    margin: 8px 0;
    padding-left: 24px;
}

.message-content ul {
    list-style-type: disc;
}

.message-content ol {
    list-style-type: decimal;
}

.message-content li {
    margin: 4px 0;
    color: #374151;
    line-height: 1.6;
}

.message-content li > ul,
.message-content li > ol {
    margin-top: 4px;
}

/* Code */
.message-content code {
    background: #f3f4f6;
    color: #1f2937;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 13px;
    word-break: break-word;
}

.message-content pre {
    background: #1f2937;
    color: #f9fafb;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
    max-width: 100%;
}

.message-content pre::-webkit-scrollbar {
    height: 6px;
}

.message-content pre::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.message-content pre::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.message-content pre::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

.message-content pre code {
    background: transparent;
    color: inherit;
    padding: 0;
    font-size: 13px;
    line-height: 1.5;
    display: block;
    white-space: pre;
}

/* Blockquotes */
.message-content blockquote {
    border-left: 3px solid #3b82f6;
    padding-left: 12px;
    margin: 8px 0;
    color: #6b7280;
    font-style: italic;
}

/* Horizontal Rules */
.message-content hr {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 12px 0;
}

/* Links */
.message-content a {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 500;
    word-break: break-word;
}

.message-content a:hover {
    text-decoration: underline;
}

/* Strong and Emphasis */
.message-content strong {
    font-weight: 600;
    color: #1f2937;
}

.message-content em {
    font-style: italic;
}

/* Line breaks */
.message-content br {
    display: block;
    content: "";
    margin: 4px 0;
}

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

.user-message .message-avatar {
    background: #223046;
}

.user-message .message-content {
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    color: white;
}

.user-message .message-content p,
.user-message .message-content li,
.user-message .message-content h3,
.user-message .message-content h4,
.user-message .message-content h5,
.user-message .message-content h6 {
    color: white;
}

.user-message .message-content a {
    color: white;
    text-decoration: underline;
}

.user-message .message-content code {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.user-message .message-content pre {
    background: rgba(0, 0, 0, 0.3);
}

.user-message .message-content blockquote {
    border-left-color: rgba(255, 255, 255, 0.5);
    color: rgba(255, 255, 255, 0.9);
}

.user-message .message-content hr {
    border-top-color: rgba(255, 255, 255, 0.3);
}

.user-message .message-content strong {
    color: white;
}

/* Typing Indicator */
.typing-indicator {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 0 20px;
    animation: messageSlide 0.3s ease-out;
}

.typing-indicator.active {
    display: flex;
}

.typing-dots {
    display: flex;
    gap: 4px;
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}

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

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

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Chat Input */
.chatbot-input-container {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #e5e7eb;
}

.chatbot-form {
    display: flex;
    gap: 8px;
}

.chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
    background: #f9fafb;
}

.chatbot-input:focus {
    border-color: #3b82f6;
    background: white;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.chatbot-send {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chatbot-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.chatbot-send:active {
    transform: scale(0.95);
}

.chatbot-send svg {
    width: 20px;
    height: 20px;
    color: white;
}

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

/* Mobile Responsiveness */
@media (max-width: 480px) {
    #chatbot-container {
        bottom: 10px;
        right: 10px;
    }

    .chatbot-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 80px;
        right: -10px;
    }

    .chatbot-toggle {
        width: 64px;
        height: 64px;
    }

    .chatbot-toggle svg {
        width: 28px;
        height: 28px;
    }

    .chat-welcome-bubble {
        width: 240px;
        bottom: 80px;
        padding: 14px 16px;
    }

    .chat-welcome-bubble::after {
        right: 14px;
    }
}
