/* EventTrader NEXUS AI — Sticky Bottom Chat Bar
   Dark theme, blue accents (NO purple), bottom-docked layout.
   z-index: 9990 (below modals at 10000, above regular content) */

/* ========== Container & Collapsed Bar ========== */

#nexus-chat-widget {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9990;
    font-family: 'JetBrains Mono', 'Roboto', monospace;
    pointer-events: none;
}

#nexus-chat-widget * {
    box-sizing: border-box;
}

.nexus-hidden {
    display: none !important;
}

#nexus-chat-widget .nexus-bar {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    background: rgba(10, 14, 20, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(59, 130, 246, 0.2);
    transition: border-color 0.2s ease;
}

#nexus-chat-widget .nexus-bar:hover {
    border-top-color: rgba(59, 130, 246, 0.4);
}

/* NEXUS icon/badge */
#nexus-chat-widget .nexus-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(6, 182, 212, 0.2));
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #60a5fa;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.5px;
    cursor: pointer;
    user-select: none;
}

/* Input field in collapsed bar */
#nexus-chat-widget .nexus-input-wrap {
    flex: 1;
    position: relative;
}

#nexus-chat-widget .nexus-input {
    width: 100%;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #e2e8f0;
    font-family: inherit;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s ease, background 0.2s ease;
}

#nexus-chat-widget .nexus-input::placeholder {
    color: rgba(148, 163, 184, 0.6);
}

#nexus-chat-widget .nexus-input:focus {
    border-color: rgba(59, 130, 246, 0.5);
    background: rgba(255, 255, 255, 0.08);
}

/* Buttons */
#nexus-chat-widget .nexus-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    min-width: 32px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    padding: 0;
}

#nexus-chat-widget .nexus-btn:hover {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

#nexus-chat-widget .nexus-btn-send {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

#nexus-chat-widget .nexus-btn-send:hover {
    background: rgba(59, 130, 246, 0.35);
    color: #93c5fd;
}

#nexus-chat-widget .nexus-btn-send:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ========== Expanded Panel ========== */

#nexus-chat-widget .nexus-panel {
    pointer-events: auto;
    display: none;
    flex-direction: column;
    height: 400px;
    min-height: 200px;
    max-height: 80vh;
    background: rgba(10, 14, 20, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(59, 130, 246, 0.2);
}

/* Drag-to-resize handle at top of panel */
#nexus-chat-widget .nexus-resize-handle {
    height: 6px;
    cursor: ns-resize;
    background: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}
#nexus-chat-widget .nexus-resize-handle::after {
    content: '';
    width: 40px;
    height: 3px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.15);
    transition: background 0.2s;
}
#nexus-chat-widget .nexus-resize-handle:hover::after {
    background: rgba(59, 130, 246, 0.5);
}

#nexus-chat-widget.nexus-expanded .nexus-panel {
    display: flex;
}

/* Panel header */
#nexus-chat-widget .nexus-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    position: relative;
    z-index: 2;
}

#nexus-chat-widget .nexus-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #60a5fa;
    letter-spacing: 0.5px;
}

#nexus-chat-widget .nexus-panel-title .nexus-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #22d3ee;
    box-shadow: 0 0 6px rgba(34, 211, 238, 0.5);
}

#nexus-chat-widget .nexus-panel-actions {
    display: flex;
    gap: 4px;
}

/* Messages area */
#nexus-chat-widget .nexus-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#nexus-chat-widget .nexus-messages::-webkit-scrollbar {
    width: 4px;
}

#nexus-chat-widget .nexus-messages::-webkit-scrollbar-track {
    background: transparent;
}

#nexus-chat-widget .nexus-messages::-webkit-scrollbar-thumb {
    background: rgba(59, 130, 246, 0.3);
    border-radius: 2px;
}

/* Message bubbles */
#nexus-chat-widget .nexus-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

#nexus-chat-widget .nexus-msg-user {
    align-self: flex-end;
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.15);
    color: #e2e8f0;
}

