/* AI Chat Widget — Groq-only (Enhanced, High-Contrast + Mobile + Typing) */

#rk-chat {
    position: fixed;
    right: 18px;
    bottom: calc(var(--rp-player-h, 80px) + 20px);
    width: 320px;
    max-height: 450px;
    display: none;
    z-index: 5500;
    background: var(--the-surface, #0f172a);
    color: var(--the-ink, #e5e7eb);
    border: 1px solid var(--the-line, rgba(255, 255, 255, .12));
    border-radius: calc(var(--the-cardRadius, 12) * 1px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
    overflow: hidden;
    transform: translateY(20px);
    opacity: 0;
    transition: all .3s ease;
}

#rk-chat.open {
    display: block;
    transform: translateY(0);
    opacity: 1;
}

/* Header */
.rk-chat__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
    padding: .6rem .7rem;
    border-bottom: 1px solid var(--the-line, rgba(255, 255, 255, .08));
    background: color-mix(in oklab, var(--the-surface, #0f172a) 88%, black 12%);
}

.rk-chat__title {
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.rk-chat__title small {
    font-weight: 600;
    opacity: .9;
    padding: .15rem .45rem;
    border-radius: 999px;
    border: 1px solid var(--the-line, rgba(255, 255, 255, .14));
    text-transform: none;
}

/* Body */
.rk-chat__body {
    padding: .7rem;
    overflow-y: auto;
    max-height: 300px;
    background: color-mix(in oklab, var(--the-surface, #0f172a) 92%, black 8%);
}

/* Messages */
.rk-msg {
    padding: .5rem .65rem;
    border-radius: 12px;
    margin: .35rem 0;
    max-width: 92%;
    word-wrap: break-word;
}

.rk-msg--you {
    margin-left: auto;
    background: #111827;
    color: #ffffff;
    border: 1px solid #374151;
}

.rk-msg--bot {
    background: #0ea5e9;
    color: #001018;
    border: 1px solid #0284c7;
}

/* Typing animation */
.rk-typing {
    display: flex;
    align-items: center;
    gap: 3px;
}

.rk-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #001018;
    opacity: .25;
    animation: rkBlink 1s infinite ease-in-out;
}

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

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

@keyframes rkBlink {

    0%,
    80%,
    100% {
        opacity: .25;
    }

    40% {
        opacity: 1;
    }
}

/* Form */
.rk-chat__form {
    display: flex;
    gap: .45rem;
    padding: .6rem .7rem;
    border-top: 1px solid var(--the-line, rgba(255, 255, 255, .08));
    background: color-mix(in oklab, var(--the-surface, #0f172a) 90%, black 10%);
}

.rk-chat__input {
    flex: 1;
    min-width: 0;
    background: #0b1220;
    color: #e5e7eb;
    border: 1px solid #263242;
    border-radius: 10px;
    padding: .55rem .65rem;
}

.rk-chat__input::placeholder {
    color: #8aa0b6;
}

.rk-chat__send {
    background: var(--the-brand, #1DB954);
    color: #000;
    border: 1px solid var(--the-brand, #1DB954);
    border-radius: 10px;
    padding: .55rem .8rem;
    font-weight: 800;
    transition: background .2s ease;
}

.rk-chat__send:hover {
    background: color-mix(in oklab, var(--the-brand, #1DB954) 85%, white 15%);
}

/* Floating Action Button (FAB) */
#chat-toggle {
    position: fixed;
    right: 18px;
    bottom: calc(var(--rp-player-h, 80px) + 18px);
    z-index: 5501;
    background: var(--the-brand, #1DB954);
    color: #000;
    border: 1px solid var(--the-brand, #1DB954);
    border-radius: 999px;
    padding: .65rem .9rem;
    font-weight: 800;
    box-shadow: 0 10px 24px rgba(0, 0, 0, .28);
    transition: transform .3s ease, opacity .3s ease;
}

/* Hide FAB when chat open (prevent overlap) */
#rk-chat.open+#chat-toggle,
body.chat-open #chat-toggle {
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}

/* Mobile layout */
@media (max-width: 480px) {
    #rk-chat {
        width: 94%;
        left: 3%;
        right: 3%;
        bottom: calc(var(--rp-player-h, 80px) + 12px);
        max-height: 70vh;
    }

    .rk-chat__body {
        max-height: 52vh;
    }

    .rk-chat__form {
        padding: .5rem;
    }

    .rk-chat__input {
        font-size: .9rem;
        padding: .45rem .6rem;
    }

    .rk-chat__send {
        padding: .45rem .7rem;
    }
}