/* =========================
   Light page + Dark Chat Widget
   (scoped variables to chat only)
   ========================= */

/* Keep ROOT light/neutral so it doesn't affect the whole site */
:root {
    --radius: 18px;
    --shadow: 0 18px 55px rgba(0, 0, 0, .18);
}

/* Dark theme variables ONLY for the chat widget */
.chat-window,
.chat-button {
    --bg: #0b1220;
    --panel: rgba(255, 255, 255, .08);
    --panel-2: rgba(255, 255, 255, .12);
    --border: rgba(255, 255, 255, .16);
    --text: rgba(255, 255, 255, .92);
    --muted: rgba(255, 255, 255, .65);
    --primary: #6ea8ff;
    --primary-2: #7cf0c5;
    --danger: #ff6b6b;
    --shadow: 0 18px 55px rgba(0, 0, 0, .35);
    --radius: 18px;
}

/* Floating Chat Button */
.chat-button {
    position: fixed;
    bottom: 18px;
    right: 18px;
    width: 82px;
    height: 82px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    cursor: pointer;
    z-index: 1001;
    color: #fff;
    font-size: 32px;
    -webkit-user-select: none;
    user-select: none;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    box-shadow: var(--shadow);
    transition: transform .18s ease, filter .18s ease;
}

.chat-button:hover {
    transform: translateY(-2px) scale(1.03);
    filter: brightness(1.05);
}

.chat-button:active {
    transform: translateY(0) scale(.98);
}

/* Chat Window */
.chat-window {
    position: fixed;
    right: 22px;
    bottom: 102px;
    width: 440px;
    max-width: calc(100vw - 36px);
    height: 620px;
    max-height: calc(100vh - 140px);

    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 1000;

    border-radius: var(--radius);
    border: 1px solid var(--border);

    /* Dark-only inside the chat */
    background:
        radial-gradient(600px 400px at 10% 0%, rgba(110, 168, 255, .18), transparent 60%),
        radial-gradient(520px 420px at 90% 10%, rgba(124, 240, 197, .14), transparent 60%),
        linear-gradient(180deg, rgba(11, 18, 32, .98), rgba(11, 18, 32, .92));

    color: var(--text);

    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);

    box-shadow:
        0 25px 70px rgba(0, 0, 0, .35),
        0 0 0 1px rgba(255, 255, 255, .06),
        0 0 40px rgba(110, 168, 255, .18);

    transform: translateY(14px) scale(.98);
    opacity: 0;
    transition: transform .22s ease, opacity .22s ease;
}

.chat-window.show {
    display: flex;
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* Header */
.chat-header {
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(90deg, rgba(110, 168, 255, .18), rgba(124, 240, 197, .10));
}

.chat-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.chat-logo {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    color: #0b1220;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    box-shadow: 0 10px 22px rgba(0, 0, 0, .25);
}

.chat-title {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-title strong {
    color: var(--text);
    font-size: 13.5px;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-title span {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.1;
}

/* Close button */
.chat-header .chat-close {
    margin-left: auto;
    width: 34px;
    height: 34px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, .06);
    color: var(--text);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: transform .15s ease, background .15s ease;

    line-height: 1;
    padding: 0;
    font-size: 18px;
}

.chat-header .chat-close:hover {
    background: rgba(255, 255, 255, .10);
    transform: scale(1.03);
}

/* Message Area */
#chat-response {
    flex: 1;
    padding: 14px 12px;
    overflow-y: auto;
    scroll-behavior: smooth;

    /* keep it dark, subtle */
    background: linear-gradient(180deg, rgba(0, 0, 0, .10), rgba(0, 0, 0, .04));
}

#chat-response::-webkit-scrollbar {
    width: 10px;
}

#chat-response::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .14);
    border-radius: 999px;
    border: 2px solid rgba(0, 0, 0, 0);
    background-clip: padding-box;
}

/* Message rows */
.chat-message {
    display: flex;
    gap: 10px;
    margin: 10px 0;
    align-items: flex-end;
}

.chat-message.user {
    justify-content: flex-end;
}

.chat-message.ai {
    justify-content: flex-start;
}

/* Avatars */
.avatar {
    width: 30px;
    height: 30px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    font-weight: 800;
    font-size: 12px;
    color: rgba(255, 255, 255, .95);
    background: rgba(255, 255, 255, .10);
    border: 1px solid var(--border);
}

.chat-message.user .avatar {
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    border: none;
    color: #0b1220;
}

/* Bubbles */
.message-bubble {
    max-width: 78%;
    padding: 10px 12px;
    border-radius: 16px;
    line-height: 1.35;
    font-size: 13.5px;
    box-shadow: 0 10px 22px rgba(0, 0, 0, .18);
    border: 1px solid rgba(255, 255, 255, .14);
}

.chat-message.ai .message-bubble {
    color: var(--text);
    background: rgba(255, 255, 255, .08);
    border-top-left-radius: 10px;
}

.chat-message.user .message-bubble {
    color: #0b1220;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    border: none;
    border-top-right-radius: 10px;
}

.message-bubble a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.message-bubble img {
    max-width: 100%;
    border-radius: 12px;
    margin-top: 8px;
}

/* Typing dots */
.typing {
    display: inline-flex;
    gap: 6px;
    padding: 10px 12px;
    border-radius: 16px;
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .14);
}

.typing span {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .70);
    animation: dot 1.2s infinite ease-in-out;
}

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

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

@keyframes dot {

    0%,
    80%,
    100% {
        transform: translateY(0);
        opacity: .55;
    }

    40% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* Input */
#chat-form {
    padding: 12px;
    display: flex;
    gap: 10px;
    align-items: center;
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, .04);
}

#chat-form input {
    flex: 1;
    height: 44px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, .16);
    background: rgba(0, 0, 0, .35);
    color: var(--text);
    padding: 0 12px;
    outline: none;
    transition: border .15s ease, background .15s ease;
}

#chat-form input::placeholder {
    color: rgba(255, 255, 255, .55);
}

#chat-form input:focus {
    border-color: rgba(110, 168, 255, .60);
    background: rgba(0, 0, 0, .45);
}

#chat-form button {
    height: 44px;
    padding: 0 14px;
    border-radius: 14px;
    border: 0;
    cursor: pointer;
    font-weight: 700;
    color: #0b1220;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    box-shadow: 0 12px 26px rgba(0, 0, 0, .25);
    transition: transform .15s ease, filter .15s ease;
}

#chat-form button:hover {
    transform: translateY(-1px);
    filter: brightness(1.03);
}

#chat-form button:active {
    transform: translateY(0);
}

/* Mobile */
@media (max-width: 420px) {
    .chat-window {
        right: 10px;
        bottom: 78px;
        width: calc(100vw - 20px);
        height: min(560px, calc(100vh - 120px));
    }

    .chat-button {
        right: 12px;
        bottom: 12px;
    }
}