#nexus-chat-widget .nexus-msg-assistant {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: #cbd5e1;
    position: relative;
}

/* Copy button */
#nexus-chat-widget .nexus-copy-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: #7B8794;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, color 0.15s;
}
#nexus-chat-widget .nexus-msg-assistant:hover .nexus-copy-btn {
    opacity: 1;
}
#nexus-chat-widget .nexus-copy-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #00cfff;
}
#nexus-chat-widget .nexus-copy-btn.nexus-copy-ok {
    color: #00ff88;
    opacity: 1;
}

/* Thinking indicator (shown before first text chunk) */
#nexus-chat-widget .nexus-thinking {
    display: inline-flex;
    align-items: center;
    gap: 1px;
    color: #60a5fa;
    font-size: 13px;
    font-style: italic;
    opacity: 0.85;
}
#nexus-chat-widget .nexus-thinking-text {
    margin-right: 1px;
}
#nexus-chat-widget .nexus-thinking-dots span {
    display: inline-block;
    animation: nexusThinkDot 1.4s infinite;
    opacity: 0;
}
#nexus-chat-widget .nexus-thinking-dots span:nth-child(1) { animation-delay: 0s; }
#nexus-chat-widget .nexus-thinking-dots span:nth-child(2) { animation-delay: 0.3s; }
#nexus-chat-widget .nexus-thinking-dots span:nth-child(3) { animation-delay: 0.6s; }
@keyframes nexusThinkDot {
    0%, 80%, 100% { opacity: 0; }
    40% { opacity: 1; }
}

/* Streaming indicator */
#nexus-chat-widget .nexus-msg-assistant .nexus-cursor {
    display: inline-block;
    width: 2px;
    height: 14px;
    background: #60a5fa;
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: nexusBlink 0.8s step-end infinite;
}

@keyframes nexusBlink {
    50% { opacity: 0; }
}

/* Typing indicator */
#nexus-chat-widget .nexus-typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    align-self: flex-start;
}

#nexus-chat-widget .nexus-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.5);
    animation: nexusTyping 1.2s infinite;
}

#nexus-chat-widget .nexus-typing-dot:nth-child(2) { animation-delay: 0.2s; }
#nexus-chat-widget .nexus-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes nexusTyping {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-4px); }
}

/* Welcome message */
#nexus-chat-widget .nexus-welcome {
    text-align: center;
    padding: 32px 20px;
    color: #64748b;
    font-size: 13px;
    line-height: 1.6;
}

#nexus-chat-widget .nexus-welcome strong {
    color: #60a5fa;
    font-weight: 600;
}

#nexus-chat-widget .nexus-welcome-billing {
    margin-top: 12px;
    font-size: 11px;
    color: #475569;
    line-height: 1.4;
}

/* Markdown support inside messages */
#nexus-chat-widget .nexus-msg-assistant strong {
    color: #93c5fd;
    font-weight: 600;
}

#nexus-chat-widget .nexus-msg-assistant code {
    background: rgba(255, 255, 255, 0.08);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 12px;
    font-family: 'JetBrains Mono', monospace;
}

#nexus-chat-widget .nexus-msg-assistant pre {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 10px 12px;
    overflow-x: auto;
    margin: 8px 0;
    font-size: 12px;
}

#nexus-chat-widget .nexus-msg-assistant pre code {
    background: none;
    padding: 0;
}

#nexus-chat-widget .nexus-msg-assistant ul,
#nexus-chat-widget .nexus-msg-assistant ol {
    padding-left: 20px;
    margin: 6px 0;
}

#nexus-chat-widget .nexus-msg-assistant h3,
#nexus-chat-widget .nexus-msg-assistant h4 {
    color: #93c5fd;
    margin: 8px 0 4px;
    font-size: 13px;
}

#nexus-chat-widget .nexus-msg-assistant table {
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 12px;
    width: 100%;
}

