#chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    font-family: 'Inter', -apple-system, sans-serif;
}

#chat-toggle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00d4ff, #6c3aed);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 24px;
    box-shadow: 0 4px 24px rgba(0, 212, 255, 0.3), 0 0 0 2px rgba(0, 212, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow .3s;
    position: relative;
    overflow: visible;
}

#chat-toggle::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00d4ff, #7c3aed, #f59e0b, #00d4ff);
    background-size: 300% 300%;
    z-index: -1;
    animation: toggleGlow 4s ease infinite;
    opacity: 0.5;
}

@keyframes toggleGlow {
    0%, 100% { background-position: 0% 50%; opacity: 0.5; }
    50% { background-position: 100% 50%; opacity: 0.8; }
}

#chat-toggle::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, #00d4ff, #6c3aed);
    z-index: -1;
}

#chat-toggle:hover {
    transform: scale(1.1) rotate(-5deg);
    box-shadow: 0 8px 40px rgba(0, 212, 255, 0.4), 0 0 0 3px rgba(0, 212, 255, 0.15);
}

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

#chat-toggle svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}

#chat-toggle .chat-notification {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #f59e0b;
    border: 2.5px solid #050510;
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.5);
    animation: notifPulse 2s ease-in-out infinite;
    z-index: 2;
}

@keyframes notifPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 12px rgba(245, 158, 11, 0.5); }
    50% { transform: scale(1.15); box-shadow: 0 0 20px rgba(245, 158, 11, 0.7); }
}

.chat-ai-label {
    position: absolute;
    right: 72px;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.15), rgba(124, 58, 237, 0.12));
    border: 1px solid rgba(0, 212, 255, 0.2);
    border-radius: 20px;
    padding: 6px 14px 6px 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 600;
    color: #e8e8f0;
    pointer-events: none;
    animation: labelIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) 0.5s both, labelPulse 3s ease-in-out infinite 2s;
    backdrop-filter: blur(8px);
}

.chat-ai-label .ai-badge-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    animation: pulse-dot 2s ease-in-out infinite;
    flex-shrink: 0;
}

.chat-ai-label .ai-badge-text {
    background: linear-gradient(135deg, #00d4ff, #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 11px;
    letter-spacing: 0.04em;
}

@keyframes labelIn {
    from { opacity: 0; transform: translateY(-50%) translateX(12px); }
    to { opacity: 1; transform: translateY(-50%) translateX(0); }
}

@keyframes labelPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 212, 255, 0); }
    50% { box-shadow: 0 0 16px rgba(0, 212, 255, 0.08); }
}

#chat-panel {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 370px;
    height: 530px;
    background: #0c0c24;
    border: 1px solid rgba(0, 212, 255, 0.12);
    border-radius: 18px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5), 0 0 60px rgba(0, 212, 255, 0.04);
    display: none;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(20px);
}

#chat-panel.open {
    display: flex;
}

#chat-header {
    padding: 14px 16px;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.12), rgba(124, 58, 237, 0.10));
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    gap: 10px;
}

#chat-header .chat-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00d4ff, #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex-shrink: 0;
}

#chat-header .chat-avatar svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}

#chat-header .chat-avatar::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00d4ff, #7c3aed, #f59e0b);
    z-index: -1;
    opacity: 0.4;
}

.chat-ai-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.2), rgba(124, 58, 237, 0.15));
    border: 1px solid rgba(0, 212, 255, 0.15);
    border-radius: 12px;
    padding: 2px 10px 2px 8px;
    font-size: 9.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #00d4ff;
    margin-left: auto;
    flex-shrink: 0;
}

.chat-ai-pill .spark {
    font-size: 10px;
}

#chat-header .chat-title {
    flex: 1;
    min-width: 0;
}

#chat-header .chat-title .chat-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

#chat-header .chat-title .chat-name-row strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #e8e8f0;
    letter-spacing: -0.01em;
}

#chat-header .chat-title small {
    font-size: 10.5px;
    color: rgba(232, 232, 240, 0.45);
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 1px;
}

#chat-header .chat-title small .status-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #10b981;
    display: inline-block;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

#chat-close {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: rgba(232, 232, 240, 0.5);
    cursor: pointer;
    font-size: 18px;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s, color .2s;
    flex-shrink: 0;
}

#chat-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #e8e8f0;
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#chat-messages::-webkit-scrollbar { width: 4px; }
#chat-messages::-webkit-scrollbar-track { background: transparent; }
#chat-messages::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.08); border-radius: 4px; }
#chat-messages::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.15); }

#chat-messages .message {
    max-width: 88%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: msgIn .3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-msg-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    animation: msgIn .3s cubic-bezier(0.4, 0, 0.2, 1);
    align-self: flex-start;
    max-width: 95%;
}

.chat-msg-row .msg-ai-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00d4ff, #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
    font-size: 12px;
    box-shadow: 0 2px 8px rgba(0, 212, 255, 0.15);
}

.chat-msg-row .msg-ai-avatar svg {
    width: 14px;
    height: 14px;
    fill: #fff;
}

.chat-msg-row .msg-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.chat-msg-row .msg-ai-label {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(0, 212, 255, 0.7);
    padding-left: 2px;
}

.chat-msg-row .message {
    max-width: 100%;
}

