/* CHAT WIDGET */
#chat-widget {
    position: fixed;
    right: 12px;
    bottom: 12px;
    width: 550px;
    max-width: 95%;
    height: 700px;
    max-height: 100%;
    z-index: 9999999999;
    opacity: 0;
    border-radius: 12px;
    visibility: hidden;
    transform: translateY(10px);
    pointer-events: none;
    box-shadow: rgba(0, 0, 0, 0.3) 0px 19px 38px, rgba(0, 0, 0, 0.22) 0px 15px 12px;
    transition: opacity 200ms ease, transform 200ms ease, visibility 0s linear 200ms;
}

    /* CHAT WIDGET RESIZABLE (TOP-LEFT HANDLE) */
    #chat-widget.resizable {
        resize: none;
        overflow: hidden;
        min-width: 340px;
        min-height: 200px;
        max-width: 95vw;
        max-height: 95vh;
    }

        #chat-widget.resizable .resize-handle {
            position: absolute;
            top: 1px;
            left: 1px;
            width: 14px;
            height: 14px;
            cursor: nwse-resize;
            z-index: 10;
            opacity: 40%;
            transform: rotate( 180deg);
        }

            #chat-widget.resizable .resize-handle:hover {
                opacity: 70%;
            }

        /* DISABLE RESIZE ON MOBILE */
        @media (max-width: 768px) {
            #chat-widget.resizable {
                width: 550px !important;
                max-width: 95% !important;
                height: 700px !important;
                max-height: 100% !important;
                resize: none !important;
            }

            #chat-widget.resizable .resize-handle {
                display: none;
            }
        }

    #chat-widget.is-open {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
        pointer-events: auto;
        transition: opacity 200ms ease, transform 200ms ease, visibility 0s;
    }

.chat-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap-reverse;
    gap: 10px;
    padding: 15px;
    background: var(--primary-600);
    color: #FFF;
    overflow: hidden;
}

.chat-widget-actions button {
    background: none;
    border: none;
    color: #FFF;
    font-size: 18px;
    opacity: 80%;
    cursor: pointer;
}

    .chat-widget-actions button:hover {
        opacity: 100%;
    }

