/* ============================================================
   KRULUXE AI ASSISTANT
   PREMIUM CHAT UI V3
   ============================================================ */


/* ============================================================
   1. ROOT VARIABLES
   ============================================================ */

:root {
    --kai-navy: #161d2b;
    --kai-navy-soft: #20293a;
    --kai-gold: #b89245;
    --kai-gold-dark: #98732f;
    --kai-gold-light: #d7bd7d;

    --kai-bg: #ffffff;
    --kai-soft-bg: #f8f6f1;
    --kai-soft-bg-2: #fbfaf7;

    --kai-text: #20232a;
    --kai-muted: #6f7279;

    --kai-border: #e5dfd3;
    --kai-border-dark: #d4c8b2;

    --kai-shadow:
        0 22px 60px rgba(20, 26, 38, 0.20);

    --kai-radius-large: 22px;
    --kai-radius-medium: 15px;
    --kai-radius-small: 10px;
}


/* ============================================================
   2. CHAT ROOT
   ============================================================ */

[data-kai-chat] {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 999999;

    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Arial,
        sans-serif;

    line-height: 1.45;
    box-sizing: border-box;
}

[data-kai-chat] *,
[data-kai-chat] *::before,
[data-kai-chat] *::after {
    box-sizing: border-box;
}


/* ============================================================
   3. FLOATING LAUNCHER
   ============================================================ */

#kai-chat-launcher {
    min-height: 52px;
    padding: 8px 18px 8px 9px;

    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

    border: 1px solid rgba(184, 146, 69, 0.55);
    border-radius: 999px;

    background: var(--kai-navy);
    color: #ffffff;

    box-shadow:
        0 12px 30px rgba(18, 24, 35, 0.22);

    cursor: pointer;

    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;

    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease,
        border-color 0.2s ease;
}

#kai-chat-launcher:hover {
    transform: translateY(-2px);

    box-shadow:
        0 16px 34px rgba(18, 24, 35, 0.28);

    border-color: var(--kai-gold);
}

#kai-chat-launcher:focus-visible {
    outline: 3px solid rgba(184, 146, 69, 0.28);
    outline-offset: 3px;
}


/* ============================================================
   4. PANEL
   ============================================================ */

#kai-chat-panel {
    position: absolute;

    right: 0;
    bottom: 68px;

    width: 420px;
    height: min(690px, calc(100vh - 110px));

    display: flex;
    flex-direction: column;

    overflow: hidden;

    border: 1px solid rgba(184, 146, 69, 0.32);
    border-radius: var(--kai-radius-large);

    background: var(--kai-bg);

    box-shadow: var(--kai-shadow);
}

#kai-chat-panel[hidden] {
    display: none !important;
}


/* ============================================================
   5. HEADER
   ============================================================ */

.kai-chat-header {
    flex: 0 0 auto;

    min-height: 78px;
    padding: 15px 16px;

    display: flex;
    align-items: center;
    gap: 12px;

    background:
        linear-gradient(
            135deg,
            #151c29 0%,
            #20293a 100%
        );

    border-bottom:
        1px solid rgba(184, 146, 69, 0.28);

    color: #ffffff;
}

.kai-chat-brand,
.kai-chat-header-brand {
    min-width: 0;

    display: flex;
    align-items: center;
    gap: 11px;

    flex: 1;
}

.kai-chat-brand-icon,
.kai-chat-logo,
.kai-chat-header-logo {
    width: 43px;
    height: 43px;

    flex: 0 0 43px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;

    background:
        linear-gradient(
            145deg,
            #d5ad56,
            #a87c28
        );

    color: #ffffff;

    font-family: Georgia, serif;
    font-size: 20px;
    font-weight: 700;

    box-shadow:
        inset 0 0 0 1px rgba(255,255,255,0.22);
}

.kai-chat-brand-copy,
.kai-chat-header-copy {
    min-width: 0;
}

.kai-chat-title,
.kai-chat-brand-title {
    margin: 0;

    color: #ffffff;

    font-family: Georgia, "Times New Roman", serif;
    font-size: 19px;
    line-height: 1.1;
    font-weight: 700;

    white-space: nowrap;
}

.kai-chat-subtitle,
.kai-chat-brand-subtitle {
    margin-top: 4px;

    color: rgba(255,255,255,0.74);

    font-size: 11px;
    line-height: 1.25;

    white-space: nowrap;
}