#nexus-chat-widget .nexus-msg-assistant th,
#nexus-chat-widget .nexus-msg-assistant td {
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 4px 8px;
    text-align: left;
}

#nexus-chat-widget .nexus-msg-assistant th {
    background: rgba(59, 130, 246, 0.1);
    color: #93c5fd;
}

/* ========== Mobile Responsive ========== */

@media (max-width: 768px) {
    #nexus-chat-widget .nexus-panel {
        height: 60vh;
    }

    #nexus-chat-widget .nexus-msg {
        max-width: 92%;
    }

    #nexus-chat-widget .nexus-bar {
        padding: 6px 10px;
        padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
    }

    #nexus-chat-widget .nexus-input {
        font-size: 16px; /* Prevent iOS zoom */
    }
}

/* Landscape mobile: minimize nexus bar to free vertical space */
@media (max-height: 500px) and (orientation: landscape) {
    #nexus-chat-widget .nexus-bar {
        padding: 4px 10px;
        padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px));
    }

    #nexus-chat-widget .nexus-bar .nexus-icon,
    #nexus-chat-widget .nexus-bar .nexus-actions {
        display: none;
    }

    #nexus-chat-widget .nexus-input {
        font-size: 14px;
        padding: 4px 8px;
    }

    body.nexus-active {
        padding-bottom: 40px;
    }
}

/* Hide on /chat page (full chat already there) */
body.page-chat #nexus-chat-widget {
    display: none !important;
}

/* Extra bottom padding so scrollable content clears nexus bar.
   The collapsed nexus bar is ~40-50px, so all pages need clearance.
   Pages with footer-bar already have 80px padding — this is a safe minimum. */
body.nexus-active {
    padding-bottom: 60px;
}

body.nexus-active.nexus-panel-open {
    padding-bottom: 400px; /* 400px panel */
}

@media (max-width: 768px) {
    body.nexus-active.nexus-panel-open {
        padding-bottom: 60vh;
    }
}

/* ========== Light Theme ========== */
[data-theme="light"] #nexus-chat-widget .nexus-bar {
    background: rgba(255, 255, 255, 0.97);
    border-top: 1px solid rgba(0, 80, 160, 0.08);
    box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.04);
}
[data-theme="light"] #nexus-chat-widget .nexus-bar:hover {
    border-top-color: rgba(0, 145, 213, 0.25);
}
[data-theme="light"] #nexus-chat-widget .nexus-badge {
    background: rgba(0, 145, 213, 0.08);
    border-color: rgba(0, 145, 213, 0.20);
    color: #0091d5;
}
[data-theme="light"] #nexus-chat-widget .nexus-input {
    background: rgba(0, 80, 160, 0.04);
    border-color: rgba(0, 80, 160, 0.10);
    color: #0f172a;
}
[data-theme="light"] #nexus-chat-widget .nexus-input::placeholder {
    color: #94a3b8;
}
[data-theme="light"] #nexus-chat-widget .nexus-input:focus {
    border-color: rgba(0, 145, 213, 0.30);
    background: rgba(255, 255, 255, 0.8);
}
[data-theme="light"] #nexus-chat-widget .nexus-send {
    color: #475569;
}
[data-theme="light"] #nexus-chat-widget .nexus-send:hover {
    color: #0091d5;
}
[data-theme="light"] #nexus-chat-widget .nexus-panel {
    background: rgba(255, 255, 255, 0.98);
    border-top: 1px solid rgba(0, 80, 160, 0.08);
}
[data-theme="light"] #nexus-chat-widget .nexus-message.assistant {
    background: rgba(0, 145, 213, 0.05);
    border-color: rgba(0, 145, 213, 0.10);
    color: #0f172a;
}
[data-theme="light"] #nexus-chat-widget .nexus-message.user {
    background: rgba(0, 80, 160, 0.04);
    color: #0f172a;
}

/* ========== Token Launch Confirmation Card ========== */

