/* ========================================================
   KAYAKALP AESTHETICS - AANYA AI CONCIERGE CHAT WIDGET
   Tailored to Deep Crimson (#8B1A2B), Warm Gold (#C5A55A), 
   and Cream (#F5F0E8) luxury clinic aesthetic.
   ======================================================== */

.kayakalp-chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

/* Floating Launch Button Container */
.kayakalp-chat-floating-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, #8B1A2B 0%, #6E1422 100%);
    color: #FFFFFF;
    border: 1.5px solid rgba(197, 165, 90, 0.45);
    border-radius: 50px;
    padding: 10px 20px 10px 12px;
    cursor: pointer;
    box-shadow: 0 10px 25px -4px rgba(139, 26, 43, 0.45), 0 0 16px rgba(197, 165, 90, 0.3);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    backdrop-filter: blur(10px);
}

.kayakalp-chat-floating-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 15px 32px -4px rgba(139, 26, 43, 0.6), 0 0 22px rgba(197, 165, 90, 0.5);
    border-color: rgba(197, 165, 90, 0.8);
}

.kayakalp-chat-btn-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #C5A55A 0%, #8B7535 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #FFFFFF;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.kayakalp-chat-online-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 10px;
    height: 10px;
    background: #10B981;
    border: 2px solid #6E1422;
    border-radius: 50%;
    animation: kayakalpPulseDot 2s infinite ease-in-out;
}

@keyframes kayakalpPulseDot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.85; }
}

.kayakalp-chat-btn-text {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.kayakalp-chat-btn-title {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: #FFFFFF;
}

.kayakalp-chat-btn-sub {
    font-size: 0.72rem;
    color: #E8D5A3;
    font-weight: 400;
}

/* Teaser Speech Bubble */
.kayakalp-chat-teaser {
    position: absolute;
    bottom: 70px;
    right: 0;
    background: #FFFFFF;
    color: #2D2D2D;
    padding: 10px 16px;
    border-radius: 16px 16px 4px 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0, 0, 0, 0.1);
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    border: 1px solid rgba(197, 165, 90, 0.3);
    animation: kayakalpSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.kayakalp-chat-teaser::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 24px;
    border-width: 6px 6px 0;
    border-style: solid;
    border-color: #FFFFFF transparent;
    display: block;
    width: 0;
}

/* ========================================================
   CHAT WINDOW (DESKTOP)
   ======================================================== */
.kayakalp-chat-window {
    width: 385px;
    height: 560px;
    max-height: calc(100vh - 100px);
    background: #FFFFFF;
    border-radius: 20px;
    box-shadow: 0 20px 45px -8px rgba(26, 26, 26, 0.28), 0 0 20px rgba(197, 165, 90, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(197, 165, 90, 0.25);
    animation: kayakalpPopIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

/* Header */
.kayakalp-chat-header {
    background: linear-gradient(135deg, #8B1A2B 0%, #6E1422 100%);
    padding: 16px 18px;
    color: #FFFFFF;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(197, 165, 90, 0.3);
    flex-shrink: 0;
}

.kayakalp-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.kayakalp-header-avatar {
    position: relative;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #C5A55A 0%, #8B7535 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
}

.kayakalp-header-avatar .kayakalp-chat-online-dot {
    border-color: #6E1422;
}

.kayakalp-header-info h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #FFFFFF;
    font-family: 'Playfair Display', Georgia, serif;
    letter-spacing: 0.3px;
}

.kayakalp-header-info p {
    margin: 2px 0 0;
    font-size: 0.73rem;
    color: #E8D5A3;
}

.kayakalp-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.kayakalp-header-btn {
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: #FFFFFF;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.kayakalp-header-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #E8D5A3;
}

/* Chat Messages Area */
.kayakalp-chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    background: #FDFCF9;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.kayakalp-chat-messages::-webkit-scrollbar {
    width: 5px;
}
.kayakalp-chat-messages::-webkit-scrollbar-thumb {
    background: #EDE5D8;
    border-radius: 4px;
}

/* Message Rows */
.kayakalp-msg-row {
    display: flex;
    gap: 10px;
    max-width: 86%;
    animation: kayakalpSlideUp 0.25s ease-out;
}

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

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

.kayakalp-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #C5A55A, #8B7535);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
    margin-top: 2px;
    color: #FFFFFF;
    box-shadow: 0 2px 6px rgba(197, 165, 90, 0.3);
}

.kayakalp-msg-bubble {
    padding: 12px 15px;
    border-radius: 18px;
    font-size: 0.9rem;
    line-height: 1.48;
    word-break: break-word;
    position: relative;
}