.chat-widget-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.chat-widget-messages {
    flex: 1;
    padding: 12px;
    background: #FBFBFB;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

    .chat-widget-settings .header {
        padding: 15px;
        border-bottom: 1px solid #D1D5DB;
    }

    .chat-widget-settings .body {
        flex: 1;
        padding: 15px;
        overflow-y: auto;
        background: #FBFBFB;
    }

.chat-widget-input {
    display: flex;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid #D1D5DB;
    background: #FBFBFB;
}

    .chat-widget-input .search-input {
        flex: 1;
        font-size: 16px;
        padding: 10px 20px;
        border-radius: 300px !important;
    }

        .chat-widget-input .search-input:focus {
            box-shadow: rgba(0, 0, 0, 0.16) 0px 1px 4px !important;
            border-color: #D9D9D9 !important;
        }

        .chat-widget-input .search-input::placeholder {
            font-size: inherit;
        }

    .chat-widget-input button {
        padding: 8px 14px;
        background-color: #5BB75B;
    }

    .chat-widget-input .btn-danger {
        background-color: #D4403A;
        border-color: #C22E29;
    }

        .chat-widget-input button:focus {
            outline: none !important;
            border-color: transparent !important;
        }

.chat-msg {
    max-width: 85%;
    margin-bottom: 10px;
    padding: 10px 15px;
    border-radius: 14px;
    font-size: 16px;
    line-height: 1.6;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.chat-msg-user {
    margin-left: auto;
    background: linear-gradient(to bottom, var(--secondary-400) 60%, var(--secondary-600) 140%);
    color: #444;
    border-bottom-right-radius: 4px;
    font-weight: 500;
    line-height: 1.5;
}

.chat-msg-bot {
    margin-right: auto;
    background: linear-gradient(to bottom, var(--primary-400), var(--primary-600) 140%);
    color: #FFF;
    border-bottom-left-radius: 4px;
    font-weight: 400;
    line-height: 1.5;
}

.chat-src-sup {
    /*top: -0.4em;*/
    top: 0;
    margin-left: 2px;
}

    .chat-src-sup a {
        /*text-decoration: underline;*/
        display: inline-flex;
        background: #F8F8F8;
        padding: 1px 4px;
        font-size: 12px;
        color: var(--primary-500);
        font-weight: 600;
        border-radius: 3px;
        line-height: 1.1;
        opacity: 80%;
        transition: opacity 300ms ease, transform 300ms ease;
    }

        .chat-src-sup a:hover {
            background: #FFF;
            box-shadow: rgba(0, 0, 0, 0.16) 0px 10px 36px 0px, rgba(0, 0, 0, 0.06) 0px 0px 0px 1px;
            opacity: 1;
        }

.chat-src-footnotes {
    display: flex;
    flex-wrap: wrap;
    row-gap: 5px;
    column-gap: 5px;
/*    margin-top: 15px;
    padding-top: 15px;
    padding-bottom: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.18);*/
}

    .chat-src-footnotes .btn:hover {
        color: #FFF;
    }

.chat-src-row {
    /*font-size: 12px;
    line-height: 1.3;
    margin-top: 6px;
    color: #FFF;*/
}

    .chat-src-row a {
        /*text-decoration: underline;*/
        color: white;
    }

.chat-src-num {
    font-weight: 600;
}

/* FLOATING ACTION */
.floating-actions {
    position: fixed;
    z-index: 999999;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 300ms ease, transform 300ms ease;
}

    .floating-actions.is-visible {
        opacity: 1;
        transform: translateY(0);
    }

.chat-widget {
    border: 0;
    border-radius: 999px;
    padding: 12px;
    box-shadow: rgba(50, 50, 93, 0.25) 0px 2px 5px -1px, rgba(0, 0, 0, 0.3) 0px 1px 3px -1px;
    cursor: pointer;
    appearance: none;
    user-select: none;
}

    .chat-widget:hover {
        transform: scale(1.1);
        transition: opacity 300ms ease-in;
    }

    .chat-widget:active {
        /*background: var(--accent-700);*/
    }

    .chat-widget:focus {
        /*outline: none;*/
        /*box-shadow: 0 0 0 3px var(--accent-100), rgba(0, 0, 0, 0.16) 0 10px 24px;*/
    }


/* STRUCTURED OUTPUTS */
.chat-structured-section-label {
    color: inherit;
}

.chat-structured-section-items {
    list-style-type: disc;
}

.chat-source-link {
    corner-shape: squircle;
    border-radius: 999px;
}

.chat-suggested-question {
    background: transparent;
    outline: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 999px;
    corner-shape: squircle;
}

    .chat-suggested-question.btn {
        color: #FFFFFF;
        opacity: 0.75;
        transition: all 0.2s ease;
    }

        .chat-suggested-question.btn:hover {
            background: rgba(255, 255, 255, 0.1);
            opacity: 1;
        }

        .chat-suggested-question.btn:focus {
            outline: 2px solid rgba(255, 255, 255, 0.4);
        }


/* ANIMATED BACKGROUND - UTILITY */
.bg-animated-soft-gradient {
    position: relative;
    overflow: hidden;
    background: linear-gradient( to right, color-mix(in srgb, var(--primary-800) 55%, transparent), color-mix(in srgb, var(--primary-600) 25%, transparent), transparent );
}

    .bg-animated-soft-gradient::before,
    .bg-animated-soft-gradient::after {
        content: "";
        position: absolute;
        inset: -110%;
        z-index: 0;
        background: conic-gradient( from 0deg, var(--primary-500), var(--secondary-400), var(--accent-400), var(--primary-300), var(--secondary-300), var(--accent-300), var(--primary-500) );
        animation: soft-gradient-spin 6s linear infinite;
        filter: blur(10px);
        opacity: .85;
        transform-origin: 50% 50%;
        pointer-events: none;
    }

    .bg-animated-soft-gradient::after {
        inset: -120%;
        animation-direction: reverse;
        animation-duration: 9s;
        filter: blur(14px);
        opacity: .6;
    }

    .bg-animated-soft-gradient > * {
        position: relative;
        z-index: 1;
    }

@keyframes soft-gradient-spin {
    from {
        transform: rotate(0deg) scale(1.08);
    }

    to {
        transform: rotate(360deg) scale(1.08);
    }
}


/* ADMIN DEBUG */
.chat-debug-modal-dialog {
    max-width: 1400px;
}

.chat-debug-modal-body {
    max-height: 75vh;
    overflow-y: auto;
}

.chat-debug-candidate-card {
    background: #FFF;
    border: 1px solid #b7b7b7;
    padding: 10px;
    box-shadow: rgba(0, 0, 0, 0.1) 0px 1px 3px 0px, rgba(0, 0, 0, 0.06) 0px 1px 2px 0px;
}

.chat-debug-snippet {
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-debug-full-chunk-text {
    white-space: pre-wrap;
    word-break: break-word;
    overflow-y: auto;
    padding: 12px;
    background: #f8f9fb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.chat-debug-toggle {
    outline: none !important;
}