.nexus-launch-card {
    margin: 8px 12px;
    padding: 12px 14px;
    background: rgba(17, 26, 40, 0.9);
    border: 1px solid rgba(0, 207, 255, 0.25);
    border-radius: 10px;
    font-family: 'JetBrains Mono', 'Roboto', monospace;
    font-size: 12px;
}

.nexus-launch-header {
    font-size: 13px;
    font-weight: 600;
    color: #00cfff;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(0, 207, 255, 0.15);
}

.nexus-launch-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

.nexus-launch-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 0;
}

.nexus-launch-label {
    color: #9DA3A8;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nexus-launch-value {
    color: #FFFFFF;
    font-weight: 500;
}

.nexus-launch-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.nexus-launch-confirm {
    padding: 6px 16px;
    background: rgba(0, 207, 255, 0.15);
    border: 1px solid rgba(0, 207, 255, 0.4);
    border-radius: 6px;
    color: #00cfff;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.nexus-launch-confirm:hover {
    background: rgba(0, 207, 255, 0.25);
    border-color: #00cfff;
}

.nexus-launch-cancel {
    padding: 6px 16px;
    background: transparent;
    border: 1px solid rgba(157, 163, 168, 0.3);
    border-radius: 6px;
    color: #9DA3A8;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.nexus-launch-cancel:hover {
    border-color: rgba(255, 68, 68, 0.5);
    color: #ff4444;
}

