/* =========================================
   LWD MODERN CHATBOT STYLES - FIXED & CLEANED
   ========================================= */

:root {
    --chat-width: 380px;
    --chat-height: 550px;
    --chat-bg: rgba(255, 255, 255, 0.98);
    --bot-msg-bg: #f1f5f9;
    --user-msg-bg: #004e92; 
    --user-msg-text: #ffffff;
    --primary-blue: #004e92;
    --secondary-blue: #000428;
}

/* --- Floating Chat Bubble --- */
#chat-bubble {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--primary-blue), #00b4d8);
    border-radius: 50%;
    box-shadow: 0 8px 24px rgba(0, 78, 146, 0.35);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.27);
}

#chat-bubble:hover { transform: scale(1.1); }

.bubble-icon-bg { font-size: 24px; color: white; }

.pulse-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid #037b9c;
    opacity: 0;
    animation: pulse 2s infinite;
}

/* --- Chat Window --- */
#chat-window {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: var(--chat-width);
    height: var(--chat-height);
    background: var(--chat-bg);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
    display: none; /* Controlled by .active class */
    flex-direction: column;
    overflow: hidden;
    z-index: 9998;
    animation: fadeIn 0.3s ease;
}

#chat-window.active {
    display: flex;
}

/* --- Header --- */
.chat-header {
    padding: 15px 20px;
    background: linear-gradient(to right, #00b4d8, var(--secondary-blue));
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-content { display: flex; align-items: center; gap: 10px; }

.bot-avatar {
    position: relative;
    width: 35px;
    height: 35px;
    background: white;
    border-radius: 50%;
    padding: 2px;
}

.bot-avatar img { width: 100%; height: 100%; object-fit: contain; border-radius: 50%; }

.online-indicator {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background: #10b981;
    border: 2px solid white;
    border-radius: 50%;
}

.bot-info .bot-name { font-weight: 600; font-size: 0.95rem; display: block; }
.bot-info .bot-status { font-size: 0.7rem; opacity: 0.8; display: block; }

.header-actions button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.1rem;
    margin-left: 8px;
    opacity: 0.7;
}
.header-actions button:hover { opacity: 1; }

/* --- Chat Body --- */
.chat-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column; /* This ensures vertical stacking */
    gap: 12px;
    scrollbar-width: thin;
}

/* --- MESSAGE WRAPPING FIX --- */
.msg {
    max-width: 85%;            /* Prevents bubble from being too wide */
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.9rem;
    line-height: 1.5;
    position: relative;
    
    /* THE FIX FOR VERTICAL WRAPPING */
    word-wrap: break-word;      /* Legacy support */
    overflow-wrap: break-word;  /* Standard modern support */
    white-space: normal;        /* Allows text to wrap onto new lines */
    display: block;             /* Ensures it sits on its own vertical block */
}

.msg.bot {
    align-self: flex-start;
    background: var(--bot-msg-bg);
    color: #1e293b;
    border-bottom-left-radius: 4px;
}

.msg.user {
    align-self: flex-end;
    background: var(--user-msg-bg);
    color: var(--user-msg-text);
    border-bottom-right-radius: 4px;
}

/* --- Suggestions --- */
.suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 5px;
    align-self: flex-start;
}

.suggestions button {
    background: white;
    border: 1px solid var(--primary-blue);
    color: var(--primary-blue);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: 0.2s;
}

.suggestions button:hover {
    background: var(--primary-blue);
    color: white;
}

/* --- Footer --- */
.chat-footer {
    padding: 15px;
    background: white;
    border-top: 1px solid #eee;
}

.input-container {
    display: flex;
    align-items: center;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 25px;
    padding: 5px 5px 5px 15px;
}

#chat-input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    padding: 8px 0;
    font-size: 0.9rem;
}

.send-btn {
    width: 35px;
    height: 35px;
    background: var(--primary-blue);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

.typing {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-bottom: 5px;
    font-style: italic;
}

/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(1.6); opacity: 0; }
}

/* Responsive */
@media (max-width: 480px) {
    #chat-window {
        width: 70%;          /* Don't take up full width */
        height: 50vh;        /* Take up 70% of screen height */
        bottom: 90px;        /* Stay above the bubble */
        right: 5%;           /* Center it slightly */
        border-radius: 20px; /* Keep the rounded corners */
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    }
}
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.quick-actions button {
    background: #ffffff;
    color: #0056b3;
    border: 1px solid #0056b3;
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quick-actions button:hover {
    background: #0056b3;
    color: white;
}
.suggestions button {
    border: 1px solid #ddd;
    background-color: #f9f9f9;
    border-radius: 8px;
    transition: background 0.3s;
}

.suggestions button:hover {
    background-color: #e3f2fd;
    border-color: #2196f3;
}