/* ============================================================
   Margaret Beauty – Chatbot Widget Styles
   Self-contained: all classes prefixed with .mb-chat-*
   Does NOT modify any existing styles.
   ============================================================ */

/* ── Toggle Button ──────────────────────────────────────────── */
.mb-chat-toggle {
    position: fixed;
    bottom: 90px; /* above mobile-bottom-nav */
    right: 22px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8E44AD 0%, #6c3483 100%);
    border: none;
    cursor: pointer;
    z-index: 4500;
    box-shadow: 0 6px 24px rgba(142, 68, 173, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275),
                box-shadow 0.3s ease;
    animation: mb-pulse 3s ease-in-out infinite;
}

.mb-chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 30px rgba(142, 68, 173, 0.7);
    animation: none;
}

.mb-chat-toggle .mb-icon-chat,
.mb-chat-toggle .mb-icon-close {
    position: absolute;
    font-size: 1.5rem;
    line-height: 1;
    transition: opacity 0.25s ease, transform 0.25s ease;
    user-select: none;
}

.mb-chat-toggle .mb-icon-close {
    opacity: 0;
    transform: rotate(-90deg) scale(0.6);
    font-size: 1.3rem;
    color: white;
    font-style: normal;
}

.mb-chat-toggle.is-open .mb-icon-chat {
    opacity: 0;
    transform: rotate(90deg) scale(0.6);
}

.mb-chat-toggle.is-open .mb-icon-close {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Notification dot */
.mb-chat-toggle .mb-notif-dot {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 13px;
    height: 13px;
    background: #e74c3c;
    border: 2px solid white;
    border-radius: 50%;
    animation: mb-notif-bounce 1.5s ease-in-out infinite;
    transition: opacity 0.3s;
}

.mb-chat-toggle.is-open .mb-notif-dot {
    opacity: 0;
}

@keyframes mb-pulse {
    0%, 100% { box-shadow: 0 6px 24px rgba(142, 68, 173, 0.55); }
    50% { box-shadow: 0 6px 32px rgba(142, 68, 173, 0.85); }
}

@keyframes mb-notif-bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

/* ── Chat Panel ─────────────────────────────────────────────── */
.mb-chat-panel {
    position: fixed;
    bottom: 160px;
    right: 22px;
    width: 360px;
    max-height: 560px;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(142,68,173,0.12);
    display: flex;
    flex-direction: column;
    z-index: 4400;
    opacity: 0;
    transform: translateY(20px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden;
}

.mb-chat-panel.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ── Header ─────────────────────────────────────────────────── */
.mb-chat-header {
    background: linear-gradient(135deg, #8E44AD 0%, #6c3483 100%);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    border-radius: 20px 20px 0 0;
}

.mb-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-size: 1.3rem;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,0.4);
}

.mb-chat-header-info {
    flex: 1;
    min-width: 0;
}

.mb-chat-header-info strong {
    display: block;
    color: white;
    font-family: 'Playfair Display', serif;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.mb-chat-header-info span {
    display: flex;
    align-items: center;
    gap: 5px;
    color: rgba(255,255,255,0.75);
    font-size: 0.72rem;
    margin-top: 1px;
}

.mb-online-dot {
    width: 7px;
    height: 7px;
    background: #2ecc71;
    border-radius: 50%;
    display: inline-block;
    animation: mb-blink 2s ease-in-out infinite;
}

@keyframes mb-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.mb-chat-close-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    color: white;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.mb-chat-close-btn:hover {
    background: rgba(255,255,255,0.3);
}

/* ── Messages Area ──────────────────────────────────────────── */
.mb-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.mb-chat-messages::-webkit-scrollbar {
    width: 4px;
}
.mb-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.mb-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(142,68,173,0.2);
    border-radius: 4px;
}

/* ── Message Bubbles ────────────────────────────────────────── */
.mb-msg {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    animation: mb-msg-in 0.25s ease-out;
}

@keyframes mb-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.mb-msg.mb-bot {
    flex-direction: row;
}

.mb-msg.mb-user {
    flex-direction: row-reverse;
}

.mb-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8E44AD, #6c3483);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.mb-msg-bubble {
    max-width: 78%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 0.85rem;
    line-height: 1.55;
    font-family: 'Lato', sans-serif;
    word-wrap: break-word;
}