[data-theme="light"] .nexus-launch-card {
    background: rgba(248, 250, 252, 0.95);
    border-color: rgba(0, 145, 213, 0.2);
}
[data-theme="light"] .nexus-launch-header {
    color: #0070b0;
    border-bottom-color: rgba(0, 145, 213, 0.1);
}
[data-theme="light"] .nexus-launch-label { color: #7B8794; }
[data-theme="light"] .nexus-launch-value { color: #0f172a; }
[data-theme="light"] .nexus-launch-confirm {
    background: rgba(0, 145, 213, 0.08);
    border-color: rgba(0, 145, 213, 0.3);
    color: #0070b0;
}
[data-theme="light"] .nexus-launch-cancel {
    color: #7B8794;
    border-color: rgba(107, 114, 128, 0.3);
}

/* ========== Exchange Connection Card ========== */

.nexus-exchange-card {
    margin: 8px 0;
    padding: 12px 14px;
    background: rgba(17, 26, 40, 0.9);
    border: 1px solid rgba(0, 207, 255, 0.25);
    border-radius: 10px;
    font-family: 'JetBrains Mono', 'Roboto', monospace;
    font-size: 12px;
    max-width: 100%;
    width: 100%;
}

.nexus-exchange-header {
    font-size: 13px;
    font-weight: 600;
    color: #00cfff;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(0, 207, 255, 0.15);
}

.nexus-exchange-warning {
    color: #ff9900;
    font-size: 11px;
    margin-bottom: 8px;
    padding: 6px 8px;
    background: rgba(255, 153, 0, 0.08);
    border: 1px solid rgba(255, 153, 0, 0.2);
    border-radius: 6px;
}

/* Exchange picker grid */
.nexus-exchange-picker {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-bottom: 8px;
}

.nexus-exchange-pick-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 10px 6px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #e2e8f0;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}

.nexus-exchange-pick-btn:hover {
    background: rgba(0, 207, 255, 0.08);
    border-color: rgba(0, 207, 255, 0.3);
}

.nexus-exchange-pick-btn.nexus-exchange-coming-soon {
    opacity: 0.55;
}

.nexus-exchange-pick-name {
    font-weight: 600;
    font-size: 12px;
}

.nexus-exchange-pick-type {
    font-size: 10px;
    color: #7B8794;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nexus-exchange-pick-soon {
    position: absolute;
    top: 3px;
    right: 4px;
    font-size: 10px;
    color: #ff9900;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* Setup instructions */
.nexus-exchange-steps {
    margin-bottom: 10px;
    max-height: 120px;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 6px;
    padding: 6px 4px 6px 0;
}

.nexus-exchange-steps ol {
    margin: 0;
    padding-left: 22px;
    color: #9DA3A8;
    font-size: 11px;
    line-height: 1.6;
}

.nexus-exchange-steps li {
    margin-bottom: 2px;
}

.nexus-exchange-setup-link {
    display: inline-block;
    margin: 4px 0 6px;
    color: #00cfff;
    font-size: 11px;
    text-decoration: none;
}

.nexus-exchange-setup-link:hover {
    text-decoration: underline;
}

/* Security notice */
.nexus-exchange-security {
    color: #00ff88;
    font-size: 10px;
    margin-bottom: 6px;
    padding: 4px 8px;
    background: rgba(0, 255, 136, 0.06);
    border: 1px solid rgba(0, 255, 136, 0.15);
    border-radius: 6px;
}

/* Form fields */
.nexus-exchange-fields {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 6px;
}

.nexus-exchange-field label {
    display: block;
    font-size: 10px;
    color: #9DA3A8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.nexus-exchange-field input[type="password"],
.nexus-exchange-field input[type="text"] {
    width: 100%;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    color: #e2e8f0;
    font-family: inherit;
    font-size: 12px;
    outline: none;
    transition: border-color 0.2s;
}

.nexus-exchange-field input[type="password"]:focus,
.nexus-exchange-field input[type="text"]:focus {
    border-color: rgba(0, 207, 255, 0.4);
}

.nexus-exchange-field input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.nexus-exchange-checkbox label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #9DA3A8;
    text-transform: none;
    letter-spacing: 0;
    cursor: pointer;
}

.nexus-exchange-checkbox input[type="checkbox"] {
    accent-color: #00cfff;
    width: 14px;
    height: 14px;
}

/* Action buttons */
.nexus-exchange-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
}

.nexus-exchange-submit {
    padding: 6px 16px;
    background: rgba(0, 207, 255, 0.15);
    border: 1px solid rgba(0, 207, 255, 0.4);
    border-radius: 6px;
    color: #00cfff;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.nexus-exchange-submit:hover {
    background: rgba(0, 207, 255, 0.25);
    border-color: #00cfff;
}

.nexus-exchange-cancel-btn {
    padding: 6px 16px;
    background: transparent;
    border: 1px solid rgba(157, 163, 168, 0.3);
    border-radius: 6px;
    color: #9DA3A8;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.nexus-exchange-cancel-btn:hover {
    border-color: rgba(255, 68, 68, 0.5);
    color: #ff4444;
}

.nexus-exchange-status {
    padding: 8px 0;
    font-size: 12px;
}

/* Mobile: 2-column picker grid */
@media (max-width: 480px) {
    .nexus-exchange-picker {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Light theme overrides */
[data-theme="light"] .nexus-exchange-card {
    background: rgba(248, 250, 252, 0.95);
    border-color: rgba(0, 145, 213, 0.2);
}
[data-theme="light"] .nexus-exchange-header {
    color: #0070b0;
    border-bottom-color: rgba(0, 145, 213, 0.1);
}
[data-theme="light"] .nexus-exchange-pick-btn {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
    color: #0f172a;
}
[data-theme="light"] .nexus-exchange-pick-btn:hover {
    background: rgba(0, 145, 213, 0.06);
    border-color: rgba(0, 145, 213, 0.3);
}
[data-theme="light"] .nexus-exchange-steps ol { color: #7B8794; }
[data-theme="light"] .nexus-exchange-setup-link { color: #0070b0; }
[data-theme="light"] .nexus-exchange-security {
    color: #059669;
    background: rgba(5, 150, 105, 0.06);
    border-color: rgba(5, 150, 105, 0.15);
}
[data-theme="light"] .nexus-exchange-field label { color: #7B8794; }
[data-theme="light"] .nexus-exchange-field input[type="password"],
[data-theme="light"] .nexus-exchange-field input[type="text"] {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.12);
    color: #0f172a;
}
[data-theme="light"] .nexus-exchange-submit {
    background: rgba(0, 145, 213, 0.08);
    border-color: rgba(0, 145, 213, 0.3);
    color: #0070b0;
}
[data-theme="light"] .nexus-exchange-cancel-btn {
    color: #7B8794;
    border-color: rgba(107, 114, 128, 0.3);
}
[data-theme="light"] .nexus-exchange-warning {
    color: #00cfff;
    background: rgba(0, 207, 255, 0.06);
    border-color: rgba(0, 207, 255, 0.15);
}

/* ========== Chat billing cost label ========== */
.nexus-msg-cost {
    font-size: 11px;
    color: #7B8794;
    margin-top: 6px;
    text-align: right;
    opacity: 0.85;
    cursor: default;
    background: rgba(255, 68, 68, 0.08);
    border-radius: 4px;
    padding: 2px 6px;
}
.nexus-billing-warning {
    font-size: 11px;
    color: #ff9900;
    margin-top: 4px;
    text-align: right;
}
[data-theme="light"] .nexus-msg-cost {
    color: #7b8a99;
}
[data-theme="light"] .nexus-billing-warning {
    color: #00cfff;
}

/* ========== Media Attachments ========== */

#nexus-chat-widget .nexus-btn-attach {
    flex-shrink: 0;
    color: #7B8794;
    transition: color 0.15s;
}
#nexus-chat-widget .nexus-btn-attach:hover {
    color: #00cfff;
}

#nexus-chat-widget .nexus-attachments-preview {
    display: none;
    pointer-events: auto;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 16px 0;
    background: rgba(10, 14, 20, 0.97);
    border-top: 1px solid rgba(0, 150, 255, 0.1);
}

#nexus-chat-widget .nexus-att-thumb {
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(0, 207, 255, 0.2);
    background: rgba(17, 26, 40, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

#nexus-chat-widget .nexus-att-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#nexus-chat-widget .nexus-att-icon {
    font-size: 20px;
    line-height: 1;
}

#nexus-chat-widget .nexus-att-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    font-size: 10px;
    padding: 1px 2px;
    background: rgba(0, 0, 0, 0.7);
    color: #9DA3A8;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#nexus-chat-widget .nexus-att-remove {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ff4444;
    color: #fff;
    border: none;
    font-size: 11px;
    line-height: 16px;
    text-align: center;
    cursor: pointer;
    padding: 0;
    opacity: 0;
    transition: opacity 0.15s;
}

#nexus-chat-widget .nexus-att-thumb:hover .nexus-att-remove {
    opacity: 1;
}

/* Drag-and-drop overlay */
#nexus-chat-widget .nexus-messages.nexus-dragover {
    outline: 2px dashed #00cfff;
    outline-offset: -4px;
    background: rgba(0, 207, 255, 0.03);
}

