/* MMG Talent AI Chat Widget - Styles */
/* Version 1.0 */

:root {
    --mmg-primary: #E85D24;
    --mmg-primary-dark: #C74D1E;
    --mmg-primary-light: #FAECE7;
    --mmg-dark: #1a1a1a;
    --mmg-gray-900: #2d2d2d;
    --mmg-gray-700: #555555;
    --mmg-gray-500: #888888;
    --mmg-gray-300: #cccccc;
    --mmg-gray-100: #f4f4f5;
    --mmg-white: #ffffff;
    --mmg-shadow: 0 8px 32px rgba(0,0,0,0.12);
    --mmg-shadow-lg: 0 16px 48px rgba(0,0,0,0.16);
    --mmg-radius: 16px;
    --mmg-radius-sm: 12px;
    --mmg-radius-msg: 18px;
    --mmg-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --mmg-transition: cubic-bezier(0.32, 0.72, 0, 1);
    --mmg-chat-width: 380px;
    --mmg-chat-height: 580px;
}

/* ======================== */
/* Floating Bubble Button   */
/* ======================== */
#mmg-chat-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--mmg-primary);
    border: none;
    cursor: pointer;
    box-shadow: var(--mmg-shadow);
    z-index: 999998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s var(--mmg-transition), box-shadow 0.3s ease;
    outline: none;
}

#mmg-chat-bubble:hover {
    transform: scale(1.08);
    box-shadow: var(--mmg-shadow-lg);
}

#mmg-chat-bubble:active {
    transform: scale(0.95);
}

#mmg-chat-bubble svg {
    width: 28px;
    height: 28px;
    fill: var(--mmg-white);
    transition: opacity 0.2s ease, transform 0.3s var(--mmg-transition);
}

#mmg-chat-bubble .mmg-icon-close {
    position: absolute;
    opacity: 0;
    transform: rotate(-90deg);
}

#mmg-chat-bubble.mmg-open .mmg-icon-chat {
    opacity: 0;
    transform: rotate(90deg);
}

#mmg-chat-bubble.mmg-open .mmg-icon-close {
    opacity: 1;
    transform: rotate(0deg);
}

/* Unread badge */
#mmg-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: 600;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--mmg-white);
    font-family: var(--mmg-font);
}

/* ======================== */
/* Chat Panel               */
/* ======================== */
#mmg-chat-panel {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: var(--mmg-chat-width);
    height: var(--mmg-chat-height);
    max-height: calc(100vh - 120px);
    background: var(--mmg-white);
    border-radius: var(--mmg-radius);
    box-shadow: var(--mmg-shadow-lg);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.35s var(--mmg-transition),
                transform 0.35s var(--mmg-transition);
    font-family: var(--mmg-font);
}

#mmg-chat-panel.mmg-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ======================== */
/* Header                   */
/* ======================== */
.mmg-chat-header {
    background: var(--mmg-dark);
    color: var(--mmg-white);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.mmg-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--mmg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    flex-shrink: 0;
    color: white;
}

.mmg-chat-header-info {
    flex: 1;
    min-width: 0;
}

.mmg-chat-header-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
}

.mmg-chat-header-status {
    font-size: 12px;
    color: var(--mmg-gray-300);
    display: flex;
    align-items: center;
    gap: 5px;
}

.mmg-chat-header-status::before {
    content: '';
    width: 7px;
    height: 7px;
    background: #22c55e;
    border-radius: 50%;
    display: inline-block;
}

.mmg-chat-header-actions {
    display: flex;
    gap: 4px;
}

.mmg-header-btn {
    background: none;
    border: none;
    color: var(--mmg-gray-300);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: background 0.15s ease, color 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mmg-header-btn:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.mmg-header-btn svg {
    width: 18px;
    height: 18px;
}

/* ======================== */
/* Messages Area            */
/* ======================== */
.mmg-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--mmg-gray-100);
    scroll-behavior: smooth;
}

.mmg-chat-messages::-webkit-scrollbar {
    width: 5px;
}

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

.mmg-chat-messages::-webkit-scrollbar-thumb {
    background: var(--mmg-gray-300);
    border-radius: 3px;
}

/* Message bubbles */
.mmg-msg {
    display: flex;
    gap: 8px;
    max-width: 88%;
    animation: mmgMsgIn 0.3s var(--mmg-transition);
}

@keyframes mmgMsgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.mmg-msg-user {
    margin-left: auto;
    flex-direction: row-reverse;
}

.mmg-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--mmg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    align-self: flex-end;
}

.mmg-msg-avatar svg {
    width: 16px;
    height: 16px;
    fill: white;
}

.mmg-msg-user .mmg-msg-avatar {
    background: var(--mmg-gray-700);
}

