/*mle-baked*/
/* ═══════════════════════════════════════════════════════════════
   MLE Chat — Claude-style conversation UI
   Self-contained. Reuses the MLE navy + N-ABLE cyan palette.
   Light + dark theming via [data-theme="dark"] on <html>.
   ═══════════════════════════════════════════════════════════════ */

:root {
    /* Primary Palette - Professional Navy */
    --navy-900: #0f172a;
    --navy-800: #1e293b;
    --navy-700: #334155;
    --navy-600: #475569;
    --navy-500: #64748b;
    --navy-400: #94a3b8;
    --navy-300: #cbd5e1;

    /* Accent - N-ABLE Cyan */
    --accent-700: #0091b3;
    --accent-600: #00a8d4;
    --accent-500: #00C8FF;
    --accent-400: #33d4ff;
    --accent-100: #d6f4ff;
    --accent-50:  #edfaff;

    /* Semantic */
    --success-600: #059669;
    --warning-600: #d97706;
    --error-600:   #dc2626;
    --error-100:   #fee2e2;

    /* Themed surfaces / text (overridden in dark) */
    --page-bg:       #ffffff;
    --column-bg:     #ffffff;
    --composer-bg:   #ffffff;
    --composer-field:#f8fafc;
    --border:        #e2e8f0;
    --border-strong: #cbd5e1;
    --text-primary:  #1e293b;
    --text-secondary:#475569;
    --text-muted:    #64748b;
    --text-faint:    #94a3b8;
    --user-bubble:   #f1f5f9;
    --user-bubble-tx:#1e293b;
    --code-bg:       #0f172a;
    --code-tx:       #e2e8f0;
    --inline-code-bg:#f1f5f9;
    --inline-code-tx:#0891b2;
    --quote-bg:      #f8fafc;
    --hover-bg:      #f1f5f9;
    --header-bg:     #1e293b;
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.10);

    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
    --ease-out: cubic-bezier(0.4, 0, 0.2, 1);

    --column: 50rem;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
}

html[data-theme="dark"] {
    --page-bg:       #0f172a;
    --column-bg:     #0f172a;
    --composer-bg:   #1e293b;
    --composer-field:#0f172a;
    --border:        #334155;
    --border-strong: #475569;
    --text-primary:  #f1f5f9;
    --text-secondary:#cbd5e1;
    --text-muted:    #94a3b8;
    --text-faint:    #64748b;
    --user-bubble:   #334155;
    --user-bubble-tx:#f1f5f9;
    --code-bg:       #020617;
    --code-tx:       #e2e8f0;
    --inline-code-bg:#1e293b;
    --inline-code-tx:#5eead4;
    --quote-bg:      #1e293b;
    --hover-bg:      #1e293b;
    --header-bg:     #020617;
    --accent-700:    #33d4ff;
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
    font-family: var(--font-sans);
    background: var(--page-bg);
    color: var(--text-primary);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── App shell ───────────────────────────────────────────────── */
.mle-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--page-bg);
}

/* Header (hidden in embed) */
.mle-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 48px;
    flex-shrink: 0;
    padding: 0 16px;
    background: var(--header-bg);
    color: #fff;
}
body.in-iframe .mle-topbar { display: none; }

.mle-topbar-logo {
    width: 28px; height: 28px;
    background: linear-gradient(135deg, var(--accent-500) 0%, var(--accent-600) 100%);
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 10px; letter-spacing: 0.5px; color: #fff;
    box-shadow: 0 2px 6px rgba(0, 200, 255, 0.25);
}
.mle-topbar-title { font-size: 13px; font-weight: 700; letter-spacing: 0.3px; flex: 1; }
.mle-topbar-badge {
    background: rgba(0, 200, 255, 0.12);
    color: var(--accent-400);
    padding: 4px 10px; border-radius: 20px;
    font-size: 10px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase;
    border: 1px solid rgba(0, 200, 255, 0.18);
}
.mle-icon-btn {
    background: transparent; border: none; color: var(--navy-300);
    width: 32px; height: 32px; border-radius: 8px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s var(--ease-out), color .15s var(--ease-out);
}
.mle-icon-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.mle-icon-btn svg { width: 16px; height: 16px; }

