/* Chatbot Container */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    height: 28px;
}

/* Chat Window */
.chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 550px;
    background: var(--color-gray-dark);
    /* Dark Theme Background */
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

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

/* Header */
.chat-header {
    background: rgba(15, 23, 42, 0.95);
    /* Corporate Blue */
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    /* For absolute positioning context if needed */
}

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

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.end-chat-btn,
.close-chat-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.end-chat-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #10b981;
    /* Green for success/send */
}

.close-chat-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ef4444;
    /* Red for close */
}

/* Custom Tooltips */
.has-tooltip {
    position: relative;
}

.has-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 110%;
    /* Place above */
    left: 50%;
    transform: translateX(-50%) translateY(5px);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    font-weight: 500;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.has-tooltip:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.chat-bot-icon {
    width: 32px;
    height: 32px;
    color: var(--color-primary);
}

.chat-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    margin-right: 8px;
}

.status-text {
    font-size: 0.75rem;
    color: #10b981;
    font-weight: 500;
    transition: color 0.3s;
}

/* Chat Messages Area */
.chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #1f2937;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 300px;
    /* Fix: Prevent Body Scroll */
    overscroll-behavior: contain;
}

/* Message Styles */
.message {
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 80%;
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 0.9rem;
}

.message.bot {
    background: #4b5563;
    color: white;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message.user {
    background: var(--color-primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Close Button */
/* Close Button Removed (now in header actions) */

.close-chat i {
    width: 16px;
    height: 16px;
}

.message p {
    margin-bottom: 0.5rem;
}

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

/* Typing Indicator */
.typing-indicator {
    background: #4b5563;
    padding: 12px 16px;
    border-radius: 12px;
    border-bottom-left-radius: 2px;
    align-self: flex-start;
    display: none;
}

.typing-indicator span {
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: #9ca3af;
    border-radius: 50%;
    margin: 0 2px;
    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);
    }

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

/* Input Area */
.chat-input-area {
    padding: 16px;
    background: rgba(15, 23, 42, 0.5);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Send Button Removed */

.chat-input-area input {
    flex: 1;
    padding: 12px 16px;
    background: white;
    /* White background for better contrast */
    border: 1px solid #d1d5db;
    border-radius: 24px;
    color: #111827;
    /* Dark text */
    outline: none;
    transition: all 0.2s;
    width: 100%;
    /* Ensure full width */
}

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

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

/* Chatbot Promo Styles */
.chatbot-promo {
    background: var(--color-gray-dark);
    color: white;
    padding: 24px;
    border-radius: 12px;
    text-align: center;
    margin-top: 2rem;
    box-shadow: 0 8px 25px rgba(51, 65, 85, 0.2);
}

.chatbot-icon {
    width: 32px;
    height: 32px;
    margin-bottom: 12px;
    color: white;
}

.chatbot-promo h3 {
    margin: 0 0 8px 0;
    font-size: 1.4rem;
    font-weight: 600;
}

.chatbot-promo p {
    margin: 0 0 16px 0;
    opacity: 0.9;
}

.chatbot-promo .btn {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .chat-window {
        width: calc(100vw - 40px);
        height: 80vh;
        bottom: 90px;
    }

    .chatbot-promo {
        padding: 20px;
        margin-top: 1.5rem;
    }
}