/* Image thumbnails in user messages */
#nexus-chat-widget .nexus-msg-images {
    display: flex;
    gap: 4px;
    margin-top: 6px;
    flex-wrap: wrap;
}

#nexus-chat-widget .nexus-msg-images img {
    max-width: 80px;
    max-height: 60px;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid rgba(0, 150, 255, 0.15);
}

#nexus-chat-widget .nexus-msg-video-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: 10px;
    background: rgba(0, 207, 255, 0.1);
    border: 1px solid rgba(0, 207, 255, 0.2);
    border-radius: 4px;
    color: #00cfff;
}

/* Light mode */
[data-theme="light"] #nexus-chat-widget .nexus-attachments-preview {
    background: rgba(255, 255, 255, 0.97);
    border-top-color: rgba(0, 0, 0, 0.08);
}
[data-theme="light"] #nexus-chat-widget .nexus-att-thumb {
    border-color: rgba(0, 0, 0, 0.12);
    background: rgba(245, 245, 245, 0.8);
}
[data-theme="light"] #nexus-chat-widget .nexus-btn-attach {
    color: #7b8a99;
}
[data-theme="light"] #nexus-chat-widget .nexus-btn-attach:hover {
    color: #0088cc;
}

/* Voice input mic button — hidden by default, shown via JS when speech API available */
#nexus-chat-widget .nexus-btn-mic {
    display: none;
    flex-shrink: 0;
    color: #7B8794;
    transition: color 0.15s;
}
#nexus-chat-widget .nexus-btn-mic:hover {
    color: #00cfff;
}
#nexus-chat-widget .nexus-btn-mic.nexus-mic-active {
    color: #ff4444;
    animation: nexusMicPulse 1.2s ease-in-out infinite;
}
@keyframes nexusMicPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
[data-theme="light"] #nexus-chat-widget .nexus-btn-mic {
    color: #7b8a99;
}
[data-theme="light"] #nexus-chat-widget .nexus-btn-mic:hover {
    color: #0088cc;
}
[data-theme="light"] #nexus-chat-widget .nexus-btn-mic.nexus-mic-active {
    color: #ff4444;
}
@media (max-width: 768px) {
    #nexus-chat-widget .nexus-btn-mic {
        width: 44px;
        height: 44px;
        min-width: 44px;
    }
}