.mb-msg.mb-bot .mb-msg-bubble {
    background: linear-gradient(135deg, #f3eaf8 0%, #eedff5 100%);
    color: #3a1a4d;
    border-bottom-left-radius: 5px;
}

.mb-msg.mb-user .mb-msg-bubble {
    background: linear-gradient(135deg, #8E44AD 0%, #6c3483 100%);
    color: white;
    border-bottom-right-radius: 5px;
}

/* Service card inside bubble */
.mb-service-card {
    background: white;
    border-left: 3px solid #8E44AD;
    border-radius: 8px;
    padding: 10px 12px;
    margin: 6px 0;
    font-size: 0.82rem;
    box-shadow: 0 2px 8px rgba(142,68,173,0.1);
}

.mb-service-card strong {
    display: block;
    color: #6c3483;
    font-size: 0.88rem;
    margin-bottom: 4px;
    font-family: 'Playfair Display', serif;
}

.mb-service-card a {
    color: #8E44AD;
    text-decoration: underline;
    font-weight: bold;
    display: inline-block;
    margin-top: 4px;
}

.mb-service-card a:hover {
    color: #6c3483;
}

/* Typing indicator */
.mb-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #f3eaf8, #eedff5);
    border-radius: 18px;
    border-bottom-left-radius: 5px;
    width: fit-content;
}

.mb-typing span {
    width: 7px;
    height: 7px;
    background: #8E44AD;
    border-radius: 50%;
    display: inline-block;
    animation: mb-typing-dot 1.2s ease-in-out infinite;
}
.mb-typing span:nth-child(2) { animation-delay: 0.2s; }
.mb-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes mb-typing-dot {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1.2); opacity: 1; }
}

/* ── Quick-Reply Chips ──────────────────────────────────────── */
.mb-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 14px;
    border-top: 1px solid rgba(142,68,173,0.08);
    flex-shrink: 0;
}

.mb-chip {
    background: white;
    border: 1.5px solid rgba(142,68,173,0.35);
    color: #6c3483;
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 0.76rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Lato', sans-serif;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
}

.mb-chip:hover {
    background: #8E44AD;
    color: white;
    border-color: #8E44AD;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(142,68,173,0.3);
}

/* ── Input Area ─────────────────────────────────────────────── */
.mb-chat-input-area {
    padding: 10px 14px 12px;
    border-top: 1px solid rgba(142,68,173,0.08);
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
    background: white;
    border-radius: 0 0 20px 20px;
}

.mb-chat-input {
    flex: 1;
    border: 1.5px solid rgba(142,68,173,0.2);
    border-radius: 22px;
    padding: 9px 15px;
    font-size: 0.85rem;
    font-family: 'Lato', sans-serif;
    outline: none;
    transition: border-color 0.2s;
    color: #333;
    background: #fafafa;
    resize: none;
    line-height: 1.4;
}

.mb-chat-input:focus {
    border-color: #8E44AD;
    background: white;
    box-shadow: 0 0 0 3px rgba(142,68,173,0.08);
}

.mb-chat-input::placeholder {
    color: #bbb;
}

.mb-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8E44AD, #6c3483);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 3px 12px rgba(142,68,173,0.4);
}

.mb-send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 16px rgba(142,68,173,0.55);
}

.mb-send-btn svg {
    width: 16px;
    height: 16px;
    fill: white;
}

/* ── Mobile Responsive ──────────────────────────────────────── */
@media screen and (max-width: 480px) {
    .mb-chat-panel {
        width: calc(100vw - 20px);
        right: 10px;
        bottom: 80px;
        max-height: calc(100vh - 140px);
        border-radius: 16px;
    }

    .mb-chat-toggle {
        bottom: 80px;
        right: 14px;
        width: 52px;
        height: 52px;
    }
}
