/* ====== CHAT WIDGET STYLES (v2 — Kodee-Inspired Light Theme) ====== */

:root {
    --bg-page: #f6f5fb;
    --bg-card: #ffffff;
    --bg-subtle: #f8f8fb;
    --bg-input: #ffffff;
    --bg-tab: #ffffff;
    --bg-tab-active: #efeaff;
    --bg-user-bubble: #f1f0f7;
    --border-soft: #ececf2;
    --border-tab: #e6e4ee;
    --border-input: #d9d6e3;
    --text-primary: #1a1a23;
    --text-secondary: #6a6a78;
    --text-tertiary: #9a98a8;
    --text-link: #6a4dff;
    --accent: #6a4dff;
    --accent-hover: #5a3ee6;
    --accent-soft: #efeaff;
    --check-done: #1a1a23;
    --check-active: #6a4dff;
    --font-sans: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
    --fs-xs: 12px;
    --fs-sm: 14px;
    --fs-base: 15px;
    --fs-lg: 17px;
    --fs-xl: 20px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --shadow-card: 0 12px 40px rgba(38, 22, 96, 0.12);
    --shadow-launcher: 0 8px 24px rgba(106, 77, 255, 0.32);
}

/* ── Launcher Button ── */
.nexora-launcher {
    position: fixed; bottom: 24px; right: 24px;
    display: flex; align-items: center; gap: 10px;
    padding: 14px 22px; border-radius: 50px;
    background: var(--accent); color: #fff;
    border: none; cursor: pointer; z-index: 9998;
    font-family: var(--font-sans); font-size: var(--fs-sm); font-weight: 600;
    box-shadow: var(--shadow-launcher);
    transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
}
.nexora-launcher:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(106,77,255,0.4);
}
.nexora-launcher.is-hidden { display: none; }
.nexora-launcher-icon { flex-shrink: 0; }

/* ── Chat Panel ── */
.nexora-panel {
    position: fixed; bottom: 24px; right: 24px;
    width: 420px; height: 620px;
    display: flex; flex-direction: column;
    background: var(--bg-card); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-soft);
    z-index: 9999; overflow: hidden;
    opacity: 0; transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
}
.nexora-panel.is-open {
    opacity: 1; transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ── Header ── */
.nexora-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-soft);
    background: var(--bg-card);
}
.nexora-header-left {
    display: flex; align-items: center; gap: 10px;
}
.nexora-header-mark {
    font-size: 20px;
    background: linear-gradient(135deg, #6a4dff, #9b7aff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.nexora-header-title {
    font-size: var(--fs-base); font-weight: 600; color: var(--text-primary);
}
.nexora-header-actions { display: flex; gap: 4px; }
.nexora-icon-btn {
    width: 34px; height: 34px; border-radius: var(--radius-sm);
    border: none; background: transparent; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-secondary); transition: all 0.2s;
}
.nexora-icon-btn:hover {
    background: var(--accent-soft); color: var(--accent);
}

/* ── Body ── */
.nexora-body {
    flex: 1; overflow-y: auto; overflow-x: hidden;
    scroll-behavior: smooth;
}

