/* Chatbot Floating Icon */
.chatbot-toggle {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 3.5rem;
    height: 3.5rem;
    background-color: white;
    color: #1a1a1a;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s;
}

.chatbot-toggle:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

.chatbot-toggle svg {
    width: 1.6rem;
    height: 1.6rem;
}

/* Chatbot Window */
.chatbot-window {
    position: fixed;
    bottom: 7rem;
    /* Changed to match toggle spacing */
    right: 2rem;
    width: 400px;
    height: 600px;
    max-height: 80vh;
    background-color: rgba(255, 255, 255, 0.85);
    /* Proper glassmorphism background */
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.05);
    /* Soft, realistic shadow */
    display: flex;
    flex-direction: column;
    z-index: 1000;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
    color: #1f2937;
}

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

/* Header */
.chatbot-header {
    padding: 1.25rem 1.5rem;
    background-color: rgba(255, 255, 255, 0.5);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chatbot-header h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: #111827;
    letter-spacing: -0.01em;
}

.chatbot-close {
    background: rgba(0, 0, 0, 0.05);
    border: none;
    color: #4b5563;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-close:hover {
    background-color: rgba(0, 0, 0, 0.1);
    color: #111827;
}

/* Messages Area */
.chatbot-messages {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;

    /* Hide Scrollbar */
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
}

.chatbot-messages::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari, Opera */
}

.message {
    max-width: 88%;
    padding: 0.875rem 1.125rem;
    border-radius: 1.25rem;
    font-size: 0.95rem;
    line-height: 1.6;
    word-wrap: break-word;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    /* Modern Gradient Blue */
    color: white;
    border-bottom-right-radius: 0.25rem;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.message.ai {
    align-self: flex-start;
    background-color: white;
    color: #374151;
    border-bottom-left-radius: 0.25rem;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* Links in AI response */
.message.ai a {
    color: #2563eb;
    font-weight: 500;
    text-decoration: none;
    border-bottom: 1px solid rgba(37, 99, 235, 0.3);
    transition: border-color 0.2s;
}

.message.ai a:hover {
    border-color: #2563eb;
}

/* Strong text */
.message.ai strong {
    color: #111827;
    font-weight: 600;
}

/* Input Area */
.chatbot-input-area {
    padding: 1rem 1.5rem;
    background-color: rgba(255, 255, 255, 0.8);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.chatbot-form {
    display: flex;
    gap: 0.75rem;
    background-color: white;
    padding: 0.35rem 0.35rem 0.35rem 1rem;
    border-radius: 99px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    /* Subtle border */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.chatbot-form:focus-within {
    border-color: rgba(37, 99, 235, 0.3);
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.08);
}

.chatbot-input {
    flex: 1;
    background-color: transparent;
    border: none;
    color: #1f2937;
    padding: 0.5rem 0;
    outline: none;
    font-size: 0.95rem;
}

.chatbot-input::placeholder {
    color: #9ca3af;
}

.chatbot-send {
    background-color: #2563eb;
    color: white;
    border: none;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.chatbot-send:hover {
    background-color: #1d4ed8;
    transform: scale(1.05);
}

.chatbot-send:disabled {
    background-color: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
    transform: none;
}

.chatbot-send svg {
    width: 1.25rem;
    height: 1.25rem;
    margin-left: 2px;
    /* Visual centering adjustment */
}


/* Loading Indicator */
.typing-indicator {
    display: none;
    gap: 5px;
    padding: 1rem 1.25rem;
    background-color: white;
    border-radius: 1.25rem;
    border-bottom-left-radius: 0.25rem;
    align-self: flex-start;
    width: fit-content;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.typing-indicator span {
    width: 5px;
    height: 5px;
    background-color: #6b7280;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

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

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

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Mobile Responsiveness */
@media (max-width: 640px) {
    .chatbot-window {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
        width: auto;
        /* Takes available width minus margins */
        height: 80vh;
        /* Not full screen, but tall enough */
        max-height: 600px;
        border-radius: 20px;
        z-index: 2000;
        border: 1px solid rgba(0, 0, 0, 0.05);
        background-color: white;
        /* Solid white for mobile */
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    }

    .chatbot-header {
        padding: 1rem;
        background-color: white;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    }

    /* Ensure close button is large enough to tap */
    .chatbot-close {
        padding: 0.5rem;
        background-color: #f3f4f6;
        /* Light gray background for visibility */
        border-radius: 50%;
        color: #1f2937;
    }

    .chatbot-messages {
        padding-bottom: 5rem;
        /* Space for input area */
    }

    .chatbot-input-area {
        position: absolute;
        bottom: 0;
        width: 100%;
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
        background-color: white;
        border-top: 1px solid rgba(0, 0, 0, 0.05);
    }

    .chatbot-toggle {
        bottom: 1.5rem;
        right: 1.5rem;
    }
}