/*
 * Filename: chat.css
 * Description: Contains all styling for the multi-agent chat widget.
 */

/* --- Root CSS Variables --- */
:root {
    --header-bg: #008069; --chat-bg: #EFEAE2; --footer-bg: #F0F2F5;
    --outgoing-msg-bg: #D9FDD3; --incoming-msg-bg: #FFFFFF; --primary-green: #00A884;
    --primary-text: #111B21; --secondary-text: #667781; --bubble-bg: #FFFFFF;
    --widget-border-radius: 16px; --font-family: 'Segoe UI', Helvetica, Arial, sans-serif;
    --suggested-question-bg: #e9ecef; --suggested-question-text: #3b5a70;
}

/* --- Launcher Styles --- */
.chat-launcher { position: fixed; bottom: 20px; right: 20px; z-index: 999; }
.chat-open-btn {
    background-color: #25D366; color: white; border: none; border-radius: 50%;
    width: 60px; height: 60px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    cursor: pointer; display: flex; justify-content: center; align-items: center;
    transition: transform 0.2s ease-in-out;
}
.chat-open-btn:hover { transform: scale(1.1); }
.notification-dot {
    position: absolute; top: -2px; right: -2px; width: 20px; height: 20px;
    background-color: #ff4500; border-radius: 50%; border: 2px solid white;
    opacity: 0; visibility: hidden; transform: scale(0.5); transition: all 0.2s ease-out;
}
.notification-dot.show { opacity: 1; visibility: visible; transform: scale(1); }

/* --- Main Chat Widget Container --- */
.chat-widget {
    position: fixed; bottom: 50px; right: 20px; width: 380px; height: 90vh;
    max-height: 650px; background-color: var(--bubble-bg); border-radius: var(--widget-border-radius);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2), 0 2px 4px rgba(0, 0, 0, 0.1);
    display: none; flex-direction: column; overflow: hidden; z-index: 1000;
    opacity: 0; transform: translateY(20px); transition: opacity 0.3s ease, transform 0.3s ease;
}
.chat-widget.show { display: flex; opacity: 1; transform: translateY(0); }
.chat-widget::after {
    content: ''; position: absolute; bottom: -10px; right: 20px;
    width: 20px; height: 20px; background-color: var(--bubble-bg);
    transform: rotate(45deg); box-shadow: 2px 2px 4px rgba(0,0,0,0.05);
}

/* --- Header & Tabs --- */
.chat-header {
    background-color: var(--header-bg); color: white; padding: 16px; display: flex;
    align-items: center; flex-shrink: 0; position: relative;
}
.avatar { width: 50px; height: 50px; border-radius: 50%; border: 2px solid white; margin-right: 12px; }
.agent-info { flex-grow: 1; }
.agent-info .agent-name { font-size: 1.1em; font-weight: bold; }
.agent-info .agent-status { font-size: 0.85em; opacity: 0.9; }
.header-buttons { display: flex; align-items: center; gap: 12px; }
.header-btn {
    background: none; border: none; color: white; cursor: pointer;
    opacity: 0.8; transition: opacity 0.2s; padding: 4px;
}
.header-btn:hover { opacity: 1; }
.agent-tabs {
    display: flex; background-color: #F0F2F5; padding: 4px;
    flex-shrink: 0; border-bottom: 1px solid #e0e0e0;
}
.agent-tab {
    flex: 1; text-align: center; padding: 10px; cursor: pointer;
    color: var(--secondary-text); font-weight: 500;
    border-bottom: 3px solid transparent; transition: all 0.2s ease;
}
.agent-tab.active { color: var(--header-bg); border-bottom-color: var(--header-bg); }

