/* ═══════════════════════════════════════════════════════
   CHAT WIDGET — Neural Studio
═══════════════════════════════════════════════════════ */

#ns-chat-widget {
    position: fixed;
    bottom: 55px;
    right: 70px;
    z-index: 9999;
    font-family: Arial, sans-serif;
}

/* Toggle button */
.ns-chat-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #1a1a1a;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    transition: transform 0.3s ease, background 0.3s ease;
    position: relative;
}

body.dark .ns-chat-toggle {
    background: rgba(168, 212, 220, 0.85);
}

.ns-chat-toggle:hover {
    transform: scale(1.08);
}

.ns-chat-icon,
.ns-chat-close-icon {
    position: absolute;
    font-size: 22px;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.ns-chat-icon { opacity: 1; transform: scale(1); }
.ns-chat-close-icon { opacity: 0; transform: scale(0.5); color: white; font-size: 18px; }

.ns-chat-toggle.open .ns-chat-icon { opacity: 0; transform: scale(0.5); }
.ns-chat-toggle.open .ns-chat-close-icon { opacity: 1; transform: scale(1); }

/* Chat window */
.ns-chat-window {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 360px;
    max-height: 500px;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    background: #ffffff;
    border: 1px solid rgba(0,0,0,0.10);
    box-shadow: 0 8px 40px rgba(0,0,0,0.12);
}

body.dark .ns-chat-window {
    background: #0a1020;
    border-color: rgba(255,255,255,0.10);
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}

.ns-chat-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Header */
.ns-chat-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    background: #fafafa;
}

body.dark .ns-chat-header {
    background: #0d1525;
    border-bottom-color: rgba(255,255,255,0.08);
}

.ns-chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ns-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #1a1a1a;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1px;
}

body.dark .ns-chat-avatar {
    background: rgba(168, 212, 220, 0.85);
    color: #060E1C;
}

.ns-chat-header-name {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
}

body.dark .ns-chat-header-name {
    color: #ffffff;
}

.ns-chat-header-status {
    font-size: 12px;
    color: #22c55e;
}

.ns-chat-minimize {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: rgba(0,0,0,0.4);
    padding: 10px 14px;
    min-height: 44px;
    min-width: 44px;
}

body.dark .ns-chat-minimize {
    color: rgba(255,255,255,0.4);
}

/* Messages */
.ns-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 280px;
    max-height: 340px;
}

.ns-chat-msg p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    padding: 10px 14px;
    border-radius: 16px;
    max-width: 85%;
    word-wrap: break-word;
}

.ns-chat-bot {
    align-self: flex-start;
}

.ns-chat-bot p {
    background: rgba(0,0,0,0.05);
    color: #1a1a1a;
    border-bottom-left-radius: 4px;
}

body.dark .ns-chat-bot p {
    background: rgba(255,255,255,0.08);
    color: #CBD5E1;
}

.ns-chat-user {
    align-self: flex-end;
}

.ns-chat-user p {
    background: #1a1a1a;
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

body.dark .ns-chat-user p {
    background: rgba(168, 212, 220, 0.85);
    color: #060E1C;
}

/* Typing indicator */
.ns-chat-typing p {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 12px 16px;
}

.ns-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(0,0,0,0.3);
    animation: nsDotPulse 1.4s ease-in-out infinite;
}

body.dark .ns-dot {
    background: rgba(255,255,255,0.3);
}

.ns-dot:nth-child(2) { animation-delay: 0.2s; }
.ns-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes nsDotPulse {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

/* Input area */
.ns-chat-input-area {
    display: flex;
    padding: 12px 16px;
    gap: 8px;
    border-top: 1px solid rgba(0,0,0,0.08);
    background: #fafafa;
}

body.dark .ns-chat-input-area {
    background: #0d1525;
    border-top-color: rgba(255,255,255,0.08);
}

#ns-chat-input {
    flex: 1;
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    outline: none;
    background: #ffffff;
    color: #1a1a1a;
    transition: border-color 0.2s ease;
}

body.dark #ns-chat-input {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.12);
    color: #CBD5E1;
}

#ns-chat-input:focus {
    border-color: rgba(0,0,0,0.3);
}

body.dark #ns-chat-input:focus {
    border-color: rgba(168, 212, 220, 0.4);
}

#ns-chat-input::placeholder {
    color: rgba(0,0,0,0.4);
}

body.dark #ns-chat-input::placeholder {
    color: rgba(255,255,255,0.3);
}

#ns-chat-send {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: none;
    background: #1a1a1a;
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

body.dark #ns-chat-send {
    background: rgba(168, 212, 220, 0.85);
    color: #060E1C;
}

#ns-chat-send:hover {
    background: #333;
}

body.dark #ns-chat-send:hover {
    background: rgba(168, 212, 220, 1);
}

/* Mobile */
@media (max-width: 768px) {
    .ns-chat-window {
        width: calc(100vw - 32px);
        right: -8px;
        bottom: 68px;
        max-height: 420px;
    }

    #ns-chat-widget {
        bottom: 16px;
        right: 16px;
    }
}