/* ============================================================
   6. HEADER BUTTONS
   ============================================================ */

.kai-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 7px;

    flex: 0 0 auto;
}

#kai-chat-new {
    min-height: 35px;

    padding: 7px 12px;

    border:
        1px solid rgba(184, 146, 69, 0.62);

    border-radius: 999px;

    background:
        rgba(255,255,255,0.04);

    color: #ffffff;

    font-size: 11px;
    font-weight: 600;

    cursor: pointer;

    transition:
        background 0.2s ease,
        border-color 0.2s ease;
}

#kai-chat-new:hover {
    background:
        rgba(184, 146, 69, 0.16);

    border-color:
        var(--kai-gold);
}

#kai-chat-close {
    width: 34px;
    height: 34px;

    padding: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    border: 0;
    border-radius: 50%;

    background: transparent;
    color: rgba(255,255,255,0.85);

    cursor: pointer;

    font-size: 19px;

    transition:
        background 0.2s ease,
        color 0.2s ease;
}

#kai-chat-close:hover {
    background:
        rgba(255,255,255,0.08);

    color: #ffffff;
}


/* ============================================================
   7. MESSAGE AREA
   ============================================================ */

#kai-chat-messages {
    flex: 1 1 auto;

    min-height: 0;

    padding: 18px 17px 14px;

    overflow-y: auto;
    overflow-x: hidden;

    background:
        linear-gradient(
            180deg,
            #ffffff 0%,
            #fbfaf7 100%
        );

    scrollbar-width: thin;
    scrollbar-color:
        #cfc7b8 transparent;
}

#kai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

#kai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

#kai-chat-messages::-webkit-scrollbar-thumb {
    background: #d4ccbd;
    border-radius: 10px;
}


/* ============================================================
   8. MESSAGE ROW
   ============================================================ */

.kai-message {
    width: 100%;

    display: flex;
    align-items: flex-start;
    gap: 8px;

    margin-bottom: 13px;
}

.kai-message-user {
    justify-content: flex-end;
}

.kai-message-assistant {
    justify-content: flex-start;
}


/* ============================================================
   9. AVATAR
   ============================================================ */

.kai-message-avatar {
    width: 31px;
    height: 31px;

    flex: 0 0 31px;

    display: flex;
    align-items: center;
    justify-content: center;

    margin-top: 2px;

    border-radius: 50%;

    background: var(--kai-navy);
    color: #ffffff;

    font-family: Georgia, serif;
    font-size: 13px;
    font-weight: 700;

    box-shadow:
        0 4px 12px rgba(18, 24, 35, 0.15);
}


/* ============================================================
   10. MESSAGE BUBBLES
   ============================================================ */

.kai-message-content {
    max-width: 82%;

    padding: 11px 13px;

    border-radius:
        5px
        15px
        15px
        15px;

    border:
        1px solid #ebe6dc;

    background: #ffffff;
    color: var(--kai-text);

    font-size: 13px;
    line-height: 1.55;

    white-space: pre-wrap;
    overflow-wrap: anywhere;

    box-shadow:
        0 5px 16px rgba(30, 34, 42, 0.055);
}

.kai-message-user .kai-message-content {
    max-width: 78%;

    border:
        1px solid var(--kai-navy);

    border-radius:
        15px
        5px
        15px
        15px;

    background:
        var(--kai-navy);

    color: #ffffff;

    box-shadow:
        0 6px 18px rgba(20, 27, 40, 0.14);
}


/* ============================================================
   11. INITIAL SUGGESTIONS
   ============================================================ */

#kai-chat-suggestions {
    width: 100%;

    display: flex;
    flex-wrap: wrap;

    gap: 7px;

    margin:
        3px 0
        15px
        39px;

    padding: 0;

    max-width:
        calc(100% - 39px);
}

#kai-chat-suggestions[hidden] {
    display: none !important;
}

#kai-chat-suggestions button,
[data-kai-suggestion] {
    min-height: 34px;

    padding: 7px 12px;

    border:
        1px solid var(--kai-border-dark);

    border-radius: 999px;

    background: #ffffff;

    color: var(--kai-navy);

    font-size: 11.5px;
    font-weight: 500;

    cursor: pointer;

    transition:
        background 0.18s ease,
        color 0.18s ease,
        border-color 0.18s ease,
        transform 0.18s ease;
}

