/* Explain: Styles for the AI chat window, buttons, and message display. */
#aiChatWindow {
    height: min(34rem, calc(100vh - 7.5rem));
    height: min(34rem, calc(100dvh - 7.5rem));
    width: min(23rem, calc(100vw - 2rem));
}

@media (max-width: 480px) {
    #aiChatWindow {
        width: calc(100vw - 1.5rem);
        height: min(31rem, calc(100vh - 6.5rem));
        height: min(31rem, calc(100dvh - 6.5rem));
    }
}

.ai-chat-scrollwrap {
    position: relative;
}

.ai-chat-messages {
    scrollbar-width: thin;
    scrollbar-color: rgba(53, 184, 176, 0.5) transparent;
}

.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(53, 184, 176, 0.45);
    border-radius: 999px;
}

.ai-chat-messages:focus-visible {
    outline: 2px solid rgba(53, 184, 176, 0.6);
    outline-offset: -2px;
}

.ai-chat-msg {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.ai-chat-scrollbtn {
    position: absolute;
    inset-inline-end: 0.6rem;
    display: none;
    align-items: center;
    justify-content: center;
    width: 2.15rem;
    height: 2.15rem;
    border-radius: 999px;
    border: 1px solid rgba(53, 184, 176, 0.45);
    background: rgba(23, 70, 100, 0.94);
    color: var(--primary-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 8px 22px -8px rgba(0, 0, 0, 0.7);
    cursor: pointer;
    z-index: 5;
    transition: transform 220ms ease, background 220ms ease, color 220ms ease;
}

.ai-chat-scrollbtn.is-visible {
    display: inline-flex;
}

.ai-chat-scrollbtn:hover,
.ai-chat-scrollbtn:focus-visible {
    background: var(--primary-color);
    color: var(--midnight-color);
    transform: scale(1.08);
    outline: none;
}

.ai-chat-scrollbtn--up {
    top: 0.55rem;
}

.ai-chat-scrollbtn--down {
    bottom: 0.55rem;
}

.ai-chat-newdot {
    display: none;
    position: absolute;
    inset-inline-start: 50%;
    top: -0.5rem;
    transform: translateX(-50%);
    padding: 0 0.35rem;
    border-radius: 999px;
    background: var(--signal-green);
    color: #0B2338;
    font-size: 0.5rem;
    font-weight: 800;
    line-height: 1.5;
    letter-spacing: 0.02em;
    white-space: nowrap;
    box-shadow: 0 0 10px rgba(53, 184, 176, 0.75);
}

.ai-chat-newdot.is-on {
    display: block;
}

.ai-chat-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 999px;
    border: 1px solid rgba(53, 184, 176, 0.4);
    background: rgba(0, 0, 0, 0.3);
    color: var(--warm-white);
    cursor: pointer;
    transition: transform 220ms ease, background 220ms ease, border-color 220ms ease, color 220ms ease;
}

.ai-chat-close:hover,
.ai-chat-close:focus-visible {
    background: rgba(220, 38, 38, 0.85);
    border-color: rgba(220, 38, 38, 0.9);
    color: #FFFFFF;
    transform: rotate(90deg);
    outline: none;
}

.ai-chat-dot {
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--primary-color);
    animation: aiChatDot 1s ease-in-out infinite;
}

@keyframes aiChatDot {
    0%, 100% {
        opacity: 0.35;
        transform: translateY(0);
    }
    50% {
        opacity: 1;
        transform: translateY(-2px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .ai-chat-scrollbtn,
    .ai-chat-close {
        transition: none !important;
    }

    .ai-chat-dot {
        animation: none !important;
        opacity: 0.8;
    }
}