/* ── Pinned Sidebar Mode ─────────────────────────────────────── */
body.nexus-sidebar-pinned {
    margin-right: 380px;
    transition: margin-right 0.3s ease;
}

/* EVE-14117: Pinned chat positioned below header with overflow clipping
   to prevent any child elements from overlapping the fixed header */
#nexus-chat-widget.nexus-pinned {
    position: fixed;
    right: 0;
    top: 56px; /* below sticky header (~56px tall) */
    bottom: 0;
    left: auto;
    width: 380px;
    z-index: 900; /* Well below header (z-index: 1000) to prevent overlap */
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Clip any child elements that extend beyond bounds */
}

#nexus-chat-widget.nexus-pinned .nexus-panel {
    display: flex !important;
    flex: 1;
    height: auto;
    max-height: none;
    border-radius: 0;
    border-right: none;
    border-top: none;
    border-bottom: none;
}

#nexus-chat-widget.nexus-pinned .nexus-bar {
    border-radius: 0;
    border-right: none;
    border-bottom: none;
}

#nexus-chat-widget.nexus-pinned .nexus-resize-handle {
    /* Horizontal resize on left edge */
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    height: auto;
    cursor: ew-resize;
    z-index: 1;
}

/* ── Pinned Left Sidebar Mode ─────────────────────────────── */
body.nexus-sidebar-pinned-left {
    margin-left: 380px;
    margin-right: 0;
    transition: margin-left 0.3s ease;
}

#nexus-chat-widget.nexus-pinned.nexus-pinned-left {
    right: auto;
    left: 0;
}

#nexus-chat-widget.nexus-pinned.nexus-pinned-left .nexus-resize-handle {
    left: auto;
    right: 0;
}

#nexus-chat-widget.nexus-pinned.nexus-pinned-left .nexus-panel {
    border-left: none;
}

#nexus-chat-widget.nexus-pinned.nexus-pinned-left .nexus-bar {
    border-left: none;
}

/* Hide pin on mobile — !important overrides inline styles set by JS applyPinState() */
@media (max-width: 768px) {
    .nexus-btn-pin { display: none !important; }
    body.nexus-sidebar-pinned { margin-right: 0 !important; }
    body.nexus-sidebar-pinned-left { margin-left: 0 !important; }
    #nexus-chat-widget.nexus-pinned {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        width: 100%;
    }
    /* Mobile touch targets — min 44x44px per Apple HIG */
    #nexus-chat-widget .nexus-btn {
        min-width: 44px;
        min-height: 44px;
        width: 44px;
        height: 44px;
    }
}