/* --- Main Content Area --- */
#main-container {
    flex-grow: 1; display: flex; flex-direction: column; min-height: 0;
    background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
}
#phone-number-container {
    display: flex; flex-direction: column; justify-content: center;
    align-items: center; padding: 20px; height: 100%;
    background-color: rgba(255, 255, 255, 0.8); backdrop-filter: blur(2px);
}
#phone-input {
    width: 80%; padding: 12px; border: 1px solid #ccc;
    border-radius: 25px; margin-bottom: 20px; text-align: center; font-size: 16px;
}
#start-chat-btn {
    padding: 12px 25px; border: none; background-color: var(--primary-green);
    color: white; border-radius: 25px; cursor: pointer; font-size: 16px;
    font-weight: bold; display: flex; align-items: center; gap: 8px;
    transition: background-color 0.2s ease;
}
#phone-error { color: red; font-size: 12px; margin-top: 5px; display: none; }

/* --- Chat Body & Messages --- */
#chat-content-container { flex-grow: 1; display: none; flex-direction: column; height: 100%; min-height: 0; }
.chat-body {
    flex-grow: 1; padding: 10px 16px 20px; overflow-y: auto;
    display: flex; flex-direction: column; scroll-behavior: smooth;
}
.message-wrapper { display: flex; flex-direction: column; margin-bottom: 8px; width: 100%; }
.message-wrapper.user { align-items: flex-end; }
.message-wrapper.bot { align-items: flex-start; }
.message {
    max-width: 80%; padding: 8px 12px; border-radius: 12px; word-wrap: break-word;
    box-shadow: 0 1px 1px rgba(0,0,0,0.08); position: relative;
}
.message.bot.interactive { cursor: pointer; }
.message p { margin: 0; }
.message.user { background-color: var(--outgoing-msg-bg); }
.message.bot { background-color: var(--incoming-msg-bg); }
.message.typing { font-style: italic; color: var(--secondary-text); }
.timestamp { font-size: 11px; color: var(--secondary-text); text-align: right; margin-top: 4px; display: block; }

/* --- Reactions & Footer --- */
.reaction-popup {
    position: absolute; background-color: #fff; border-radius: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    padding: 4px 8px; display: flex; gap: 8px; z-index: 1010;
}
.reaction-btn { cursor: pointer; font-size: 20px; padding: 4px; transition: transform 0.1s ease; }
.reaction-btn:hover { transform: scale(1.2); }
.message-reaction {
    position: absolute; bottom: -10px; right: 5px; background-color: #fff;
    border-radius: 50%; padding: 2px; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    font-size: 14px; line-height: 1; z-index: 2;
}
.chat-footer { 
    padding: 8px 16px; background-color: var(--footer-bg); 
    display: flex; flex-direction: column; flex-shrink: 0; 
}
#suggested-questions-container {
    display: flex; overflow-x: auto; padding-bottom: 8px; gap: 8px;
    -ms-overflow-style: none; scrollbar-width: none;
}
#suggested-questions-container::-webkit-scrollbar { display: none; }
.suggested-question {
    background-color: transparent; border: 1px solid var(--secondary-text);
    color: var(--secondary-text); border-radius: 16px; padding: 6px 12px;
    font-size: 13px; cursor: pointer; transition: background-color 0.2s ease, color 0.2s ease;
    white-space: nowrap; flex-shrink: 0;
}
.suggested-question:hover { background-color: var(--suggested-question-bg); color: var(--suggested-question-text); }
#message-form { display: flex; align-items: center; width: 100%; }
#message-input { flex-grow: 1; border: none; padding: 12px 18px; border-radius: 25px; font-size: 15px; background-color: var(--incoming-msg-bg); }
.send-btn {
    background-color: var(--primary-green); color: white; border: none; border-radius: 50%;
    width: 48px; height: 48px; margin-left: 10px; cursor: pointer;
    display: flex; justify-content: center; align-items: center;
}

/* --- Responsive Design --- */
@media (max-width: 480px) {
    .chat-widget { width: 100vw; height: 100vh; max-height: 100%; border-radius: 0; bottom: 0; right: 0; }
    .chat-widget::after { display: none; }
}