
#aichat-widget-container {
    --background: #ffffff;
    --user-bg: #eef2f5;
    --ai-bg: #fdfdfd;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    position: fixed;
    bottom: 30px;
    z-index: 999999;
}

.aichat-pos-right { right: 30px; }
.aichat-pos-left { left: 30px; }

#aichat-toggle-btn {
    width: 64px;
    height: 64px;
    background-color: var(--nid-primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 28px rgba(0,0,0,0.18);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#aichat-toggle-btn:hover { transform: scale(1.08); }

#aichat-window {
    width: 380px;
    height: 600px;
    background: var(--background);
    border-radius: 16px;
    box-shadow: 0 15px 45px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: absolute;
    bottom: 90px;
    transition: opacity 0.3s ease, transform 0.3s ease;
    border: 1px solid rgba(0,0,0,0.06);
}

.aichat-pos-right #aichat-window { right: 0; transform-origin: bottom right; }
.aichat-pos-left #aichat-window { left: 0; transform-origin: bottom left; }

.aichat-closed #aichat-window { opacity: 0; pointer-events: none; transform: scale(0.8); }
.aichat-open #aichat-window { opacity: 1; pointer-events: all; transform: scale(1); }
.aichat-open #aichat-toggle-btn { opacity: 0; pointer-events: none; }

#aichat-header {
    background: var(--nid-primary);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#aichat-messages {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.aichat-message {
    max-width: 85%;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.aichat-user {
    align-self: flex-end;
}
.aichat-user .aichat-content {
    background: var(--user-bg);
    padding: 14px 18px;
    border-radius: 16px;
    border-bottom-right-radius: 4px;
    color: #111;
}

.aichat-ai {
    align-self: flex-start;
}
.aichat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    flex-shrink: 0;
}
.aichat-ai .aichat-content {
    background: var(--ai-bg);
    padding: 14px 18px;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    color: #333;
    border: 1px solid #eaeaea;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}

.aichat-ai p { margin: 0 0 12px 0; }
.aichat-ai p:last-child { margin: 0; }
.aichat-ai a { color: var(--nid-primary); font-weight: 500; text-decoration: none; }
.aichat-ai a:hover { text-decoration: underline; }
.aichat-ai pre { background: #2b2b2b; color: #f8f8f2; padding: 14px; border-radius: 8px; overflow-x: auto; margin: 12px 0;}
.aichat-ai code { background: rgba(0,0,0,0.05); padding: 3px 6px; border-radius: 4px; font-family: monospace; font-size: 0.9em; }
.aichat-ai ul, .aichat-ai ol { margin: 10px 0; padding-left: 25px; }

/* Quick Action Chips */
#aichat-quick-prompts-area::-webkit-scrollbar { height: 4px; }
#aichat-quick-prompts-area::-webkit-scrollbar-track { background: transparent; }
#aichat-quick-prompts-area::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

.aichat-quick-chip {
    background: #fff;
    border: 1px solid var(--nid-primary);
    color: var(--nid-primary);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    margin-right: 8px;
    margin-bottom: 5px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-block;
}
.aichat-quick-chip:hover {
    background: var(--nid-primary);
    color: white;
}

#aichat-input-area {
    display: flex;
    padding: 16px;
    border-top: 1px solid #eee;
    background: #fff;
    align-items: center;
}

#aichat-input {
    flex-grow: 1;
    border: 1px solid #ddd;
    border-radius: 24px;
    padding: 12px 18px;
    outline: none;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#aichat-input:focus { 
    border-color: var(--nid-primary); 
    box-shadow: 0 0 0 3px rgba(0,0,0,0.05);
}

#aichat-send-btn {
    background: var(--nid-primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 46px;
    height: 46px;
    margin-left: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s, transform 0.1s;
}

#aichat-send-btn:hover { opacity: 0.9; transform: translateY(-1px); }
#aichat-send-btn:active { transform: translateY(1px); }
#aichat-send-btn svg { width: 20px; height: 20px; }

#aichat-footer {
    text-align: center;
    padding: 10px 0 14px 0;
    font-size: 12px;
    color: #999;
    background: #fff;
}
#aichat-footer a { color: #888; text-decoration: none; font-weight: 600; transition: color 0.2s; }
#aichat-footer a:hover { color: var(--nid-primary); }

.aichat-dot {
    display: inline-block;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: #888;
    margin: 0 2px;
    animation: aichat-bounce 1.4s infinite ease-in-out both;
}
.aichat-dot:nth-child(1) { animation-delay: -0.32s; }
.aichat-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes aichat-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

@media (max-width: 480px) {
    #aichat-widget-container { bottom: 15px; }
    .aichat-pos-right { right: 15px; }
    .aichat-pos-left { left: 15px; }
    #aichat-window { width: calc(100vw - 30px); height: 80vh; bottom: 75px; }
}