.chat-msg-row .message.assistant {
    background: rgba(255, 255, 255, 0.04);
    color: rgba(232, 232, 240, 0.92);
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

@keyframes msgIn {
    from { opacity: 0; transform: translateY(8px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

#chat-messages .message.user {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.15), rgba(124, 58, 237, 0.1));
    color: #e8e8f0;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    border: 1px solid rgba(0, 212, 255, 0.08);
}

#chat-messages .message.assistant {
    background: rgba(255, 255, 255, 0.04);
    color: rgba(232, 232, 240, 0.92);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

#chat-messages .message.assistant code {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-family: 'JetBrains Mono', monospace;
    color: #00d4ff;
}

#chat-messages .message.assistant pre {
    background: rgba(0, 0, 0, 0.35);
    padding: 12px;
    border-radius: 10px;
    overflow-x: auto;
    margin: 8px 0;
    font-size: 12px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

#chat-messages .typing {
    align-self: flex-start;
    padding: 12px 18px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    display: flex;
    gap: 5px;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

#chat-messages .typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(0, 212, 255, 0.5);
    animation: typing 1.4s ease-in-out infinite;
}

#chat-messages .typing span:nth-child(2) { animation-delay: .2s; background: rgba(124, 58, 237, 0.5); }
#chat-messages .typing span:nth-child(3) { animation-delay: .4s; background: rgba(245, 158, 11, 0.5); }

@keyframes typing {
    0%, 60%, 100% { opacity: .3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-6px); }
}

#chat-input-area {
    padding: 12px 16px 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: rgba(0, 0, 0, 0.15);
}

#chat-input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.04);
    color: #e8e8f0;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 13px;
    resize: none;
    outline: none;
    max-height: 80px;
    line-height: 1.4;
    transition: border-color .2s;
}

#chat-input::placeholder {
    color: rgba(232, 232, 240, 0.3);
    font-size: 12.5px;
}

#chat-input:focus {
    border-color: rgba(0, 212, 255, 0.3);
    background: rgba(0, 212, 255, 0.03);
}

#chat-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00d4ff, #7c3aed);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity .2s, transform .2s;
    box-shadow: 0 2px 12px rgba(0, 212, 255, 0.2);
}

#chat-send:not(:disabled):hover {
    transform: scale(1.08);
}

#chat-send:disabled {
    opacity: .35;
    cursor: default;
    box-shadow: none;
}

.faq-container {
    padding: 6px 0 2px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    animation: msgIn .35s cubic-bezier(0.4, 0, 0.2, 1);
}

.faq-label {
    font-size: 11.5px;
    color: rgba(232, 232, 240, 0.35);
    margin-bottom: 2px;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.faq-btn {
    background: rgba(0, 212, 255, 0.06);
    border: 1px solid rgba(0, 212, 255, 0.12);
    border-radius: 20px;
    padding: 7px 14px;
    color: rgba(232, 232, 240, 0.8);
    font-size: 12.5px;
    cursor: pointer;
    text-align: left;
    transition: all .2s;
    font-family: 'Inter', -apple-system, sans-serif;
    line-height: 1.4;
}

.faq-btn:hover {
    background: rgba(0, 212, 255, 0.12);
    border-color: rgba(0, 212, 255, 0.25);
    color: #e8e8f0;
    transform: translateX(3px);
}

.faq-btn::before {
    content: '›';
    margin-right: 6px;
    color: #00d4ff;
    font-weight: 700;
    font-size: 15px;
}

@media (max-width: 640px) {
    #chat-widget {
        bottom: 0;
        right: 0;
    }

    #chat-panel {
        width: 100vw;
        height: 100dvh;
        bottom: 0;
        right: 0;
        border-radius: 0;
        border: none;
        box-shadow: none;
        backdrop-filter: none;
    }

    #chat-panel.open {
        border-radius: 0;
    }

    #chat-toggle {
        width: 56px;
        height: 56px;
        margin: 0 12px 12px 0;
        box-shadow: 0 4px 20px rgba(0, 212, 255, 0.35), 0 0 0 2px rgba(0, 212, 255, 0.1);
    }

    #chat-toggle svg {
        width: 24px;
        height: 24px;
    }

    .chat-ai-label {
        right: 72px;
        padding: 5px 12px 5px 8px;
        font-size: 12px;
    }

    .chat-ai-label .ai-badge-text {
        font-size: 10px;
    }

    #chat-header {
        padding: 12px 14px;
        border-radius: 0;
    }

    #chat-header .chat-avatar {
        width: 34px;
        height: 34px;
    }

    #chat-header .chat-avatar svg {
        width: 18px;
        height: 18px;
    }

    #chat-header .chat-title .chat-name-row strong {
        font-size: 13px;
    }

    .chat-ai-pill {
        font-size: 8.5px;
        padding: 2px 8px 2px 6px;
    }

    #chat-messages {
        padding: 12px;
        gap: 8px;
    }

    #chat-messages .message {
        max-width: 92%;
        padding: 9px 12px;
        font-size: 12.5px;
    }

    .chat-msg-row {
        gap: 6px;
        max-width: 98%;
    }

    .chat-msg-row .msg-ai-avatar {
        width: 24px;
        height: 24px;
    }

    .chat-msg-row .msg-ai-avatar svg {
        width: 12px;
        height: 12px;
    }

    .chat-msg-row .msg-ai-label {
        font-size: 8px;
    }

    #chat-input-area {
        padding: 10px 12px 14px;
        gap: 6px;
    }

    #chat-input {
        padding: 9px 14px;
        font-size: 14px;
    }

    #chat-send {
        width: 40px;
        height: 40px;
        font-size: 14px;
    }

    .faq-btn {
        padding: 6px 12px;
        font-size: 12px;
    }

    #chat-close {
        width: 28px;
        height: 28px;
        font-size: 16px;
    }
}
