/* AI Demo Styles */
.ai-demo {
    max-height: 600px;
    overflow-y: auto;
    padding-right: 8px; /* Space for scrollbar */
}

.ai-demo::-webkit-scrollbar {
    width: 8px;
}

.ai-demo::-webkit-scrollbar-track {
    background: var(--card-background);
    border-radius: 4px;
}

.ai-demo::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.ai-demo::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-text);
}

/* Ensure smooth scrolling within demo areas */
.ai-demo {
    scroll-behavior: smooth;
}

/* Chatbot Styles */
.chatbot-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1000;
}

.chatbot-button {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--accent-green), #00cc35);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 255, 65, 0.3);
    transition: all 0.3s ease;
}

body.light-mode .chatbot-button {
    background: linear-gradient(135deg, var(--accent-blue), #0066ff);
    box-shadow: 0 4px 12px rgba(0, 0, 255, 0.3);
}

.chatbot-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 255, 65, 0.4);
}

body.light-mode .chatbot-button:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 255, 0.4);
}

.chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background-color: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

body.light-mode .chatbot-window {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.chatbot-header {
    background-color: var(--background-color);
    color: var(--primary-text);
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chatbot-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--accent-green);
}

body.light-mode .chatbot-header h3 {
    color: var(--accent-blue);
}

#chatbot-close {
    background: none;
    border: none;
    color: var(--secondary-text);
    cursor: pointer;
    font-size: 1.5rem;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#chatbot-close:hover {
    color: var(--primary-text);
}

.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message {
    max-width: 80%;
    animation: fadeInUp 0.3s ease-out;
}

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

.user-message {
    align-self: flex-end;
}

.bot-message {
    align-self: flex-start;
}

.message-content {
    padding: 0.75rem 1rem;
    border-radius: 18px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.user-message .message-content {
    background-color: var(--accent-green);
    color: #000;
    border-bottom-right-radius: 4px;
}

body.light-mode .user-message .message-content {
    background-color: var(--accent-blue);
    color: #fff;
}

.bot-message .message-content {
    background-color: var(--background-color);
    color: var(--primary-text);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

.chatbot-input-area {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.chatbot-input {
    flex: 1;
    background-color: var(--card-background);
    border: 1px solid var(--border-color);
    color: var(--primary-text);
    padding: 0.75rem;
    border-radius: 20px;
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.3s;
}

.chatbot-input:focus {
    border-color: var(--accent-green);
    box-shadow: 0 0 0 2px rgba(0, 255, 65, 0.2);
}

body.light-mode .chatbot-input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(0, 0, 255, 0.2);
}

.chatbot-send-btn {
    width: 40px;
    height: 40px;
    background-color: var(--accent-green);
    color: #000;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

body.light-mode .chatbot-send-btn {
    background-color: var(--accent-blue);
    color: #fff;
}

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

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

/* Custom scrollbar for chat messages */
.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: var(--card-background);
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-text);
}

/* Proactive Chat Popup */
.chatbot-popup {
    position: absolute;
    bottom: 80px;
    right: -10px;
    background-color: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    max-width: 360px;
    width: 360px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateY(10px) scale(0.95);
    transition: all 0.3s ease;
    pointer-events: none;
}

body.light-mode .chatbot-popup {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.chatbot-popup.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

.chatbot-popup::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 25px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid var(--border-color);
}

.chatbot-popup::before {
    content: '';
    position: absolute;
    bottom: -7px;
    right: 25px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid var(--card-background);
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.popup-avatar {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent-green), #00cc35);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.8rem;
    font-weight: bold;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

body.light-mode .popup-avatar {
    background: linear-gradient(135deg, var(--accent-blue), #0066ff);
}

.popup-close {
    background: none;
    border: none;
    color: var(--secondary-text);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
}

.popup-close:hover {
    color: var(--primary-text);
}

.popup-content {
    display: flex;
    align-items: flex-start;
}

.popup-message {
    flex: 1;
}

.popup-text {
    color: var(--primary-text);
    font-size: 0.9rem;
    line-height: 1.4;
    margin-bottom: 0.75rem;
}

.popup-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.popup-btn {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--primary-text);
    border-radius: 16px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s ease;
}

.popup-btn:hover {
    border-color: var(--accent-green);
    color: var(--accent-green);
}

body.light-mode .popup-btn:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.popup-btn.primary {
    background-color: var(--accent-green);
    color: #000;
    border-color: var(--accent-green);
}

body.light-mode .popup-btn.primary {
    background-color: var(--accent-blue);
    color: #fff;
    border-color: var(--accent-blue);
}

.popup-btn.primary:hover {
    opacity: 0.8;
}

/* Notification dot on chat button */
.chatbot-button.has-notification::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 12px;
    height: 12px;
    background-color: #ff4444;
    border-radius: 50%;
    border: 2px solid white;
    animation: pulse 2s infinite;
}

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

/* Typing Indicator Styles */
.typing-indicator .message-content {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.75rem 1rem;
}

.typing-animation {
    display: flex;
    gap: 4px;
    align-items: center;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
    animation: typingAnimation 1.4s infinite ease-in-out;
}

body.light-mode .typing-dot {
    background: var(--accent-blue);
}

.typing-dot:nth-child(1) {
    animation-delay: 0s;
}

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

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

.typing-text {
    color: var(--secondary-text);
    font-size: 12px;
    font-style: italic;
}

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

/* Mobile responsiveness */
@media (max-width: 480px) {
    .chatbot-container {
        bottom: 1rem;
        right: 1rem;
    }

    .chatbot-window {
        width: 300px;
        height: 400px;
    }

    .chatbot-button {
        width: 50px;
        height: 50px;
    }

    .chatbot-popup {
        max-width: 320px;
        width: 320px;
        right: -5px;
    }

    .popup-actions {
        flex-direction: column;
    }
}
