/* =========================================================
   AI RESEARCH AGENT
   Minimal Dash UI
   ========================================================= */

:root {
    --bg: #f8f9fb;
    --surface: #ffffff;
    --surface-soft: #f3f4f6;

    --text: #18181b;
    --text-secondary: #71717a;

    --border: #e4e4e7;
    --border-hover: #c4c4c8;

    --accent: #18181b;
    --accent-hover: #303033;

    --radius: 16px;
    --radius-small: 10px;

    --shadow:
        0 1px 2px rgba(0, 0, 0, 0.03),
        0 8px 30px rgba(0, 0, 0, 0.05);
}


/* ---------- Base ---------- */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

body {
    min-height: 100vh;
}


/* ---------- Main app ---------- */

.app-shell {
    min-height: 100vh;
}

.app-container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 28px 24px 180px;
}


/* ---------- Header ---------- */

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    margin-bottom: 48px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
}

.brand-icon {
    width: 34px;
    height: 34px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: var(--text);
    color: white;

    border-radius: 10px;

    font-size: 16px;
    font-weight: 700;
}

.brand-name {
    font-size: 16px;
    font-weight: 650;
    letter-spacing: -0.02em;
}

.header-status {
    display: flex;
    align-items: center;
    gap: 7px;

    color: var(--text-secondary);
    font-size: 13px;
}

.status-dot {
    width: 7px;
    height: 7px;

    background: #22c55e;
    border-radius: 50%;
}


/* ---------- Welcome ---------- */

.welcome {
    text-align: center;
    padding: 55px 20px 70px;
}

.welcome h1 {
    margin: 0 0 12px;

    font-size: 36px;
    font-weight: 650;
    letter-spacing: -0.04em;
}

.welcome p {
    margin: auto;
    max-width: 550px;

    color: var(--text-secondary);
    font-size: 16px;
    line-height: 1.65;
}


/* ---------- Conversation ---------- */

.conversation {
    width: 100%;
}

.message {
    margin-bottom: 26px;
}

.user-message {
    display: flex;
    justify-content: flex-end;
}

.user-bubble {
    max-width: 75%;

    padding: 12px 16px;

    background: #eceef1;

    border-radius: 16px 16px 4px 16px;

    font-size: 15px;
    line-height: 1.55;
}

.agent-message {
    width: 100%;
}

.agent-header {
    display: flex;
    align-items: center;
    gap: 9px;

    margin-bottom: 12px;

    font-size: 13px;
    font-weight: 600;
}

.agent-avatar {
    width: 27px;
    height: 27px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: var(--text);
    color: white;

    border-radius: 8px;

    font-size: 12px;
}

.agent-content {
    font-size: 15px;
    line-height: 1.7;
}


/* ---------- Markdown ---------- */

.agent-content h1,
.agent-content h2,
.agent-content h3 {
    letter-spacing: -0.025em;
}

.agent-content h2 {
    margin-top: 28px;
    margin-bottom: 10px;

    font-size: 20px;
}

.agent-content h3 {
    margin-top: 22px;
    font-size: 16px;
}

.agent-content p {
    margin: 10px 0;
}

.agent-content code {
    background: #f1f1f3;

    padding: 2px 5px;

    border-radius: 5px;

    font-size: 13px;
}

.agent-content blockquote {
    margin: 18px 0;
    padding: 3px 0 3px 15px;

    border-left: 3px solid #d4d4d8;

    color: #52525b;
}


/* ---------- Academic tables ---------- */

.agent-content table {
    width: 100%;

    margin: 20px 0;

    border-collapse: collapse;

    background: white;

    font-size: 14px;
}

.agent-content th {
    text-align: left;

    padding: 10px 12px;

    border-bottom: 2px solid #27272a;

    font-weight: 600;
}

.agent-content td {
    padding: 10px 12px;

    border-bottom: 1px solid var(--border);
}

.agent-content tbody tr:last-child td {
    border-bottom: 2px solid #27272a;
}


/* ---------- Chart ---------- */

/*.chart-container { */
/*    margin: 25px 0; */

/*    background: white;*/

/*    border: 1px solid var(--border); */
/*    border-radius: var(--radius); */
/*
/*   padding: 12px; */
/*} */


.chart-container {
    width: 100%;
    margin-top: 22px;
    margin-bottom: 22px;

    background: #ffffff;

    border: 1px solid #e4e4e7;
    border-radius: 12px;

    padding: 12px;

    overflow: hidden;
}

