/* ==========================================================================
   Mallige Hospital AI Healthcare Assistant - Chatbot Widget Styles
   ========================================================================== */

:root {
    --m-primary: #177aa1;
    --m-primary-dark: #105977;
    --m-accent: #f49420;
    --m-accent-hover: #d67d12;
    --m-green: #81b13c;
    --m-bg-light: #f4f7f9;
    --m-text-dark: #222b45;
    --m-text-muted: #6b778c;
    --m-border: #e2e8f0;
    --m-shadow: 0 12px 35px rgba(23, 122, 161, 0.22);
}

/* Floating Trigger Container - Anchored to Bottom-Right Corner */
#mallige-bot-trigger-wrap {
    position: fixed;
    bottom: 22px;
    right: 12px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: flex-end; /* Align elements to the right side */
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    user-select: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

#mallige-bot-trigger-wrap.is-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px) scale(0.95);
}

/* Actor Column: Positions Doctor over the right side of the pill button */
.mallige-bot-actor-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-right: 22px;
    position: relative;
}

/* 1. Floating WhatsApp Button (Positioned on Bottom-Left Side) */
.mallige-bot-wa-btn {
    position: fixed;
    bottom: 35px;
    left: 20px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background-color: #25d366;
    color: #ffffff !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 29px;
    text-decoration: none !important;
    box-shadow: 0 4px 16px rgba(37, 211, 102, 0.5);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 99998;
    animation: waPulse 2.8s ease-in-out infinite;
}

.mallige-bot-wa-btn:hover {
    transform: scale(1.15) translateY(-2px);
    box-shadow: 0 8px 24px rgba(37, 211, 102, 0.75);
    color: #ffffff !important;
}

/* 2. Standing Doctor Avatar Character Stage */
.mallige-bot-doctor-char {
    position: relative;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    margin-bottom: -8px;
    z-index: 2;
    animation: doctorIdleFloat 3.2s ease-in-out infinite alternate;
}

.mallige-bot-doctor-char:hover {
    transform: scale(1.05) translateY(-3px);
}

.doctor-stand-stage {
    position: relative;
    width: 90px;
    height: 185px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

/* Dual pose images: Waving Hi and Namaste */
.doctor-pose-img {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    height: 185px;
    width: auto;
    max-width: 95px;
    object-fit: contain;
    filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.22));
    transition: opacity 0.45s cubic-bezier(0.4, 0, 0.2, 1), transform 0.45s ease;
    display: block;
    pointer-events: none;
}

.doctor-pose-img.pose-wave {
    opacity: 1;
    transform: translateX(-50%) rotate(0deg);
    animation: waveHandTilt 2.4s ease-in-out infinite;
    transform-origin: 50% 90%;
}

.doctor-pose-img.pose-namaste {
    opacity: 0;
    transform: translateX(-50%) scale(0.96);
}

/* When switching to Namaste */
.mallige-bot-doctor-char.is-namaste .doctor-pose-img.pose-wave {
    opacity: 0;
    transform: translateX(-50%) scale(0.96);
}

.mallige-bot-doctor-char.is-namaste .doctor-pose-img.pose-namaste {
    opacity: 1;
    transform: translateX(-50%) scale(1);
    animation: namasteBreathe 3s ease-in-out infinite alternate;
}

/* Greeting Callout Bubble positioned higher beside doctor's head so it avoids form fields */
.mallige-bot-greeting-bubble {
    position: absolute;
    right: calc(100% + 10px);
    top: -26px;
    background: #ffffff;
    color: var(--m-text-dark);
    padding: 8px 13px;
    border-radius: 14px 14px 2px 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1.35;
    display: none;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(0, 142, 155, 0.25);
    white-space: nowrap;
    cursor: pointer;
    z-index: 10;
    animation: botBubbleFadeIn 0.4s ease-out;
}

.mallige-bot-greeting-bubble::after {
    content: '';
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    border-width: 7px 0 7px 8px;
    border-style: solid;
    border-color: transparent transparent transparent #ffffff;
    display: block;
    width: 0;
}

.mallige-bot-greeting-bubble:hover {
    transform: translateY(-2px);
}

.mallige-bot-greeting-bubble .greeting-close {
    background: #e2e8f0;
    color: #4a5568;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
    margin-left: 4px;
}

.mallige-bot-greeting-bubble .greeting-close:hover {
    background: #cbd5e1;
    color: #1e293b;
}

