/* Chatbot Widget Styles */
.chatbot-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    transition: bottom 0.3s ease;
}

/* Adjust position when sticky footer is visible */
body:has(.sticky-cta-footer.visible) .chatbot-widget {
    bottom: 96px;
}

.chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
}

.chatbot-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.chatbot-toggle .chatbot-icon,
.chatbot-toggle .chatbot-close-icon {
    width: 28px;
    height: 28px;
    color: white;
    position: absolute;
    transition: all 0.3s ease;
}

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

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

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

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

.chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s ease;
}

.chatbot-widget.open .chatbot-window {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

.chatbot-header {
    padding: 20px;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    color: white;
    border-radius: 16px 16px 0 0;
    position: relative;
}

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

.chatbot-subtitle {
    margin: 4px 0 0 0;
    font-size: 13px;
    opacity: 0.9;
}

.chatbot-mobile-close {
    display: none;
    position: absolute;
    top: 16px;
    right: 16px;
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    transition: background 0.2s ease;
}

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

.chatbot-mobile-close svg {
    width: 20px;
    height: 20px;
}

.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f9fafb;
}

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

.chatbot-message {
    display: flex;
    margin-bottom: 8px;
}

.message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.bot-message .message-content {
    background: white;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-radius: 12px 12px 12px 4px;
}

/* Markdown HTML styling */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
    margin: 0.5em 0;
    font-weight: 600;
    line-height: 1.3;
}

.message-content h1 { font-size: 1.5em; }
.message-content h2 { font-size: 1.3em; }
.message-content h3 { font-size: 1.1em; }
.message-content h4 { font-size: 1em; }

.message-content p {
    margin: 0.5em 0;
}

.message-content p:first-child {
    margin-top: 0;
}

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

.message-content ul,
.message-content ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.message-content li {
    margin: 0.25em 0;
}

.message-content strong {
    font-weight: 600;
}

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

.message-content code {
    background: #f3f4f6;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.message-content pre {
    background: #f3f4f6;
    padding: 0.75em;
    border-radius: 6px;
    overflow-x: auto;
    margin: 0.5em 0;
}

.message-content pre code {
    background: transparent;
    padding: 0;
}

.message-content a {
    color: #1a1a1a;
    text-decoration: underline;
}

.message-content a:hover {
    color: #2d2d2d;
}

.message-content blockquote {
    border-left: 3px solid #e5e7eb;
    padding-left: 1em;
    margin: 0.5em 0;
    color: #6b7280;
}

.user-message {
    justify-content: flex-end;
}

.user-message .message-content {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    color: white;
    border-radius: 12px 12px 4px 12px;
}

.chatbot-input-container {
    display: flex;
    gap: 8px;
    padding: 16px;
    background: white;
    border-top: 1px solid #e5e7eb;
    border-radius: 0 0 16px 16px;
}

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

.chatbot-input:focus {
    border-color: #1a1a1a;
    box-shadow: 0 0 0 3px rgba(26, 26, 26, 0.1);
}

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

.chatbot-send-btn:hover {
    transform: scale(1.05);
}

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

/* Typing indicator */
.typing-indicator .message-content {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.typing-indicator .message-content span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Fade in animation for messages */
.fade-in-message {
    animation: fadeInUp 0.3s ease;
}

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

/* Mobile responsiveness */
@media (max-width: 640px) {
    .chatbot-window {
        width: calc(100vw - 32px);
        height: calc(100vh - 120px);
        max-height: none;
    }

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

    /* Show close button on mobile */
    .chatbot-mobile-close {
        display: block;
    }

    /* Adjust position when sticky footer is visible on mobile */
    body:has(.sticky-cta-footer.visible) .chatbot-widget {
        bottom: 148px;
    }
}
