/* ── Chat Widget ── */
.chat-toggle {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #6c63ff;
    border: none;
    cursor: pointer;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(108, 99, 255, .4);
    transition: transform .2s, box-shadow .2s;
}
.chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(108, 99, 255, .55);
}
.chat-toggle svg {
    width: 26px;
    height: 26px;
    fill: #fff;
    transition: opacity .2s;
}
.chat-toggle .chat-icon-close { display: none; }
.chat-toggle.open .chat-icon-open { display: none; }
.chat-toggle.open .chat-icon-close { display: block; }

/* ── Panel ── */
.chat-panel {
    position: fixed;
    bottom: 170px;
    right: 24px;
    width: 380px;
    max-height: 520px;
    background: #111;
    border: 1px solid rgba(108, 99, 255, .25);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    z-index: 9998;
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0,0,0,.5);
    opacity: 0;
    transform: translateY(20px) scale(.95);
    pointer-events: none;
    transition: opacity .25s, transform .25s;
}
.chat-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Header */
.chat-header {
    padding: 16px 20px;
    background: #161616;
    border-bottom: 1px solid rgba(255,255,255,.06);
    display: flex;
    align-items: center;
    gap: 12px;
}
.chat-header-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #4caf50;
    flex-shrink: 0;
}
.chat-header-text h4 {
    margin: 0;
    font-size: 14px;
    color: #fff;
    font-weight: 600;
}
.chat-header-text p {
    margin: 2px 0 0;
    font-size: 11px;
    color: rgba(255,255,255,.45);
}

/* Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 200px;
    max-height: 340px;
    scrollbar-width: thin;
    scrollbar-color: rgba(108,99,255,.3) transparent;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(108,99,255,.3); border-radius: 4px; }

.chat-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    word-wrap: break-word;
}
.chat-msg a { color: #8b83ff; text-decoration: underline; }
.chat-msg-user {
    align-self: flex-end;
    background: #6c63ff;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-msg-assistant {
    align-self: flex-start;
    background: #1e1e1e;
    color: rgba(255,255,255,.88);
    border-bottom-left-radius: 4px;
}

/* Typing indicator */
.chat-typing {
    display: none;
    align-self: flex-start;
    padding: 10px 18px;
    background: #1e1e1e;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    gap: 4px;
}
.chat-typing.visible { display: flex; }
.chat-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255,255,255,.4);
    animation: chatDot 1.2s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: .2s; }
.chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes chatDot {
    0%, 60%, 100% { opacity: .3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-4px); }
}

/* Input */
.chat-input-area {
    padding: 12px 16px;
    background: #161616;
    border-top: 1px solid rgba(255,255,255,.06);
    display: flex;
    gap: 8px;
}
.chat-input-area input {
    flex: 1;
    background: #222;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 8px;
    padding: 10px 14px;
    color: #fff;
    font-size: 13px;
    outline: none;
    transition: border-color .2s;
}
.chat-input-area input::placeholder { color: rgba(255,255,255,.3); }
.chat-input-area input:focus { border-color: #6c63ff; }
.chat-input-area button {
    background: #6c63ff;
    border: none;
    border-radius: 8px;
    padding: 0 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s;
}
.chat-input-area button:hover { background: #5a52e0; }
.chat-input-area button:disabled { opacity: .5; cursor: not-allowed; }
.chat-input-area button svg { width: 18px; height: 18px; fill: #fff; }

/* ── Mobile ── */
@media (max-width: 480px) {
    .chat-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: 100dvh;
        border-radius: 16px 16px 0 0;
    }
    .chat-messages { max-height: calc(100dvh - 180px); }
    .chat-toggle { bottom: 80px; right: 16px; }
}