/* 3. Teal Pill Button: "Chat/Book an appointment" matching user's reference image */
.mallige-bot-pill-btn {
    background: #008e9b;
    color: #ffffff !important;
    border: none;
    padding: 10px 22px;
    border-radius: 50px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 5px 16px rgba(0, 142, 155, 0.4);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    transition: all 0.25s ease;
    outline: none;
    z-index: 3;
    letter-spacing: 0.1px;
    font-family: inherit;
}

.mallige-bot-pill-btn:hover {
    background: #007c87;
    transform: translateY(-2px);
    box-shadow: 0 7px 20px rgba(0, 142, 155, 0.55);
}

.mallige-bot-pill-btn .pill-dot {
    width: 8px;
    height: 8px;
    background: #34d399;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px #34d399;
}

.mallige-bot-avatar-btn img {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    object-fit: cover;
    object-position: top center;
}

/* Pulse Online Indicator */
.mallige-bot-online-badge {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 15px;
    height: 15px;
    background: #10b981;
    border: 2px solid #ffffff;
    border-radius: 50%;
}

.mallige-bot-online-badge::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #10b981;
    opacity: 0.6;
    animation: botPulse 2s infinite;
}

/* Chat Container Window */
#mallige-bot-window {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 550px;
    max-height: calc(100vh - 90px);
    background: #ffffff;
    border-radius: 20px;
    box-shadow: var(--m-shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 100000;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    border: 1px solid rgba(23, 122, 161, 0.15);
    transform-origin: bottom right;
    animation: botWindowOpen 0.35s cubic-bezier(0.34, 1.25, 0.64, 1) forwards;
}

#mallige-bot-window.is-open {
    display: flex;
}

/* Header */
.mallige-bot-header {
    background: linear-gradient(135deg, var(--m-primary) 0%, var(--m-primary-dark) 100%);
    color: #ffffff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

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

.mallige-bot-header-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #ffffff;
    border: 2px solid var(--m-accent);
    padding: 2px;
    position: relative;
    flex-shrink: 0;
}

.mallige-bot-header-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    object-position: top center;
}

.mallige-bot-header-title {
    font-size: 15px;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
    display: flex;
    align-items: center;
    gap: 6px;
}

.mallige-bot-header-subtitle {
    font-size: 11px;
    opacity: 0.9;
    margin: 3px 0 0;
    display: flex;
    align-items: center;
    gap: 5px;
}

.mallige-bot-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #34d399;
    border-radius: 50%;
}

.mallige-bot-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mallige-bot-header-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s, transform 0.2s;
}

.mallige-bot-header-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

/* Chat Messages Area */
.mallige-bot-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--m-bg-light);
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

/* Message Rows */
.mallige-msg {
    display: flex;
    gap: 10px;
    max-width: 88%;
    animation: botMsgFadeIn 0.3s ease;
}

.mallige-msg-bot {
    align-self: flex-start;
}

.mallige-msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.mallige-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #ffffff;
    border: 1px solid var(--m-accent);
    flex-shrink: 0;
    overflow: hidden;
}

.mallige-msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
}

.mallige-msg-bubble {
    padding: 12px 14px;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.5;
    position: relative;
    word-break: break-word;
}

.mallige-msg-bot .mallige-msg-bubble {
    background: #ffffff;
    color: #222b45 !important;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border: 1px solid #edf2f7;
}

.mallige-msg-user .mallige-msg-bubble {
    background: linear-gradient(135deg, var(--m-primary) 0%, var(--m-primary-dark) 100%);
    color: #ffffff !important;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(23, 122, 161, 0.25);
}

.mallige-msg-time {
    font-size: 10px;
    opacity: 0.65;
    margin-top: 4px;
    display: block;
    text-align: right;
}