#kai-chat-suggestions button:hover,
[data-kai-suggestion]:hover {
    transform: translateY(-1px);

    background:
        var(--kai-soft-bg);

    color:
        var(--kai-gold-dark);

    border-color:
        var(--kai-gold);
}


/* ============================================================
   12. SMART NEXT ACTION SECTION
   ============================================================ */

.kai-smart-next-actions {
    width: 100%;

    margin:
        4px 0
        18px
        39px;

    padding: 0;

    max-width:
        calc(100% - 39px);
}

.kai-smart-next-title {
    margin-bottom: 9px;

    color: var(--kai-navy);

    font-size: 12px;
    line-height: 1.35;
    font-weight: 650;

    letter-spacing: 0.005em;
}


/* ============================================================
   13. SMART BUTTON GRID
   ============================================================ */

.kai-smart-next-buttons {
    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 7px;

    width: 100%;
}


/* ============================================================
   14. SMART BUTTON
   ============================================================ */

.kai-smart-next-button {
    width: 100%;

    min-height: 40px;

    padding: 9px 10px;

    display: flex;
    align-items: center;
    justify-content: center;

    text-align: center;

    border:
        1px solid var(--kai-border-dark);

    border-radius:
        var(--kai-radius-small);

    background:
        #ffffff;

    color:
        var(--kai-navy);

    font-family: inherit;

    font-size: 11.5px;
    line-height: 1.25;
    font-weight: 600;

    cursor: pointer;

    box-shadow:
        0 2px 7px rgba(40, 37, 30, 0.035);

    transition:
        transform 0.16s ease,
        box-shadow 0.16s ease,
        background 0.16s ease,
        color 0.16s ease,
        border-color 0.16s ease;
}

.kai-smart-next-button:hover {
    transform:
        translateY(-1px);

    background:
        var(--kai-navy);

    color:
        #ffffff;

    border-color:
        var(--kai-navy);

    box-shadow:
        0 6px 14px rgba(20, 27, 40, 0.11);
}

.kai-smart-next-button:focus-visible {
    outline:
        3px solid rgba(184, 146, 69, 0.20);

    outline-offset:
        2px;
}


/* ============================================================
   15. OPTIONAL GOLD EMPHASIS
   ============================================================ */

.kai-smart-next-button:nth-child(1) {
    border-color:
        rgba(184, 146, 69, 0.70);
}

.kai-smart-next-button:nth-child(1):hover {
    background:
        var(--kai-gold);

    border-color:
        var(--kai-gold);

    color:
        #ffffff;
}


/* ============================================================
   16. THINKING
   ============================================================ */

#kai-chat-thinking {
    flex: 0 0 auto;

    padding:
        7px
        18px;

    background:
        var(--kai-soft-bg-2);

    border-top:
        1px solid #eee9df;

    color:
        var(--kai-muted);

    font-size:
        11px;
    font-style:
        italic;
}

#kai-chat-thinking[hidden] {
    display:
        none !important;
}


/* ============================================================
   17. FORM AREA
   ============================================================ */

#kai-chat-form {
    flex: 0 0 auto;

    padding:
        11px
        13px
        10px;

    display: flex;
    align-items: flex-end;
    gap: 8px;

    border-top:
        1px solid #e9e4da;

    background:
        #ffffff;
}


/* ============================================================
   18. TEXTAREA
   ============================================================ */

#kai-chat-input {
    flex: 1 1 auto;

    min-width: 0;

    min-height: 44px;
    max-height: 120px;

    padding:
        11px
        12px;

    resize: none;

    border:
        1px solid #dad4c8;

    border-radius:
        13px;

    background:
        #fbfaf8;

    color:
        var(--kai-text);

    font-family:
        inherit;

    font-size:
        12px;

    line-height:
        1.4;

    outline:
        none;

    transition:
        border-color 0.18s ease,
        box-shadow 0.18s ease,
        background 0.18s ease;
}

#kai-chat-input::placeholder {
    color:
        #9b9891;
}

#kai-chat-input:focus {
    background:
        #ffffff;

    border-color:
        var(--kai-gold);

    box-shadow:
        0 0 0 3px rgba(184, 146, 69, 0.10);
}


/* ============================================================
   19. SEND BUTTON
   ============================================================ */

