﻿/* =====================================================
   EMA Chat Widget
   ===================================================== */

.ema-chat-widget {
    position: fixed;
    inset-inline-end: 24px;
    bottom: 24px;
    z-index: 9999;
}


/* =====================================================
   Toggle Button
   ===================================================== */

.ema-chat-toggle {
    width: 62px;
    height: 62px;
    border: 0;
    border-radius: 50%;
    display: grid;
    place-items: center;
    cursor: pointer;
    background: linear-gradient( 135deg, #f7df97 0%, #c8a04a 48%, #9f7624 100% );
    color: #08111f;
    font-size: 28px;
    box-shadow: 0 18px 45px rgba(184, 137, 45, .42);
    transition: transform .22s ease, box-shadow .22s ease;
}

    .ema-chat-toggle:hover {
        transform: translateY(-4px) scale(1.04);
        box-shadow: 0 24px 60px rgba(184, 137, 45, .55);
    }

    .ema-chat-toggle:focus-visible {
        outline: 3px solid #c8a04a;
        outline-offset: 4px;
    }


/* =====================================================
   Chat Box
   ===================================================== */

.ema-chat-box {
    position: absolute;
    inset-inline-end: 0;
    bottom: 78px;
    width: min( 360px, calc(100vw - 32px) );
    height: 460px;
    max-height: calc(100vh - 120px);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border-radius: 24px;
    background: #ffffff;
    border: 1px solid rgba(201, 163, 78, .22);
    box-shadow: 0 28px 80px rgba(15, 23, 42, .22);
}


    /* JS adds/removes this class */
    .ema-chat-box.is-open {
        display: flex;
    }


/* =====================================================
   Header
   ===================================================== */

.ema-chat-header {
    flex: 0 0 auto;
    padding: 16px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient( 135deg, #12213a, #08111f );
    color: #ffffff;
    font-weight: 900;
}

    .ema-chat-header span {
        opacity: .75;
        font-size: 13px;
        font-weight: 600;
    }


/* =====================================================
   Messages
   ===================================================== */

.ema-chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    padding: 16px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #f8fafc;
}

    .ema-chat-messages .message {
        max-width: 100%;
        margin-bottom: 12px;
        padding: 11px 13px;
        border-radius: 16px;
        font-size: 14px;
        line-height: 1.7;
        overflow-wrap: anywhere;
    }

    .ema-chat-messages .user {
        background: rgba(201, 163, 78, .16);
        color: #08111f;
    }

    .ema-chat-messages .bot {
        background: #ffffff;
        color: #12213a;
        border: 1px solid rgba(15, 23, 42, .08);
    }


/* =====================================================
   Input Area
   ===================================================== */

.ema-chat-input {
    flex: 0 0 auto;
    display: flex;
    align-items: stretch;
    gap: 8px;
    padding: 12px;
    background: #ffffff;
    border-top: 1px solid rgba(15, 23, 42, .08);
}

    .ema-chat-input input {
        flex: 1 1 auto;
        min-width: 0;
        border: 1px solid rgba(15, 23, 42, .12);
        border-radius: 999px;
        padding: 11px 14px;
        background: #ffffff;
        color: #08111f;
        outline: none;
    }

        .ema-chat-input input:focus {
            border-color: rgba(200, 160, 74, .8);
            box-shadow: 0 0 0 3px rgba(200, 160, 74, .14);
        }

    .ema-chat-input button {
        flex: 0 0 auto;
        border: 0;
        border-radius: 999px;
        padding: 0 18px;
        cursor: pointer;
        background: #c8a04a;
        color: #08111f;
        font-weight: 900;
    }

        .ema-chat-input button:hover {
            filter: brightness(1.04);
        }

        .ema-chat-input button:focus-visible {
            outline: 3px solid #c8a04a;
            outline-offset: 2px;
        }


/* =====================================================
   Dark Theme
   ===================================================== */

body.dark-theme .ema-chat-box {
    background: #111827;
    border-color: rgba(201, 163, 78, .24);
}

body.dark-theme .ema-chat-messages {
    background: #0f172a;
}

    body.dark-theme
    .ema-chat-messages
    .user {
        background: rgba(201, 163, 78, .18);
        color: #f8fafc;
    }

    body.dark-theme
    .ema-chat-messages
    .bot {
        background: #111827;
        color: #f8fafc;
        border-color: rgba(255, 255, 255, .08);
    }

body.dark-theme .ema-chat-input {
    background: #111827;
    border-top-color: rgba(255, 255, 255, .08);
}

    body.dark-theme
    .ema-chat-input input {
        background: #0f172a;
        color: #f8fafc;
        border-color: rgba(255, 255, 255, .12);
    }

        body.dark-theme
        .ema-chat-input input::placeholder {
            color: rgba(248, 250, 252, .58);
        }


/* =====================================================
   Mobile
   ===================================================== */

@media (max-width: 576px) {

    .ema-chat-widget {
        inset-inline-end: 16px;
        bottom: 16px;
    }

    .ema-chat-toggle {
        width: 56px;
        height: 56px;
        font-size: 25px;
    }

    .ema-chat-box {
        inset-inline-end: 0;
        bottom: 70px;
        width: min( 360px, calc(100vw - 32px) );
        height: min( 420px, calc(100vh - 110px) );
        border-radius: 20px;
    }
}


/* =====================================================
   Small Mobile
   ===================================================== */

@media (max-width: 380px) {

    .ema-chat-widget {
        inset-inline-end: 10px;
        bottom: 10px;
    }

    .ema-chat-box {
        bottom: 66px;
        width: calc(100vw - 20px);
        height: min( 400px, calc(100vh - 90px) );
        border-radius: 18px;
    }

    .ema-chat-messages {
        padding: 12px;
    }

    .ema-chat-input {
        padding: 10px;
    }

        .ema-chat-input button {
            padding-inline: 14px;
        }
}


/* =====================================================
   Reduced Motion
   ===================================================== */

@media (prefers-reduced-motion: reduce) {

    .ema-chat-toggle {
        transition: none;
    }

        .ema-chat-toggle:hover {
            transform: none;
        }
}
