/* ============================================================
   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: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    cursor: pointer;

    background: #1a73e8;
    color: #ffffff;

    box-shadow: 0 4px 16px rgba(26, 115, 232, 0.45);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#bridge-aichat-launcher:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 22px rgba(26, 115, 232, 0.55);
}

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

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

    width: 360px;
    height: 520px;
    border-radius: 12px;
    overflow: hidden;

    display: none;
    flex-direction: column;

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

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

/* ── Header ──────────────────────────────────────────────── */
.aichat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: #1a73e8;
    flex-shrink: 0;
}

.aichat-header-title {
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.aichat-close-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.85);
    font-size: 18px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.aichat-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

/* ── 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: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    word-break: break-word;
}

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

.aichat-msg-user {
    align-self: flex-end;
    background: #1a73e8;
    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: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 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;
    }
}