#kai-chat-send {
    width: 52px;
    height: 44px;

    flex:
        0 0
        52px;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 0;

    border: 0;
    border-radius: 13px;

    background:
        linear-gradient(
            135deg,
            #c39a47,
            #ad8232
        );

    color:
        #ffffff;

    cursor:
        pointer;

    font-size:
        20px;

    box-shadow:
        0 5px 14px rgba(174, 131, 48, 0.24);

    transition:
        transform 0.17s ease,
        box-shadow 0.17s ease;
}

#kai-chat-send:hover {
    transform:
        translateY(-1px);

    box-shadow:
        0 8px 18px rgba(174, 131, 48, 0.30);
}

#kai-chat-send:disabled,
#kai-chat-input:disabled,
#kai-chat-new:disabled {
    opacity:
        0.58;

    cursor:
        not-allowed;
}


/* ============================================================
   20. DISCLAIMER
   ============================================================ */

.kai-chat-disclaimer,
.kai-chat-footer-note,
.kai-ai-disclaimer {
    flex: 0 0 auto;

    padding:
        0
        15px
        11px;

    background:
        #ffffff;

    color:
        #89867f;

    text-align:
        center;

    font-size:
        9.5px;

    line-height:
        1.35;
}


/* ============================================================
   21. TABLET
   ============================================================ */

@media (max-width: 768px) {

    [data-kai-chat] {
        right:
            14px;

        bottom:
            16px;
    }

    #kai-chat-panel {
        width:
            min(410px, calc(100vw - 28px));

        height:
            min(680px, calc(100vh - 95px));

        bottom:
            66px;
    }
}


/* ============================================================
   22. MOBILE
   ============================================================ */

@media (max-width: 520px) {

    [data-kai-chat] {
        right:
            10px;

        left:
            10px;

        bottom:
            10px;
    }


    #kai-chat-launcher {
        margin-left:
            auto;

        width:
            auto;
    }


    #kai-chat-panel {
        position:
            fixed;

        left:
            10px;

        right:
            10px;

        bottom:
            72px;

        width:
            auto;

        height:
            min(720px, calc(100dvh - 90px));

        max-height:
            calc(100dvh - 90px);

        border-radius:
            18px;
    }


    .kai-chat-header {
        min-height:
            71px;

        padding:
            12px;
    }


    .kai-chat-brand-icon,
    .kai-chat-logo,
    .kai-chat-header-logo {
        width:
            38px;

        height:
            38px;

        flex-basis:
            38px;

        font-size:
            17px;
    }


    .kai-chat-title,
    .kai-chat-brand-title {
        font-size:
            17px;
    }


    .kai-chat-subtitle,
    .kai-chat-brand-subtitle {
        font-size:
            9.5px;
    }


    #kai-chat-new {
        padding:
            6px
            9px;

        font-size:
            10px;
    }


    #kai-chat-close {
        width:
            29px;

        height:
            29px;

        font-size:
            17px;
    }


    #kai-chat-messages {
        padding:
            15px
            12px
            12px;
    }


    .kai-message-content {
        max-width:
            86%;

        font-size:
            12.5px;
    }


    .kai-message-user .kai-message-content {
        max-width:
            82%;
    }


    #kai-chat-suggestions,
    .kai-smart-next-actions {
        margin-left:
            38px;

        max-width:
            calc(100% - 38px);
    }


    .kai-smart-next-buttons {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));

        gap:
            6px;
    }


    .kai-smart-next-button {
        min-height:
            38px;

        padding:
            8px
            7px;

        font-size:
            10.5px;
    }


    #kai-chat-form {
        padding:
            9px
            10px;
    }


    #kai-chat-input {
        font-size:
            12px;
    }


    #kai-chat-send {
        width:
            48px;

        flex-basis:
            48px;
    }
}


/* ============================================================
   23. SMALL MOBILE
   ============================================================ */

@media (max-width: 380px) {

    .kai-smart-next-buttons {
        grid-template-columns:
            1fr;
    }

    .kai-smart-next-button {
        justify-content:
            flex-start;

        text-align:
            left;

        padding-left:
            12px;
    }
}


/* ============================================================
   24. ACCESSIBILITY
   ============================================================ */

@media (prefers-reduced-motion: reduce) {

    [data-kai-chat] *,
    [data-kai-chat] *::before,
    [data-kai-chat] *::after {
        transition:
            none !important;

        scroll-behavior:
            auto !important;
    }
}