/* ============================================================
   Bridge_AIChat — Chat Widget Styles
   ============================================================ */

/* ── Keyframes ───────────────────────────────────────────── */
@keyframes aichat-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@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: #ffffff;
    color: #1e293b;

    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    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.2);
}

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

/* ── Chat Window ─────────────────────────────────────────── */
#bridge-aichat-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    z-index: 9998;

    width: 370px;
    height: 540px;
    border-radius: 16px;
    overflow: hidden;

    display: none;
    flex-direction: column;

    background: #ffffff;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
}

#bridge-aichat-window.is-open {
    display: flex;
    animation: aichat-slide-up 0.22s ease forwards;
}

#bridge-aichat-window.is-expanded {
    width: calc(100vw - 48px);
    height: calc(100vh - 120px);
    max-width: 700px;
    max-height: 800px;
    bottom: 96px;
    right: 24px;
    border-radius: 16px;
    z-index: 9998;
    transition: width 0.25s ease, height 0.25s ease, bottom 0.25s ease;
}

.aichat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 12px 22px 16px;
    background: #ffffff;
    flex-shrink: 0;
    border-bottom: 1px solid #e8e2d9;
}

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

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

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

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

.aichat-header-btn {
    background: transparent;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    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(0, 0, 0, 0.08);
    color: #1e293b;
}

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

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

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

.aichat-messages::-webkit-scrollbar-thumb {
    background: #d0d4db;
    border-radius: 4px;
}

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

.aichat-msg-bot {
    align-self: flex-start;
    background: #EAEAEA;
    color: #000000;
    border-radius: 0 12px 12px 12px;
}

.aichat-msg-user {
    align-self: flex-end;
    background: #0066FF;
    color: #ffffff;
    border-radius: 12px 0 12px 12px;
}

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

.aichat-typing span {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #80868b;
    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: 10px 12px;
    border-top: 1px solid #e8eaed;
    background: #ffffff;
    flex-shrink: 0;
}

.aichat-textarea {
    flex: 1 1 auto;
    resize: none;
    border: 1px solid #dadce0;
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 14px;
    font-family: 'Lexend', sans-serif;
    line-height: 1.4;
    max-height: 120px;
    overflow-y: auto;
    outline: none;
    color: #202124;
    transition: border-color 0.15s;
    background: #f8f9fa;
}

.aichat-textarea:focus {
    border-color: #1a73e8;
    background: #ffffff;
}

.aichat-textarea::placeholder {
    color: #9aa0a6;
}

.aichat-send-btn {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: #1a73e8;
    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: #1558b0;
    transform: scale(1.06);
}

.aichat-send-btn:disabled {
    background: #dadce0;
    cursor: not-allowed;
    transform: none;
}

/* ── Responsive: shrink on very small screens ─────────────── */
@media (max-width: 400px) {
    #bridge-aichat-window {
        width: calc(100vw - 16px);
        right: 8px;
        bottom: 84px;
    }

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