.chart-container .js-plotly-plot {
    width: 100%;
}

/* ---------- Bottom composer ---------- */

.composer-wrapper {
    position: fixed;

    bottom: 0;
    left: 0;
    right: 0;

    padding: 18px 24px 26px;

    background:
        linear-gradient(
            to top,
            var(--bg) 65%,
            rgba(248, 249, 251, 0)
        );

    z-index: 100;
}

.composer {
    width: 100%;
    max-width: 850px;

    margin: auto;

    background: var(--surface);

    border: 1px solid var(--border);
    border-radius: 20px;

    box-shadow: var(--shadow);

    padding: 13px;
}

.composer:focus-within {
    border-color: #b8b8bd;
}

.question-input {
    width: 100%;

    min-height: 65px;
    max-height: 180px;

    padding: 5px 7px 10px;

    border: none;
    outline: none;
    resize: none;

    background: transparent;

    color: var(--text);

    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;
}

.question-input::placeholder {
    color: #a1a1aa;
}


/* ---------- Composer toolbar ---------- */

.composer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 12px;
}

.composer-left {
    display: flex;
    align-items: center;
    gap: 8px;
}


/* ---------- Upload ---------- */

.upload-button {
    display: inline-flex;
    align-items: center;
    gap: 7px;

    padding: 8px 11px;

    border: 1px solid var(--border);
    border-radius: 9px;

    color: #52525b;

    font-size: 13px;

    cursor: pointer;

    transition: all 0.15s ease;
}

.upload-button:hover {
    background: var(--surface-soft);
    border-color: var(--border-hover);
}

.upload-status {
    max-width: 280px;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    color: var(--text-secondary);

    font-size: 12px;
}


/* ---------- Ask button ---------- */

.ask-button {
    padding: 9px 17px;

    border: none;
    border-radius: 10px;

    background: var(--accent);
    color: white;

    font-size: 13px;
    font-weight: 600;

    cursor: pointer;

    transition:
        background 0.15s ease,
        transform 0.1s ease;
}

.ask-button:hover {
    background: var(--accent-hover);
}

.ask-button:active {
    transform: scale(0.97);
}


/* ---------- Mobile ---------- */

@media (max-width: 700px) {

    .app-container {
        padding: 20px 16px 170px;
    }

    .welcome {
        padding-top: 30px;
    }

    .welcome h1 {
        font-size: 29px;
    }

    .user-bubble {
        max-width: 90%;
    }

    .composer-wrapper {
        padding: 12px;
    }

    .upload-status {
        display: none;
    }
}


/* ---------- Message attachment ---------- */

.message-attachment {
    display: inline-flex;
    align-items: center;

    margin-top: 9px;
    padding: 6px 9px;

    background: rgba(255, 255, 255, 0.65);

    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 7px;

    color: #52525b;

    font-size: 12px;
    font-weight: 500;
}


/* =========================================================
   MATHEMATICS
   ========================================================= */

.agent-markdown mjx-container {
    font-size: 105% !important;
}


/* Display equations */

.agent-markdown mjx-container[display="true"] {
    margin: 22px 0 !important;

    overflow-x: auto;
    overflow-y: hidden;

    padding: 4px 2px;
}


/* Prevent large equations breaking mobile layout */

.agent-markdown {
    overflow-wrap: break-word;
}

.agent-markdown mjx-container {
    max-width: 100%;
}


/* =========================================================
   AGENT THINKING
   ========================================================= */

.thinking-container {
    display: flex;
    align-items: center;
    gap: 10px;

    padding: 12px 0;

    color: #71717a;

    font-size: 13px;
}

.thinking-avatar {
    width: 27px;
    height: 27px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: #18181b;
    color: white;

    border-radius: 8px;

    font-size: 12px;
    font-weight: 600;
}

.thinking-dots {
    display: flex;
    align-items: center;
    gap: 4px;
}

.thinking-dot {
    width: 5px;
    height: 5px;

    background: #a1a1aa;

    border-radius: 50%;

    animation: thinkingPulse 1.3s infinite ease-in-out;
}

.thinking-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.thinking-dot:nth-child(3) {
    animation-delay: 0.30s;
}

@keyframes thinkingPulse {

    0%,
    60%,
    100% {
        opacity: 0.3;
        transform: translateY(0);
    }

    30% {
        opacity: 1;
        transform: translateY(-3px);
    }
}


.ask-button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}