.kayakalp-msg-row.user .kayakalp-msg-bubble {
    background: linear-gradient(135deg, #8B1A2B 0%, #6E1422 100%);
    color: #FFFFFF;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 14px rgba(139, 26, 43, 0.25);
}

.kayakalp-msg-row.bot .kayakalp-msg-bubble {
    background: #FFFFFF;
    color: #2D2D2D;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(197, 165, 90, 0.25);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

.kayakalp-msg-bubble strong {
    color: #8B1A2B;
    font-weight: 600;
}

.kayakalp-msg-row.user .kayakalp-msg-bubble strong {
    color: #E8D5A3;
}

.kayakalp-msg-time {
    display: block;
    font-size: 0.65rem;
    margin-top: 5px;
    opacity: 0.7;
    text-align: right;
}

/* Typing Dots */
.kayakalp-typing-bubble {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
}

.kayakalp-typing-dot {
    width: 7px;
    height: 7px;
    background: #C5A55A;
    border-radius: 50%;
    animation: kayakalpBlink 1.4s infinite both;
}

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

@keyframes kayakalpBlink {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Consultation Lead Celebration Card */
.kayakalp-celebration-card {
    background: linear-gradient(135deg, #FDF9F0 0%, #F5EEDB 100%);
    border: 1.5px solid #C5A55A;
    border-radius: 14px;
    padding: 14px;
    margin: 8px 0;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    box-shadow: 0 4px 15px rgba(197, 165, 90, 0.2);
    animation: kayakalpSlideUp 0.3s ease;
}

.kayakalp-celebration-icon {
    font-size: 1.5rem;
}

.kayakalp-celebration-text h4 {
    margin: 0 0 4px;
    color: #8B1A2B;
    font-size: 0.95rem;
    font-weight: 600;
}

.kayakalp-celebration-text p {
    margin: 0;
    font-size: 0.8rem;
    color: #5A5A5A;
    line-height: 1.35;
}

/* Suggested Chips */
.kayakalp-chips-container {
    padding: 8px 14px;
    background: #FDFCF9;
    border-top: 1px solid rgba(197, 165, 90, 0.15);
    display: flex;
    gap: 6px;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    flex-shrink: 0;
}

.kayakalp-chips-container::-webkit-scrollbar {
    display: none;
}

.kayakalp-chip {
    background: #FFFFFF;
    color: #8B1A2B;
    border: 1px solid rgba(197, 165, 90, 0.4);
    padding: 6px 12px;
    border-radius: 50px;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    font-family: inherit;
}

.kayakalp-chip:hover {
    background: linear-gradient(135deg, #8B1A2B, #6E1422);
    color: #FFFFFF;
    border-color: #8B1A2B;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(139, 26, 43, 0.2);
}

/* Chat Input Footer (Desktop) */
.kayakalp-chat-footer {
    display: flex;
    padding: 10px 14px;
    background: #FFFFFF;
    border-top: 1px solid #EDE5D8;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    box-sizing: border-box;
}

.kayakalp-chat-input {
    flex: 1 1 auto;
    min-width: 0;
    border: 1px solid #EDE5D8;
    border-radius: 25px;
    padding: 10px 16px;
    font-size: 0.88rem;
    color: #2D2D2D;
    outline: none;
    transition: all 0.2s;
    font-family: inherit;
    background: #FDFCF9;
    box-sizing: border-box;
}

.kayakalp-chat-input:focus {
    border-color: #C5A55A;
    background: #FFFFFF;
    box-shadow: 0 0 0 3px rgba(197, 165, 90, 0.15);
}

/* Voice Language Switch Pill */
.kayakalp-voice-lang-btn {
    height: 38px;
    padding: 0 10px;
    border-radius: 19px;
    background: #FDF9F3;
    border: 1px solid #D4AF37;
    color: #8B1A2B;
    font-size: 0.78rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    font-family: inherit;
}

.kayakalp-voice-lang-btn:hover {
    background: #8B1A2B;
    color: #FFFFFF;
    border-color: #8B1A2B;
    box-shadow: 0 2px 6px rgba(139, 26, 43, 0.25);
}

/* Voice Microphone Button */
.kayakalp-chat-mic-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #FDF9F3;
    border: 1px solid #EDE5D8;
    color: #8B1A2B;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.kayakalp-chat-mic-btn:hover {
    background: #EDE5D8;
    color: #6E1422;
    transform: scale(1.08);
}

/* Mic Active Listening State with Pulsing Glow Animation */
.kayakalp-chat-mic-btn.kayakalp-mic-listening {
    background: linear-gradient(135deg, #DC2626, #991B1B) !important;
    color: #FFFFFF !important;
    border-color: #DC2626 !important;
    animation: kayakalp-mic-pulse 1.3s infinite ease-in-out;
}

@keyframes kayakalp-mic-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.6);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 0 9px rgba(220, 38, 38, 0);
        transform: scale(1.12);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0);
        transform: scale(1);
    }
}

.kayakalp-chat-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8B1A2B, #6E1422);
    border: none;
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.kayakalp-chat-send-btn:hover:not(:disabled) {
    transform: scale(1.08);
    background: linear-gradient(135deg, #A8243A, #8B1A2B);
    box-shadow: 0 4px 12px rgba(139, 26, 43, 0.35);
}

.kayakalp-chat-send-btn:disabled {
    background: #EDE5D8;
    color: #B0B0B0;
    cursor: not-allowed;
    transform: none;
}

/* Positioning Adjustment: WhatsApp on Left, Chatbot on Right */
.whatsapp-float {
    left: 24px !important;
    right: auto !important;
}

.whatsapp-tooltip {
    left: 70px !important;
    right: auto !important;
}

.whatsapp-tooltip::after {
    left: -6px !important;
    right: auto !important;
    border-right: 6px solid #2D2D2D !important;
    border-left: none !important;
}

/* ========================================================
   MOBILE RESPONSIVENESS (PHONES & TABLETS UP TO 768px)
   Ultra-clean full-screen experience with locked input footer
   ======================================================== */
@media (max-width: 768px) {
    .kayakalp-chat-widget {
        bottom: 16px;
        right: 16px;
    }

    /* Full-screen viewport takeover when chat is open on mobile */
    .kayakalp-chat-widget.kayakalp-chat-open {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        z-index: 9999999 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .kayakalp-chat-window {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        border: none !important;
        box-shadow: none !important;
        margin: 0 !important;
        z-index: 9999999 !important;
        flex-direction: column !important;
        animation: none !important;
    }

    /* Keep chat window strictly hidden by default on mobile until user taps launcher */
    .kayakalp-chat-window[style*="display: none"],
    .kayakalp-chat-widget:not(.kayakalp-chat-open) .kayakalp-chat-window {
        display: none !important;
    }

    .kayakalp-chat-widget.kayakalp-chat-open .kayakalp-chat-window {
        display: flex !important;
    }

    /* Prevent underlying website scroll while mobile chat is open */
    body.kayakalp-chat-active {
        overflow: hidden !important;
        touch-action: none;
    }

    /* Hide WhatsApp float button when mobile chat is open to avoid crowding */
    body.kayakalp-chat-active .whatsapp-float,
    .kayakalp-chat-widget.kayakalp-chat-open ~ .whatsapp-float {
        display: none !important;
    }

    /* Mobile Header */
    .kayakalp-chat-header {
        flex-shrink: 0 !important;
        padding: 12px 14px !important;
        padding-top: max(12px, env(safe-area-inset-top)) !important;
        border-radius: 0 !important;
    }

    .kayakalp-header-avatar {
        width: 36px !important;
        height: 36px !important;
        font-size: 1.15rem !important;
    }

    .kayakalp-header-info h3 {
        font-size: 0.92rem !important;
    }

    .kayakalp-header-info p {
        font-size: 0.68rem !important;
    }

    .kayakalp-header-btn {
        width: 32px !important;
        height: 32px !important;
    }

    /* Mobile Messages Area */
    .kayakalp-chat-messages {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        padding: 14px 12px !important;
        gap: 10px !important;
    }

    .kayakalp-msg-row {
        max-width: 90% !important;
    }

    .kayakalp-msg-bubble {
        padding: 10px 13px !important;
        font-size: 0.88rem !important;
    }

    /* Mobile Chips Bar */
    .kayakalp-chips-container {
        flex-shrink: 0 !important;
        padding: 7px 12px !important;
        gap: 6px !important;
    }

    .kayakalp-chip {
        padding: 5px 11px !important;
        font-size: 0.74rem !important;
    }

    /* Mobile Chat Input Footer - Perfectly Visible & Fixed Above Keyboard/Bar */
    .kayakalp-chat-footer {
        flex-shrink: 0 !important;
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
        padding: 10px 12px !important;
        padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
        background: #FFFFFF !important;
        border-top: 1.5px solid #EDE5D8 !important;
        box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.08) !important;
        width: 100% !important;
        box-sizing: border-box !important;
        position: relative !important;
        z-index: 10 !important;
    }

    .kayakalp-chat-input {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        height: 42px !important;
        padding: 8px 14px !important;
        font-size: 16px !important; /* 16px strictly avoids iOS Safari viewport auto-zoom! */
        line-height: 1.3 !important;
        border-radius: 21px !important;
        border: 1.5px solid #D6C7B2 !important;
        background: #FDFCF9 !important;
        color: #2D2D2D !important;
        box-sizing: border-box !important;
        outline: none !important;
    }

    .kayakalp-chat-input:focus {
        border-color: #8B1A2B !important;
        background: #FFFFFF !important;
        box-shadow: 0 0 0 2.5px rgba(139, 26, 43, 0.18) !important;
    }

    .kayakalp-voice-lang-btn {
        height: 38px !important;
        min-width: 38px !important;
        padding: 0 8px !important;
        border-radius: 19px !important;
        font-size: 0.76rem !important;
        font-weight: 700 !important;
        flex-shrink: 0 !important;
    }

    .kayakalp-chat-mic-btn {
        width: 38px !important;
        height: 38px !important;
        font-size: 0.95rem !important;
        flex-shrink: 0 !important;
    }

    .kayakalp-chat-send-btn {
        width: 38px !important;
        height: 38px !important;
        font-size: 0.95rem !important;
        flex-shrink: 0 !important;
    }

    .kayakalp-chat-btn-text {
        display: none;
    }

    .kayakalp-chat-floating-btn {
        padding: 8px;
        border-radius: 50%;
        width: 54px;
        height: 54px;
        justify-content: center;
    }

    .whatsapp-float {
        left: 16px !important;
        bottom: 16px !important;
    }
}