/* ── Scroll region ───────────────────────────────────────────── */
.mle-scroll {
    flex: 1;
    overflow-y: auto;
    position: relative;
    scroll-behavior: smooth;
}
.mle-scroll::-webkit-scrollbar { width: 8px; }
.mle-scroll::-webkit-scrollbar-track { background: transparent; }
.mle-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
.mle-scroll::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* Centered conversation column */
.mle-column {
    max-width: var(--column);
    margin: 0 auto;
    padding: 28px 24px 40px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ── Welcome ─────────────────────────────────────────────────── */
.mle-welcome {
    display: flex; flex-direction: column; align-items: center;
    text-align: center;
    padding: 8vh 8px 24px;
    animation: mleFade .4s var(--ease-out);
}
@keyframes mleFade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.mle-welcome-icon {
    width: 52px; height: 52px;
    background: linear-gradient(135deg, var(--accent-500) 0%, var(--accent-600) 100%);
    border-radius: 15px;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 18px;
    box-shadow: 0 6px 20px rgba(0, 200, 255, 0.28);
}
.mle-welcome-icon svg { width: 26px; height: 26px; color: #fff; }
.mle-welcome h2 { font-size: 22px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.mle-welcome p { font-size: 14px; color: var(--text-muted); margin-bottom: 26px; }

.mle-suggestions {
    display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
    max-width: 40rem;
}
.mle-chip {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 14px;
    background: var(--column-bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-family: var(--font-sans); font-size: 13px; font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all .15s var(--ease-out);
}
.mle-chip:hover {
    border-color: var(--accent-400);
    color: var(--accent-700);
    background: var(--hover-bg);
    transform: translateY(-1px);
}
.mle-chip svg { width: 15px; height: 15px; color: var(--text-faint); }
.mle-chip:hover svg { color: var(--accent-600); }

/* ── Messages ────────────────────────────────────────────────── */
.mle-turn { animation: mleTurnIn .22s var(--ease-out); }
@keyframes mleTurnIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* User: compact, right-aligned, subtle bubble */
.mle-turn-user { display: flex; justify-content: flex-end; margin-top: 14px; }
.mle-user-bubble {
    max-width: 80%;
    background: var(--user-bubble);
    color: var(--user-bubble-tx);
    padding: 10px 15px;
    border-radius: var(--radius-lg);
    border-bottom-right-radius: 6px;
    font-size: 14.5px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.mle-user-img {
    display: block; max-width: 220px; max-height: 220px;
    border-radius: 10px; margin-bottom: 8px;
}

/* Assistant: full width, no bubble */
.mle-turn-bot { margin-top: 6px; }
.mle-bot-body {
    font-size: 15px;
    color: var(--text-primary);
    word-wrap: break-word;
    overflow-wrap: anywhere;
}
.mle-turn-error .mle-bot-body { color: var(--error-600); }

/* Per-turn action row */
.mle-turn-actions {
    display: flex; gap: 4px; align-items: center;
    margin-top: 6px; height: 26px;
    opacity: 0; transition: opacity .15s var(--ease-out);
}
.mle-turn-bot:hover .mle-turn-actions { opacity: 1; }
.mle-turn-actions.show { opacity: 1; }
.mle-mini-btn {
    display: inline-flex; align-items: center; gap: 5px;
    background: transparent; border: none;
    color: var(--text-faint);
    font-family: var(--font-sans); font-size: 11.5px; font-weight: 500;
    padding: 4px 7px; border-radius: 6px; cursor: pointer;
    transition: all .12s var(--ease-out);
}
.mle-mini-btn:hover { background: var(--hover-bg); color: var(--text-secondary); }
.mle-mini-btn svg { width: 13px; height: 13px; }
.mle-timestamp { font-size: 11px; color: var(--text-faint); margin-left: auto; }

/* ── Thinking indicator ──────────────────────────────────────── */
.mle-thinking {
    display: inline-flex; align-items: center; gap: 9px;
    color: var(--text-muted); font-size: 14px;
    padding: 2px 0;
}
.mle-thinking-dots { display: inline-flex; gap: 4px; }
.mle-thinking-dots span {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--accent-500);
    animation: mleBlink 1.3s infinite ease-in-out;
}
.mle-thinking-dots span:nth-child(2) { animation-delay: .18s; }
.mle-thinking-dots span:nth-child(3) { animation-delay: .36s; }
@keyframes mleBlink { 0%, 70%, 100% { opacity: .25; transform: scale(.85); } 35% { opacity: 1; transform: scale(1); } }

/* ── Markdown typography (assistant body) ────────────────────── */
.mle-bot-body > *:first-child { margin-top: 0 !important; }
.mle-bot-body > *:last-child { margin-bottom: 0 !important; }
.mle-bot-body p { margin: 0 0 14px; }
.mle-bot-body h1, .mle-bot-body h2, .mle-bot-body h3,
.mle-bot-body h4, .mle-bot-body h5, .mle-bot-body h6 {
    color: var(--text-primary); font-weight: 700; line-height: 1.3;
    margin: 22px 0 10px;
}
.mle-bot-body h1 { font-size: 21px; }
.mle-bot-body h2 { font-size: 18px; }
.mle-bot-body h3 { font-size: 16px; }
.mle-bot-body h4, .mle-bot-body h5, .mle-bot-body h6 { font-size: 15px; }
.mle-bot-body strong { font-weight: 700; color: var(--text-primary); }
.mle-bot-body em { font-style: italic; }
.mle-bot-body del { opacity: .7; }
.mle-bot-body ul, .mle-bot-body ol { margin: 0 0 14px; padding-left: 24px; }
.mle-bot-body li { margin: 5px 0; }
.mle-bot-body li > ul, .mle-bot-body li > ol { margin: 5px 0; }
.mle-bot-body blockquote {
    margin: 14px 0; padding: 10px 16px;
    background: var(--quote-bg);
    border-left: 3px solid var(--accent-500);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
}
.mle-bot-body blockquote p:last-child { margin-bottom: 0; }
.mle-bot-body hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* Inline code */
.mle-bot-body code {
    font-family: var(--font-mono); font-size: 0.85em;
    background: var(--inline-code-bg); color: var(--inline-code-tx);
    padding: 2px 6px; border-radius: 5px;
}

/* Links (whitelisted module nav) */
.mle-bot-body a.mle-navlink {
    color: var(--accent-700); font-weight: 600;
    text-decoration: none; cursor: pointer;
    border-bottom: 1px solid transparent;
    transition: border-color .12s var(--ease-out);
}
.mle-bot-body a.mle-navlink::after { content: " ↗"; font-size: .8em; opacity: .6; }
.mle-bot-body a.mle-navlink:hover { border-bottom-color: var(--accent-500); }

/* Tables */
.mle-table-wrap { overflow-x: auto; margin: 0 0 14px; }
.mle-bot-body table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.mle-bot-body th, .mle-bot-body td {
    border: 1px solid var(--border);
    padding: 8px 12px; text-align: left; vertical-align: top;
}
.mle-bot-body th { background: var(--hover-bg); font-weight: 700; }

/* Code blocks with copy button */
.mle-codeblock {
    position: relative; margin: 0 0 14px;
    border-radius: var(--radius-md); overflow: hidden;
    background: var(--code-bg);
    border: 1px solid var(--border);
}
.mle-codeblock-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 12px;
    background: rgba(255,255,255,0.04);
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.mle-codeblock-lang {
    font-family: var(--font-mono); font-size: 11px; font-weight: 500;
    color: #94a3b8; text-transform: lowercase;
}
.mle-code-copy {
    display: inline-flex; align-items: center; gap: 5px;
    background: transparent; border: none;
    color: #94a3b8; font-family: var(--font-sans); font-size: 11px; font-weight: 500;
    padding: 3px 7px; border-radius: 6px; cursor: pointer;
    transition: all .12s var(--ease-out);
}
.mle-code-copy:hover { background: rgba(255,255,255,0.08); color: #e2e8f0; }
.mle-code-copy svg { width: 13px; height: 13px; }
.mle-codeblock pre {
    margin: 0; padding: 14px 16px; overflow-x: auto;
    font-family: var(--font-mono); font-size: 12.5px; line-height: 1.6;
    color: var(--code-tx);
}
.mle-codeblock pre code { background: none; color: inherit; padding: 0; font-size: inherit; }

/* Streaming cursor */
.mle-cursor {
    display: inline-block; width: 8px; height: 1.05em;
    background: var(--accent-500); border-radius: 2px;
    vertical-align: text-bottom; margin-left: 2px;
    animation: mleCursor 1s steps(2) infinite;
}
@keyframes mleCursor { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* ── Scroll-to-bottom pill ───────────────────────────────────── */
.mle-scrollpill {
    position: absolute; left: 50%; bottom: 16px;
    transform: translateX(-50%) translateY(8px);
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--composer-bg);
    color: var(--text-secondary);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    padding: 7px 14px;
    font-size: 12.5px; font-weight: 500;
    box-shadow: var(--shadow-lg);
    cursor: pointer; opacity: 0; pointer-events: none;
    transition: opacity .18s var(--ease-out), transform .18s var(--ease-out);
    z-index: 5;
}
.mle-scrollpill.show { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }
.mle-scrollpill svg { width: 14px; height: 14px; }

/* ── Composer ────────────────────────────────────────────────── */
.mle-composer-dock {
    flex-shrink: 0;
    background: var(--page-bg);
    padding: 8px 24px 18px;
}
.mle-composer {
    max-width: var(--column);
    margin: 0 auto;
    background: var(--composer-bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 8px 8px 8px 14px;
    transition: border-color .15s var(--ease-out), box-shadow .15s var(--ease-out);
}
.mle-composer.focused {
    border-color: var(--accent-400);
    box-shadow: 0 0 0 3px rgba(0, 200, 255, 0.12);
}

.mle-attach-preview {
    display: none; align-items: center; gap: 10px;
    padding: 8px 10px; margin: 2px 4px 8px;
    background: var(--hover-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 12.5px; color: var(--text-secondary);
}
.mle-attach-preview.show { display: flex; }
.mle-attach-preview img { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; }
.mle-attach-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.mle-attach-remove {
    background: none; border: none; color: var(--text-faint); cursor: pointer;
    display: flex; padding: 3px; border-radius: 5px;
}
.mle-attach-remove:hover { color: var(--error-600); background: var(--error-100); }
.mle-attach-remove svg { width: 15px; height: 15px; }

.mle-composer-row { display: flex; align-items: flex-end; gap: 6px; }

.mle-textarea {
    flex: 1;
    resize: none; border: none; outline: none; background: transparent;
    font-family: var(--font-sans); font-size: 15px; line-height: 1.5;
    color: var(--text-primary);
    padding: 8px 4px;
    max-height: 200px; min-height: 24px;
}
.mle-textarea::placeholder { color: var(--text-faint); }

.mle-composer-btn {
    flex-shrink: 0;
    width: 36px; height: 36px; border-radius: 9px;
    border: none; background: transparent; color: var(--text-muted);
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all .15s var(--ease-out);
}
.mle-composer-btn:hover { background: var(--hover-bg); color: var(--accent-600); }
.mle-composer-btn.has-file { color: var(--accent-600); background: var(--accent-50); }
.mle-composer-btn svg { width: 18px; height: 18px; }

.mle-send {
    flex-shrink: 0;
    width: 36px; height: 36px; border-radius: 10px;
    border: none; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--navy-800); color: #fff;
    transition: all .15s var(--ease-out);
}
html[data-theme="dark"] .mle-send { background: var(--accent-600); }
.mle-send:hover:not(:disabled) { background: var(--navy-900); transform: translateY(-1px); }
html[data-theme="dark"] .mle-send:hover:not(:disabled) { background: var(--accent-500); }
.mle-send:disabled { opacity: .4; cursor: not-allowed; }
.mle-send svg { width: 17px; height: 17px; }
.mle-send.is-stop { background: var(--error-600); }
.mle-send.is-stop:hover { background: #b91c1c; }

.mle-composer-hint {
    text-align: center; font-size: 11px; color: var(--text-faint);
    margin-top: 8px;
}
.mle-hidden { display: none !important; }

@media (max-width: 640px) {
    .mle-column { padding: 20px 14px 32px; }
    .mle-composer-dock { padding: 6px 12px 14px; }
    .mle-user-bubble { max-width: 90%; }
    .mle-composer-hint { display: none; }
}