/* Quick Action Chips / Buttons */
.mallige-bot-chips-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.mallige-chip-btn {
    background: #ffffff;
    color: var(--m-primary);
    border: 1.5px solid rgba(23, 122, 161, 0.35);
    padding: 5px 11px;
    border-radius: 18px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s ease;
    text-decoration: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.mallige-chip-btn:hover {
    background: var(--m-primary);
    color: #ffffff;
    border-color: var(--m-primary);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(23, 122, 161, 0.25);
}

.mallige-chip-btn.chip-accent {
    background: linear-gradient(135deg, var(--m-accent) 0%, #e08215 100%);
    color: #ffffff;
    border-color: var(--m-accent);
}

.mallige-chip-btn.chip-accent:hover {
    background: linear-gradient(135deg, #e08215 0%, #c46d0a 100%);
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(244, 148, 32, 0.4);
}

.mallige-chip-btn.chip-danger {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #fca5a5;
}

.mallige-chip-btn.chip-danger:hover {
    background: #dc2626;
    color: #ffffff;
    border-color: #dc2626;
}

/* Action Card inside Bot Bubble */
.mallige-bot-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px;
    margin-top: 8px;
}

.mallige-bot-card-title {
    font-weight: 700;
    font-size: 13px;
    color: var(--m-primary-dark);
    margin-bottom: 4px;
}

.mallige-bot-card-desc {
    font-size: 12px;
    color: var(--m-text-muted);
    margin-bottom: 10px;
    line-height: 1.4;
}

.mallige-bot-card-btn {
    display: block;
    background: var(--m-accent);
    color: #ffffff !important;
    text-align: center;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none !important;
    transition: background 0.2s;
}

.mallige-bot-card-btn:hover {
    background: var(--m-accent-hover);
}

/* Typing Indicator Animation */
.mallige-typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid #edf2f7;
}

.mallige-typing-dot {
    width: 6px;
    height: 6px;
    background: var(--m-text-muted);
    border-radius: 50%;
    opacity: 0.6;
    animation: botTypingDot 1.4s infinite;
}

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

/* Input Footer */
.mallige-bot-footer {
    padding: 12px 14px;
    background: #ffffff;
    border-top: 1px solid var(--m-border);
    display: flex;
    align-items: center;
    gap: 8px;
}

#mallige-bot-window input.mallige-bot-input,
.mallige-bot-input {
    flex: 1;
    border: 1.5px solid var(--m-border) !important;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 13px;
    color: #1e293b !important;
    -webkit-text-fill-color: #1e293b !important;
    caret-color: #177aa1 !important;
    outline: none;
    transition: border-color 0.2s;
    background: #f8fafc !important;
    margin-bottom: 0 !important;
}

#mallige-bot-window input.mallige-bot-input::placeholder,
.mallige-bot-input::placeholder {
    color: #64748b !important;
    -webkit-text-fill-color: #64748b !important;
    opacity: 1 !important;
}

#mallige-bot-window input.mallige-bot-input:focus,
.mallige-bot-input:focus {
    border-color: var(--m-primary) !important;
    background: #ffffff !important;
    color: #1e293b !important;
    -webkit-text-fill-color: #1e293b !important;
}

.mallige-bot-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--m-primary);
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.mallige-bot-send-btn:hover {
    background: var(--m-primary-dark);
    transform: scale(1.05);
}

.mallige-bot-send-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    transform: none;
}

/* Powered by banner */
.mallige-bot-watermark {
    text-align: center;
    font-size: 10px;
    color: #94a3b8;
    padding: 4px 0 6px;
    background: #ffffff;
}

/* Keyframes */
@keyframes botPulse {
    0% { transform: scale(0.9); opacity: 0.8; }
    50% { transform: scale(1.6); opacity: 0; }
    100% { transform: scale(0.9); opacity: 0; }
}

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

@keyframes botBubbleFloat {
    0% { transform: translateY(0); }
    100% { transform: translateY(-4px); }
}

@keyframes botWindowOpen {
    from { opacity: 0; transform: scale(0.85) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

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

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

/* Mobile Responsiveness */
@media only screen and (max-width: 576px) {
    #mallige-bot-trigger-wrap {
        bottom: 12px;
        right: 8px;
    }

    .mallige-bot-actor-col {
        margin-right: 16px;
    }

    .mallige-bot-wa-btn {
        bottom: 68px;
        left: 12px;
        width: 50px;
        height: 50px;
        font-size: 27px;
    }

    .doctor-stand-stage {
        width: 82px;
        height: 155px;
    }

    .doctor-pose-img {
        height: 155px;
        max-width: 82px;
    }

    .mallige-bot-doctor-char {
        margin-bottom: -6px;
    }

    .mallige-bot-pill-btn {
        padding: 8px 16px;
        font-size: 12px;
        border-radius: 40px;
        box-shadow: 0 4px 12px rgba(0, 142, 155, 0.4);
    }

    .mallige-bot-greeting-bubble {
        display: none !important;
    }

    #mallige-bot-window {
        bottom: 0;
        right: 0;
        width: 100vw;
        max-width: 100vw;
        height: 85vh;
        max-height: 85vh;
        border-radius: 20px 20px 0 0;
        border: none;
    }
}
