/* ── AI Chat Widget — rashasalim.com theme ─────────────────────────────────── */

#ai-chat-bubble {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 99999;
    font-family: 'Inter', sans-serif;
}

/* ── Toggle button ───────────────────────────────────────────────────────── */

#ai-chat-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #f0d700;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    box-shadow: 0 4px 24px rgba(240, 215, 0, 0.35);
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

#ai-chat-toggle:hover {
    background: #d2ff00;
    transform: scale(1.07);
    box-shadow: 0 6px 28px rgba(210, 255, 0, 0.4);
}

#ai-chat-toggle:active {
    transform: scale(0.95);
}

#ai-chat-toggle svg {
    width: 24px;
    height: 24px;
    color: #111111;
    flex-shrink: 0;
}

/* ── Chat window ─────────────────────────────────────────────────────────── */

#ai-chat-window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 360px;
    max-height: 540px;
    background: #1a1a1a;
    border: 1px solid #2c2c2c;
    border-radius: 18px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(240,215,0,0.08);

    /* Hidden by default */
    opacity: 0;
    pointer-events: none;
    transform: scale(0.94) translateY(12px);
    transform-origin: bottom right;
    transition: opacity 0.22s ease, transform 0.22s ease;
}

#ai-chat-window.open {
    opacity: 1;
    pointer-events: all;
    transform: scale(1) translateY(0);
}

/* ── Header ──────────────────────────────────────────────────────────────── */

#ai-chat-header {
    background: #111111;
    padding: 13px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #2c2c2c;
    flex-shrink: 0;
}

#ai-chat-header-title {
    font-family: 'Montserrat', 'Inter', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.02em;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 8px;
}

#ai-chat-header-title::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #f0d700;
    flex-shrink: 0;
    animation: ai-pulse 2.4s infinite;
}

@keyframes ai-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.45; }
}

#ai-chat-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #555;
    padding: 2px;
    display: flex;
    align-items: center;
    transition: color 0.15s;
    line-height: 0;
}

#ai-chat-close:hover { color: #ffffff; }

/* ── Messages ────────────────────────────────────────────────────────────── */

#ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: #2c2c2c transparent;
}

#ai-chat-messages::-webkit-scrollbar       { width: 4px; }
#ai-chat-messages::-webkit-scrollbar-thumb { background: #2c2c2c; border-radius: 4px; }

/* Welcome card */
#ai-chat-welcome {
    background: #111111;
    border: 1px solid #2c2c2c;
    border-radius: 12px;
    padding: 14px 16px;
    color: #888;
    font-size: 0.82rem;
    line-height: 1.65;
    text-align: center;
}

#ai-chat-welcome strong {
    display: block;
    color: #f0d700;
    font-size: 0.9rem;
    margin-bottom: 5px;
    font-family: 'Montserrat', 'Inter', sans-serif;
}

/* Message bubbles */
.ai-chat-msg {
    max-width: 86%;
    padding: 9px 14px;
    border-radius: 14px;
    font-size: 0.875rem;
    line-height: 1.55;
    word-break: break-word;
}

.ai-chat-msg.user {
    background: #f0d700;
    color: #111111;
    font-weight: 500;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.ai-chat-msg.bot {
    background: #242424;
    color: #d8d8d8;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

/* Markdown rendering inside bot bubbles */
.ai-chat-msg.bot p          { margin: 0 0 8px; }
.ai-chat-msg.bot p:last-child { margin-bottom: 0; }
.ai-chat-msg.bot ul,
.ai-chat-msg.bot ol         { margin: 6px 0 8px 18px; padding: 0; }
.ai-chat-msg.bot li         { margin-bottom: 3px; }
.ai-chat-msg.bot strong     { color: #f0d700; font-weight: 600; }
.ai-chat-msg.bot em         { color: #bbb; font-style: italic; }
.ai-chat-msg.bot code       { background: #1a1a1a; border-radius: 4px; padding: 1px 5px; font-family: monospace; font-size: 0.82rem; color: #d2ff00; }
.ai-chat-msg.bot pre        { background: #111; border-radius: 8px; padding: 10px 12px; overflow-x: auto; margin: 8px 0; }
.ai-chat-msg.bot pre code   { background: none; padding: 0; color: #d2ff00; }
.ai-chat-msg.bot hr         { border: none; border-top: 1px solid #333; margin: 8px 0; }

.ai-chat-msg.error {
    background: #2e1414;
    color: #ff6b6b;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    font-size: 0.82rem;
}

/* Typing indicator */
.ai-chat-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 11px 14px;
    background: #242424;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    width: fit-content;
}

.ai-chat-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #444;
    animation: ai-bounce 1.3s infinite;
}
.ai-chat-typing span:nth-child(2) { animation-delay: 0.18s; }
.ai-chat-typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes ai-bounce {
    0%, 60%, 100% { transform: translateY(0);   background: #444; }
    30%            { transform: translateY(-5px); background: #f0d700; }
}

/* ── Input area ──────────────────────────────────────────────────────────── */

#ai-chat-input-area {
    padding: 10px 12px;
    border-top: 1px solid #2c2c2c;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
    background: #1a1a1a;
}

#ai-chat-input {
    flex: 1;
    background: #242424;
    border: 1px solid #333;
    border-radius: 20px;
    color: #ffffff;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    padding: 9px 16px;
    resize: none;
    outline: none;
    line-height: 1.45;
    max-height: 96px;
    overflow-y: auto;
    transition: border-color 0.18s;
    scrollbar-width: none;
}

#ai-chat-input::-webkit-scrollbar { display: none; }
#ai-chat-input:focus               { border-color: #f0d700; }
#ai-chat-input::placeholder        { color: #4a4a4a; }

#ai-chat-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #f0d700;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.18s, transform 0.1s;
    line-height: 0;
}

#ai-chat-send:hover   { background: #d2ff00; }
#ai-chat-send:active  { transform: scale(0.9); }

#ai-chat-send:disabled {
    background: #2a2a2a;
    cursor: not-allowed;
}

#ai-chat-send svg               { width: 15px; height: 15px; color: #111111; }
#ai-chat-send:disabled svg      { color: #555; }

/* ── Mobile ──────────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
    #ai-chat-bubble {
        bottom: 16px;
        right: 16px;
    }

    #ai-chat-window {
        width: calc(100vw - 32px);
        right: -4px;
        bottom: 68px;
        max-height: 72vh;
    }
}