.mmg-msg-bubble {
    padding: 10px 14px;
    border-radius: var(--mmg-radius-msg);
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.mmg-msg-assistant .mmg-msg-bubble {
    background: var(--mmg-white);
    color: var(--mmg-dark);
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.mmg-msg-user .mmg-msg-bubble {
    background: var(--mmg-primary);
    color: var(--mmg-white);
    border-bottom-right-radius: 6px;
}

.mmg-msg-time {
    font-size: 11px;
    color: var(--mmg-gray-500);
    margin-top: 4px;
    padding: 0 4px;
}

.mmg-msg-user .mmg-msg-time {
    text-align: right;
}

/* Markdown in messages */
.mmg-msg-bubble p { margin: 0 0 8px 0; }
.mmg-msg-bubble p:last-child { margin-bottom: 0; }
.mmg-msg-bubble strong { font-weight: 600; }
.mmg-msg-bubble a { color: var(--mmg-primary); text-decoration: underline; }
.mmg-msg-user .mmg-msg-bubble a { color: rgba(255,255,255,0.9); }
.mmg-msg-bubble ol, .mmg-msg-bubble ul { margin: 4px 0; padding-left: 20px; }
.mmg-msg-bubble li { margin-bottom: 2px; }

/* Typing indicator */
.mmg-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    align-items: center;
}

.mmg-typing-dot {
    width: 7px;
    height: 7px;
    background: var(--mmg-gray-500);
    border-radius: 50%;
    animation: mmgTyping 1.4s infinite;
}

.mmg-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.mmg-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes mmgTyping {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-4px); }
}

/* ======================== */
/* Quick Replies            */
/* ======================== */
.mmg-quick-replies {
    padding: 8px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    background: var(--mmg-gray-100);
    border-top: 1px solid rgba(0,0,0,0.04);
}

.mmg-quick-btn {
    padding: 6px 14px;
    border: 1px solid var(--mmg-gray-300);
    border-radius: 20px;
    background: var(--mmg-white);
    color: var(--mmg-gray-700);
    font-size: 12px;
    font-family: var(--mmg-font);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.mmg-quick-btn:hover {
    border-color: var(--mmg-primary);
    color: var(--mmg-primary);
    background: var(--mmg-primary-light);
}

/* ======================== */
/* Input Area               */
/* ======================== */
.mmg-chat-input-area {
    padding: 12px 16px;
    background: var(--mmg-white);
    border-top: 1px solid var(--mmg-gray-100);
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
}

.mmg-chat-input {
    flex: 1;
    border: 1.5px solid var(--mmg-gray-300);
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: var(--mmg-font);
    line-height: 1.4;
    resize: none;
    outline: none;
    max-height: 100px;
    min-height: 40px;
    transition: border-color 0.15s ease;
    background: var(--mmg-white);
    color: var(--mmg-dark);
}

.mmg-chat-input::placeholder {
    color: var(--mmg-gray-500);
}

.mmg-chat-input:focus {
    border-color: var(--mmg-primary);
}

.mmg-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--mmg-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
    opacity: 0.5;
}

.mmg-chat-send.mmg-active {
    opacity: 1;
}

.mmg-chat-send.mmg-active:hover {
    background: var(--mmg-primary-dark);
    transform: scale(1.05);
}

.mmg-chat-send:active {
    transform: scale(0.92);
}

.mmg-chat-send svg {
    width: 18px;
    height: 18px;
    fill: white;
    margin-left: 2px;
}

/* Powered by footer */
.mmg-chat-footer {
    text-align: center;
    padding: 6px;
    font-size: 10px;
    color: var(--mmg-gray-500);
    background: var(--mmg-white);
}

/* ======================== */
/* Welcome message          */
/* ======================== */
.mmg-welcome {
    text-align: center;
    padding: 24px 16px 8px;
}

.mmg-welcome-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--mmg-primary);
    margin: 0 auto 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mmg-welcome-icon svg {
    width: 24px;
    height: 24px;
    fill: white;
}

.mmg-welcome h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--mmg-dark);
    margin: 0 0 4px;
}

.mmg-welcome p {
    font-size: 13px;
    color: var(--mmg-gray-500);
    margin: 0;
    line-height: 1.4;
}

/* ======================== */
/* Escalation banner        */
/* ======================== */
.mmg-escalation-banner {
    padding: 10px 16px;
    background: #fef3cd;
    border-top: 1px solid #ffc107;
    text-align: center;
    font-size: 13px;
    color: #856404;
}

/* ======================== */
/* Mobile responsive        */
/* ======================== */
@media (max-width: 480px) {
    #mmg-chat-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    #mmg-chat-bubble {
        bottom: 16px;
        right: 16px;
    }

    .mmg-chat-header {
        padding: 16px;
        padding-top: max(16px, env(safe-area-inset-top));
    }

    .mmg-chat-input-area {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
}