/* ── Welcome State ── */
.nx-welcome {
    display: flex; flex-direction: column; align-items: center;
    padding: 36px 24px 24px; text-align: center;
}
.nx-welcome-logo {
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--accent-soft);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 16px;
}
.nx-welcome-mark {
    font-size: 28px;
    background: linear-gradient(135deg, #6a4dff, #9b7aff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.nx-welcome-title {
    font-size: var(--fs-xl); font-weight: 700; color: var(--text-primary);
    margin-bottom: 6px;
}
.nx-welcome-subtitle {
    font-size: var(--fs-sm); color: var(--text-secondary); margin-bottom: 24px;
}

/* ── Suggestion list ── */
.nx-suggestion-list {
    list-style: none; width: 100%; margin-bottom: 20px;
    display: flex; flex-direction: column; gap: 8px;
}
.nx-suggestion-list li button {
    display: flex; align-items: center; gap: 8px;
    width: 100%; padding: 12px 16px; border-radius: var(--radius-md);
    border: 1px solid var(--border-soft); background: var(--bg-card);
    cursor: pointer; font-family: var(--font-sans);
    font-size: var(--fs-sm); color: var(--text-primary); text-align: left;
    transition: all 0.2s;
}
.nx-suggestion-list li button:hover {
    border-color: var(--accent); background: var(--accent-soft);
    color: var(--accent);
}
.nx-suggestion-list li button::before {
    content: '↗'; font-size: 14px; color: var(--accent); flex-shrink: 0;
}

/* ── Tabs (v3 — horizontal scroll) ── */
.nx-tabs-wrap {
    position: relative;
    width: 100%;
}

.nx-tabs-wrap::after {
    content: "";
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 24px;
    background: linear-gradient(to right, transparent, var(--bg-card));
    pointer-events: none;
}

.nx-tabs {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 16px;
    margin: 0 -16px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
}

.nx-tabs::-webkit-scrollbar {
    display: none;
}

.nx-tab {
    flex: 0 0 auto;
    padding: 8px 16px;
    border: 1px solid var(--border-tab);
    background: var(--bg-tab);
    border-radius: 999px;
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    scroll-snap-align: start;
    transition: all 0.15s ease;
    font-family: var(--font-sans);
    font-weight: 500;
}

.nx-tab.is-active {
    background: var(--bg-tab-active);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 600;
}

.nx-tab:hover:not(.is-active) {
    border-color: var(--accent);
    color: var(--text-primary);
}

/* ── Conversation ── */
.nx-conversation {
    padding: 16px 0;
}
.nx-messages {
    display: flex; flex-direction: column; gap: 16px;
    padding: 0 16px;
}

/* ── User bubble ── */
.nx-user-msg {
    align-self: flex-end; max-width: 85%;
    padding: 12px 16px; border-radius: var(--radius-md) var(--radius-md) 4px var(--radius-md);
    background: var(--accent); color: #fff;
    font-size: var(--fs-sm); line-height: 1.5;
    word-wrap: break-word;
}

/* ── Assistant block ── */
.nx-assistant-block {
    display: flex; flex-direction: column; gap: 8px;
    max-width: 95%;
}
.nx-assistant-header {
    display: flex; align-items: center; gap: 8px;
    font-size: var(--fs-xs); color: var(--text-secondary); font-weight: 500;
}
.nx-assistant-mark {
    font-size: 14px;
    background: linear-gradient(135deg, #6a4dff, #9b7aff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ── Chain-of-Thought ── */
.nx-cot {
    list-style: none; display: flex; flex-direction: column; gap: 2px;
    padding: 12px 16px; border-radius: var(--radius-md);
    background: var(--bg-subtle); border: 1px solid var(--border-soft);
}
.nx-cot-step { border-radius: 6px; }
.nx-cot-row {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 8px; width: 100%; border: none;
    background: transparent; cursor: default;
    font-family: var(--font-sans); font-size: var(--fs-sm); text-align: left;
}
.nx-cot-row.has-debug { cursor: pointer; }
.nx-cot-row.has-debug:hover { background: rgba(106,77,255,0.05); border-radius: 6px; }

.nx-cot-mark {
    width: 20px; height: 20px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; flex-shrink: 0;
    border: 2px solid var(--border-soft); color: var(--text-tertiary);
    transition: all 0.3s;
}
.nx-cot-step[data-status="active"] .nx-cot-mark {
    border-color: var(--accent); color: var(--accent);
    animation: cot-pulse 1.2s ease-in-out infinite;
}
.nx-cot-step[data-status="done"] .nx-cot-mark {
    border-color: var(--check-done); background: var(--check-done);
    color: #fff;
}
.nx-cot-step[data-status="skipped"] .nx-cot-mark {
    border-color: var(--border-soft); color: var(--text-tertiary);
    opacity: 0.5;
}
@keyframes cot-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(106,77,255,0.3); }
    50% { box-shadow: 0 0 0 6px rgba(106,77,255,0); }
}

.nx-cot-label {
    flex: 1; color: var(--text-primary); font-weight: 500;
}
.nx-cot-step[data-status="skipped"] .nx-cot-label {
    color: var(--text-tertiary); text-decoration: line-through; opacity: 0.6;
}

.nx-cot-toggle {
    font-size: 12px; color: var(--text-tertiary);
    transition: transform 0.2s;
}
.nx-cot-toggle.is-expanded { transform: rotate(180deg); }

/* Debug panel */
.nx-cot-debug {
    padding: 8px 12px; margin: 0 8px 8px 38px;
    border-radius: 6px; background: #fff;
    border: 1px solid var(--border-soft);
    font-size: var(--fs-xs); font-family: 'Courier New', monospace;
    line-height: 1.6; color: var(--text-secondary);
    overflow-x: auto;
    animation: fade-in 0.2s ease;
}
.nx-cot-debug strong {
    color: var(--text-primary); font-weight: 600;
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Markdown Response ── */
.nx-response {
    padding: 4px 0;
    font-size: var(--fs-sm); line-height: 1.7; color: var(--text-primary);
}
.nx-response h1,.nx-response h2,.nx-response h3 {
    font-weight: 600; color: var(--text-primary); margin: 12px 0 6px;
}
.nx-response h1 { font-size: var(--fs-lg); }
.nx-response h2 { font-size: var(--fs-base); }
.nx-response h3 { font-size: var(--fs-sm); font-weight: 600; }
.nx-response p { margin: 6px 0; }
.nx-response ul,.nx-response ol {
    margin: 6px 0; padding-left: 20px;
}
.nx-response li { margin: 3px 0; }
.nx-response a {
    color: var(--text-link); text-decoration: underline;
    text-decoration-thickness: 1px; text-underline-offset: 2px;
}
.nx-response a:hover { text-decoration-thickness: 2px; }
.nx-response img {
    max-width: 100%; border-radius: var(--radius-md);
    margin: 10px 0; border: 1px solid var(--border-soft);
}
.nx-response table {
    width: 100%; border-collapse: collapse; margin: 10px 0;
    font-size: var(--fs-xs);
}
.nx-response th,.nx-response td {
    padding: 8px 12px; border: 1px solid var(--border-soft); text-align: left;
}
.nx-response th {
    background: var(--bg-subtle); font-weight: 600;
}
.nx-response code {
    background: var(--bg-subtle); padding: 2px 6px;
    border-radius: 4px; font-size: var(--fs-xs);
}
.nx-response pre {
    background: var(--bg-subtle); padding: 12px;
    border-radius: var(--radius-sm); overflow-x: auto;
    margin: 8px 0;
}
.nx-response strong { font-weight: 600; }
.nx-response blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 12px; margin: 8px 0;
    color: var(--text-secondary);
}

/* ── Feedback ── */
.nx-feedback {
    display: flex; gap: 6px; padding: 4px 0;
}
.nx-feedback button {
    width: 32px; height: 32px; border-radius: var(--radius-sm);
    border: 1px solid var(--border-soft); background: var(--bg-card);
    cursor: pointer; font-size: 15px;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.nx-feedback button:hover {
    border-color: var(--accent); background: var(--accent-soft);
}
.nx-feedback button.is-selected {
    border-color: var(--accent); background: var(--accent-soft);
}

/* ── Inline suggestions (after response) ── */
.nx-suggestions {
    padding: 8px 0;
}
.nx-suggestions-label {
    font-size: var(--fs-xs); color: var(--text-tertiary);
    margin-bottom: 6px; font-weight: 500;
}
.nx-suggestions ul {
    list-style: none; display: flex; flex-direction: column; gap: 4px;
}
.nx-suggestion {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 12px; border-radius: var(--radius-sm);
    border: 1px solid var(--border-soft); background: var(--bg-card);
    cursor: pointer; font-family: var(--font-sans);
    font-size: var(--fs-xs); color: var(--text-primary); text-align: left;
    width: 100%; transition: all 0.2s;
}
.nx-suggestion:hover {
    border-color: var(--accent); background: var(--accent-soft);
    color: var(--accent);
}
.nx-suggestion::before {
    content: '↗'; font-size: 12px; color: var(--accent); flex-shrink: 0;
}

/* ── Footer / Input ── */
.nexora-footer {
    padding: 12px 16px 12px;
    border-top: 1px solid var(--border-soft);
    background: var(--bg-card);
}
.nx-input-wrap {
    display: flex; align-items: flex-end; gap: 8px;
    background: var(--bg-input); border: 1.5px solid var(--border-input);
    border-radius: var(--radius-md); padding: 8px 12px;
    transition: border-color 0.2s;
}
.nx-input-wrap:focus-within {
    border-color: var(--accent);
}
.nx-input {
    flex: 1; border: none; outline: none; resize: none;
    font-family: var(--font-sans); font-size: var(--fs-sm);
    line-height: 1.5; color: var(--text-primary);
    background: transparent; max-height: 100px;
}
.nx-input::placeholder { color: var(--text-tertiary); }
.nx-send {
    width: 34px; height: 34px; border-radius: var(--radius-sm);
    border: none; background: var(--accent); color: #fff;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s; flex-shrink: 0;
    opacity: 0.4;
}
.nx-send:not(:disabled) { opacity: 1; }
.nx-send:not(:disabled):hover {
    background: var(--accent-hover); transform: scale(1.05);
}
.nx-disclaimer {
    font-size: 11px; color: var(--text-tertiary);
    text-align: center; margin-top: 8px;
}

/* ── Loading dots ── */
.nx-typing-dots {
    display: inline-flex; gap: 4px; padding: 8px 0;
}
.nx-typing-dots span {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--accent);
    animation: typing-bounce 1.4s ease-in-out infinite;
}
.nx-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.nx-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ── Mobile Full-Screen ── */
@media (max-width: 480px) {
    .nexora-panel {
        bottom: 0; right: 0; left: 0; top: 0;
        width: 100%; height: 100%;
        border-radius: 0;
    }
    .nexora-launcher {
        bottom: 16px; right: 16px;
        padding: 12px 18px;
    }
    .nexora-launcher-label { display: none; }
}
