/* Chatbot V2 Premium Styles */
:root {
    --chat-primary: #3b82f6;
    --chat-gradient: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    --chat-bg: #ffffff;
    --chat-text: #1e293b;
    --chat-light: #f8fafc;
    --chat-border: #e2e8f0;
}

/* Isolation & Reset */
.chatbot-window *,
.chatbot-toggle * {
    box-sizing: border-box;
}

/* Toggle Button with Pulse Animation */
.chatbot-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: var(--chat-gradient);
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(99, 102, 241, 0.4);
    z-index: 9999;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chatbot-toggle:hover {
    transform: scale(1.1) rotate(10deg);
    box-shadow: 0 15px 35px rgba(99, 102, 241, 0.5);
}

.chatbot-toggle::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.5);
    animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* Main Window - Glassmorphism & Logic Layout */
.chatbot-window {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transform-origin: bottom right;
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

@keyframes slideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Header */
.chat-header {
    padding: 1.25rem;
    background: var(--chat-gradient);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    /* Prevents shrinking */
}

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

.chat-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.chat-title h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.chat-title span {
    font-size: 0.75rem;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Dynamic Status Area */
.chat-status-info {
    font-size: 0.75rem;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.chat-status-info span {
    display: inline-block;
}

.chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
    padding: 5px;
}

.chat-close:hover {
    opacity: 1;
}

/* Status Indicator Pulse */
.status-dot {
    width: 8px;
    height: 8px;
    background-color: #22c55e;
    /* Green-500 */
    border-radius: 50%;
    position: relative;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    animation: pulse-green 2s infinite;
    flex-shrink: 0;
}

.status-dot.error {
    background-color: #ef4444;
    /* Red-500 */
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    animation: pulse-red 2s infinite;
}

@keyframes pulse-green {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    }
}

@keyframes pulse-red {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* Messages Area - The most critical part for "text everywhere" fix */
.chat-messages {
    flex: 1;
    /* Takes all available space */
    padding: 1.25rem;
    overflow-y: auto;
    /* Enables scrolling */
    overflow-x: hidden;
    background: var(--chat-light);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scroll-behavior: smooth;
}

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

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

/* Message Bubbles - Ultra Polish */
.message {
    max-width: 85%;
    padding: 12px 18px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.6;
    position: relative;
    word-wrap: break-word;
    animation: messagePop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.message.bot {
    background: #ffffff;
    color: var(--chat-text);
    border: 1px solid rgba(226, 232, 240, 0.8);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    background: linear-gradient(145deg, #ffffff 0%, #f1f5f9 100%);
}

.message.user {
    background: var(--chat-gradient);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
    border: none;
}

.message p {
    margin: 0 !important;
    padding: 0 !important;
    line-height: inherit;
}

.message p+p {
    margin-top: 8px !important;
}

/* Markdown Styling inside bubbles - High Specificity */
.chatbot-window .message strong,
.chatbot-window .message em,
.chatbot-window .message a {
    display: inline !important;
    margin: 0 !important;
    padding: 0 !important;
    white-space: normal !important;
}

.chatbot-window .message strong {
    font-weight: 800;
}

.message.bot strong {
    color: var(--chat-primary);
}

.message ul {
    padding-left: 20px;
    margin: 5px 0;
}

.message a {
    color: inherit;
    text-decoration: underline;
    font-weight: 600;
}

.message.bot a {
    color: var(--chat-primary);
}

/* Input Area - Floating Glass Style */
.chat-input-area {
    padding: 1rem;
    background: transparent;
    border-top: none;
    flex-shrink: 0;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    backdrop-filter: blur(1px);
    /* Slight blur behind input */
}

/* Adjust Messages padding to not be hidden by floating input */
.chat-messages {
    padding-bottom: 90px;
}

.chat-input-wrapper {
    display: flex;
    gap: 12px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 10px 14px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-input-wrapper:focus-within {
    transform: translateY(-2px);
    box-shadow: 0 15px 35px -10px rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.3);
    background: white;
}

.chat-input {
    flex: 1;
    border: none;
    background: none;
    padding: 4px;
    font-size: 1rem;
    outline: none;
    color: var(--chat-text);
    font-weight: 500;
}

.chat-send {
    background: var(--chat-gradient);
    width: 42px;
    height: 42px;
    border-radius: 14px;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-send:hover {
    transform: scale(1.1) rotate(-10deg);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.4);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border: 1px solid var(--chat-border);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    margin-bottom: 10px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

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

@keyframes typingBounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-4px);
    }
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .chatbot-window {
        width: 100%;
        height: 100%;
        max-height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }

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

    .chatbot-toggle.active {
        display: none;
    }
}

/* Quick Suggestion Chips (V2 Boost) */
.chat-suggestions {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    overflow-x: auto;
    /* Horizontal Scroll */
    white-space: nowrap;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
}

.chat-suggestions::-webkit-scrollbar {
    display: none;
}

.suggestion-chip {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 0.8rem;
    color: var(--chat-primary);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.suggestion-chip:hover {
    background: var(--chat-primary);
    color: white;
    border-color: var(--chat-primary);
    transform: translateY(-1px);
}