/* ============================================================
   Bridge_AIChat — Chat Widget Styles
   Full-height sidebar docked to the right edge of the viewport.
   ============================================================ */

:root {
    --aichat-panel-width: 380px;
}

@media (max-width: 480px) {
    :root {
        --aichat-panel-width: 100vw;
    }
}

/* ── Page push ───────────────────────────────────────────────
   Instead of the panel overlaying the page, the page itself
   shifts left by the panel's width so nothing sits hidden
   behind the chat — the whole site stays visible, just shrunk
   over to make room on the right.
   ──────────────────────────────────────────────────────────── */
html.aichat-open,
html.aichat-open body {
    overflow-x: hidden;
}

html.aichat-open .page-wrapper {
    margin-right: var(--aichat-panel-width);
}

.page-wrapper {
    transition: margin-right 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

/* ── Keyframes ───────────────────────────────────────────── */
@keyframes aichat-dot-bounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-6px);
    }
}

/* ── Launcher Button ─────────────────────────────────────── */
#bridge-aichat-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;

    display: flex;
    align-items: center;
    justify-content: center;

    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    cursor: pointer;

    background: #12213d;
    color: #ffffff;

    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#bridge-aichat-launcher:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.3);
}

#bridge-aichat-launcher:focus-visible {
    outline: 3px solid #12213d;
    outline-offset: 3px;
}

/* Hidden while the panel is open — the header close button (and Escape)
   handle closing, so the launcher no longer needs to sit on top of the
   input area's send button. */
#bridge-aichat-launcher.is-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

/* Dimmed while the session is being initialized on first open */
#bridge-aichat-launcher.is-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* ── Chat Window: full-height sidebar, docked right ───────── */
#bridge-aichat-window {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 9998;

    width: var(--aichat-panel-width);
    max-width: 85vw;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    overflow: hidden;

    display: flex;
    flex-direction: column;

    background: #ffffff;
    box-shadow: -5px 0 0px rgba(0, 0, 0, 0.1);

    transform: translateX(100%);
    visibility: hidden;
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s linear 0.3s;
}

#bridge-aichat-window.is-open {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.aichat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 16px;
    background: #ffffff;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(30, 41, 59, 0.08);
}

.aichat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.aichat-header-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #1e3a5f;
    color: #ffffff;
    flex-shrink: 0;
}

.aichat-header-title {
    color: #1e293b;
    font-size: 18px;
    font-weight: 600;
    font-family: 'Lexend Deca', sans-serif;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.aichat-header-subtitle {
    color: #64748b;
    font-size: 12px;
    font-weight: 400;
    font-family: 'Lexend', sans-serif;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    margin-top: 2px;
}

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

.aichat-header-btn {
    background: rgba(30, 41, 59, 0.06);
    border: none;
    color: #1e293b;
    cursor: pointer;
    padding: 9px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    line-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.aichat-header-btn:hover {
    background: rgba(30, 41, 59, 0.12);
    color: #1e293b;
}

.aichat-header-btn:focus-visible {
    outline: 2px solid #2f6fed;
    outline-offset: 2px;
}

/* ── Messages Area ───────────────────────────────────────── */
.aichat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    background: #ffffff;
}

.aichat-messages::-webkit-scrollbar {
    width: 4px;
}

.aichat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.aichat-messages::-webkit-scrollbar-thumb {
    background: rgba(30, 41, 59, 0.15);
    border-radius: 4px;
}

/* ── Message Bubbles ─────────────────────────────────────── */
.aichat-msg {
    max-width: 82%;
    padding: 11px 15px;
    font-size: 14px;
    line-height: 1.5;
    font-family: 'Lexend', sans-serif;
    word-break: break-word;
}

.aichat-msg-bot {
    align-self: flex-start;
    background: #f1f5f9;
    color: #1e293b;
    border-radius: 4px 14px 14px 14px;
}

.aichat-msg-user {
    align-self: flex-end;
    background: #2f6fed;
    color: #ffffff;
    border-radius: 14px 4px 14px 14px;
}

/* ── Typing Indicator ────────────────────────────────────── */
.aichat-typing {
    align-self: flex-start;
    background: #f1f5f9;
    border-radius: 4px 14px 14px 14px;
    padding: 13px 16px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.aichat-typing span {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #94a3b8;
    animation: aichat-dot-bounce 1.2s infinite ease-in-out;
}

.aichat-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.aichat-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

/* ── Input Area ──────────────────────────────────────────── */
.aichat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 14px 16px;
    border-top: 1px solid rgba(30, 41, 59, 0.08);
    background: #ffffff;
    flex-shrink: 0;
}

.aichat-textarea {
    flex: 1 1 auto;
    resize: none;
    border: 1px solid rgba(30, 41, 59, 0.15);
    border-radius: 22px;
    padding: 11px 16px;
    font-size: 14px;
    font-family: 'Lexend', sans-serif;
    line-height: 1.4;
    max-height: 120px;
    overflow-y: auto;
    outline: none;
    color: #1e293b;
    transition: border-color 0.15s, background 0.15s;
    background: #f8fafc;
}

.aichat-textarea:focus {
    border-color: #2f6fed;
    background: #ffffff;
}

.aichat-textarea::placeholder {
    color: #94a3b8;
}

.aichat-send-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: #2f6fed;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.15s;
    padding: 0;
}

.aichat-send-btn:hover:not(:disabled) {
    background: #1f5be0;
    transform: scale(1.06);
}

.aichat-send-btn:disabled {
    background: rgba(30, 41, 59, 0.15);
    cursor: not-allowed;
    transform: none;
}

/* ── Responsive: full-width sheet on small screens ────────── */
@media (max-width: 480px) {
    #bridge-aichat-window {
        width: 100vw;
        max-width: 100vw;
    }

    #bridge-aichat-launcher {
        right: 16px;
        bottom: 16px;
    }
}
