/* Manegix Premium Chat Widget */
:root {
    --chat-primary: #667eea;
    --chat-primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --chat-bg: #fdfdfd;
    --chat-header-text: #ffffff;
    --chat-agent-bg: #ffffff;
    --chat-agent-text: #2d3748;
    --chat-visitor-bg: #667eea;
    --chat-visitor-text: #ffffff;
    --chat-input-bg: #f7fafc;
    --chat-shadow: 0 5px 25px rgba(0,0,0,0.15);
}

/* Widget Container */
#chat-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    gap: 15px;
}

/* Chat Toggle Button */
#chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--chat-primary-gradient);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(118, 75, 162, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-size: 24px;
}

#chat-toggle:hover {
    transform: scale(1.1);
}

/* Chat Panel */
#chat-panel {
    width: 380px;
    height: 600px;
    max-height: 80vh;
    background: var(--chat-bg);
    border-radius: 16px;
    box-shadow: var(--chat-shadow);
    display: none; /* Toggled by JS via .open class on parent */
    flex-direction: column;
    overflow: hidden;
    animation: chat-slide-up 0.4s ease-out;
}

#chat-widget.open #chat-panel {
    display: flex;
}

#chat-widget.open #chat-toggle {
    transform: scale(0);
    opacity: 0;
    height: 0;
    width: 0;
    margin: 0;
}

@keyframes chat-slide-up {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.chat-header {
    background: var(--chat-primary-gradient);
    padding: 20px;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

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

.chat-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
    border: 2px solid rgba(255,255,255,0.3);
}

.chat-title h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

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

.chat-title span::before {
    content: '';
    display: block;
    width: 8px;
    height: 8px;
    background: #48bb78;
    border-radius: 50%;
}

.chat-close-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.8);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.chat-close-btn:hover {
    color: white;
}

/* Messages Area */
#chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #fdfdfd;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Scrollbar */
#chat-messages::-webkit-scrollbar {
    width: 6px;
}
#chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.1);
    border-radius: 3px;
}

/* Message Bubbles */
.chat-message {
    max-width: 80%;
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* Animation */
.chat-message {
    animation: message-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes message-pop {
    from { opacity: 0; transform: translateY(10px) scale(0.9); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Visitor (Me) */
.chat-message.visitor {
    align-self: flex-end;
    background: var(--chat-primary-gradient);
    color: white;
    border-radius: 18px 18px 2px 18px;
}

/* Agent (Them) */
.chat-message.agent {
    align-self: flex-start;
    background: var(--chat-agent-bg);
    color: var(--chat-agent-text);
    border-radius: 18px 18px 18px 2px;
    border: 1px solid #edf2f7;
}

/* Footer / Input */
.chat-footer {
    padding: 15px;
    background: white;
    border-top: 1px solid #edf2f7;
    display: flex;
    gap: 10px;
    align-items: center;
}

#chat-input {
    flex: 1;
    border: 1px solid #edf2f7;
    background: var(--chat-input-bg);
    padding: 12px 16px;
    border-radius: 24px;
    font-size: 14px;
    transition: all 0.2s;
    outline: none;
}

#chat-input:focus {
    border-color: #a3bffa;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#chat-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--chat-primary-gradient);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    box-shadow: 0 2px 5px rgba(118, 75, 162, 0.3);
}

#chat-send:hover {
    transform: scale(1.05);
}

#chat-send i {
    font-size: 16px;
    margin-left: -2px; /* optical adjustment for plane icon */
}
