/* ============================================================
   AŞAMA 2b — CHAT (Legatus AI ivory/ink revizyonu)
   ------------------------------------------------------------
   Mevcut .chat-area / .welcome-message / .message / .input-area
   class'larının görünümünü ivory/ink dilinde override eder.
   01-tokens.css ve 02-sidebar.css'ten SONRA include et.
   ============================================================ */

/* Canvas */
.chat-area {
    background: var(--bg-primary);
}

.chat-messages {
    padding: 32px 24px 24px;
    gap: 20px;
}
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); }

/* ---- Welcome (Harvey-style hero) ------------------------- */
.welcome-message {
    max-width: 640px;
    gap: 14px;
}
.welcome-message h1 {
    font-family: var(--font-serif);
    font-size: 30px;
    font-weight: 500;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    margin: 0;
}
.welcome-message > p {
    font-size: 14px;
    line-height: 1.55;
    color: var(--text-secondary);
    margin: 0 0 12px;
    max-width: 480px;
}

.example-questions {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
    max-width: 560px;
}
.example-btn {
    padding: 12px 14px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 13px;
    line-height: 1.4;
    text-align: left;
    transition: border-color 0.15s, background 0.15s;
}
.example-btn:hover {
    border-color: var(--accent);
    background: var(--bg-secondary);
}

/* ---- Messages -------------------------------------------- */
.message {
    gap: 12px;
    max-width: 760px;
}

.message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 600;
}
.message.user .message-avatar {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.message.assistant .message-avatar {
    background: var(--accent);
    color: var(--bg-secondary);
}

.message-content {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
}
.message.user .message-content {
    background: var(--user-bubble);
    border: 1px solid var(--border);
    border-bottom-right-radius: 4px;
}
.message.assistant .message-content {
    background: var(--ai-bubble);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.message-content h3 {
    font-family: var(--font-serif);
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    margin: 14px 0 8px;
    padding-bottom: 4px;
}
.message-content h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}
.message-content code {
    background: var(--bg-tertiary);
    color: var(--accent);
    border-radius: 4px;
    padding: 1px 5px;
}
.message-content li::marker { color: var(--accent); }

/* Citation chips inside messages (if static/app.js renders [n] refs) */
.message-content .citation,
.message-content a.citation {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin: 0 1px;
    border-radius: 4px;
    background: var(--bg-tertiary);
    color: var(--accent);
    font-family: var(--font-sans);
    font-size: 10px;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid var(--border);
    vertical-align: 2px;
}
.message-content .citation:hover {
    background: var(--accent);
    color: var(--bg-secondary);
    border-color: var(--accent);
}

/* Tables — re-skin (style.css'teki dark tablo override'ı) */
.table-wrapper {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.response-table {
    font-size: 13px;
}
.response-table th {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    font-weight: 600;
    padding: 8px 14px;
}
.response-table td {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 7px 14px;
    white-space: normal;
}
.response-table tbody tr:nth-child(even) td {
    background: var(--bg-tertiary);
}
.response-table tbody tr:hover td {
    background: var(--hover-bg);
}

/* Action buttons under assistant message */
.action-btn {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 5px 10px;
    font-size: 12px;
    font-family: var(--font-sans);
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.action-btn:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}
.continue-btn {
    background: var(--text-primary);
    color: var(--bg-secondary);
    border-color: var(--text-primary);
    font-weight: 500;
}
.continue-btn:hover {
    background: #2a2722;
    border-color: #2a2722;
    color: var(--bg-secondary);
}

/* System message pill */
.system-message {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 12px;
    border-radius: var(--radius-md);
    padding: 7px 14px;
}

/* ---- Thinking state (4-stage; see app.js patch) ---------- */
.thinking-state {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px;
    background: var(--ai-bubble);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    max-width: 480px;
    font-family: var(--font-sans);
}
.thinking-step {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-secondary);
    transition: color 0.2s;
}
.thinking-step .dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: transparent;
    flex-shrink: 0;
    position: relative;
    transition: border-color 0.2s, background 0.2s;
}
.thinking-step.active {
    color: var(--text-primary);
}
.thinking-step.active .dot {
    border-color: var(--accent);
}
.thinking-step.active .dot::after {
    content: '';
    position: absolute;
    inset: 2px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 1.2s infinite;
}
.thinking-step.done .dot {
    background: var(--accent);
    border-color: var(--accent);
}
.thinking-step.done .dot::after {
    content: '✓';
    position: absolute;
    inset: 0;
    color: var(--bg-secondary);
    font-size: 9px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}
.thinking-step.done {
    color: var(--text-primary);
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.4; }
}

/* Old typing indicator dimmed (artık thinking-state kullanıyoruz) */
.typing-indicator span { background: var(--text-secondary); }

/* ---- Input area ------------------------------------------ */
.input-area {
    padding: 14px 24px 32px;
    border-top: 1px solid var(--border);
    background: var(--bg-primary);
}

.input-toolbar {
    max-width: 760px;
    margin: 0 auto 8px;
}
.length-selector label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.length-selector select {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    padding: 5px 8px;
}

#chatForm .input-wrapper {
    max-width: 760px;
    margin: 0 auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 8px 8px 8px 14px;
    display: flex;
    align-items: flex-end;
    gap: 6px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
#chatForm .input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(200,169,106,0.15);
}
[data-theme="light"] #chatForm .input-wrapper:focus-within {
    box-shadow: 0 0 0 3px rgba(138,106,47,0.10);
}

#userInput {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    padding: 8px 4px;
    resize: none;
    outline: none;
    max-height: 200px;
}
#userInput::placeholder {
    color: var(--text-secondary);
}

#sendBtn,
#stopBtn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--text-primary);
    color: var(--bg-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, opacity 0.15s;
    flex-shrink: 0;
}
#sendBtn svg, #stopBtn svg { width: 16px; height: 16px; }
#sendBtn:hover { background: #2a2722; }
#sendBtn:disabled { opacity: 0.4; cursor: not-allowed; }
#stopBtn { background: var(--danger); color: #fff; }

.disclaimer {
    max-width: 760px;
    margin: 8px auto 0;
    text-align: center;
    font-size: 11px;
    color: var(--text-secondary);
    opacity: 0.7;
}


/* ── "+" menüsü ve araç etiketi (Derin araştırma) ───────────────────────── */
.plus-wrap { position: relative; flex-shrink: 0; align-self: flex-end; }
.plus-btn {
    width: 32px; height: 32px; border-radius: 50%;
    border: 1px solid var(--border); background: transparent;
    color: var(--text-secondary); display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.plus-btn:hover, .plus-btn[aria-expanded="true"] { background: var(--bg-tertiary); color: var(--text-primary); border-color: var(--accent); }
.plus-menu {
    position: absolute; left: 0; bottom: calc(100% + 8px); z-index: 50;
    min-width: 340px; padding: 6px;
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius-lg, 12px); box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}
.plus-item {
    display: flex; align-items: flex-start; gap: 10px; width: 100%;
    padding: 9px 10px; border: none; background: transparent; border-radius: 8px;
    color: var(--text-primary); text-align: left; cursor: pointer; font-family: inherit;
}
.plus-item:hover, .plus-item.is-active { background: var(--bg-tertiary); }
.plus-item.is-active .plus-ico::after { content: ' ✓'; color: var(--accent); font-size: 12px; }
.plus-item b { display: block; font-size: 13.5px; font-weight: 600; }
.plus-item small { display: block; font-size: 11.5px; color: var(--text-secondary); margin-top: 2px; line-height: 1.35; }
.plus-ico { font-size: 16px; line-height: 1.3; width: 22px; text-align: center; flex-shrink: 0; }
.tool-chip {
    display: inline-flex; align-items: center; gap: 5px; align-self: flex-end;
    margin-bottom: 4px; padding: 4px 6px 4px 9px; border-radius: 999px; white-space: nowrap;
    background: color-mix(in srgb, var(--accent) 16%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
    color: var(--accent); font-size: 12.5px; font-weight: 600;
}
.tool-chip[hidden] { display: none; }
.tool-chip-x {
    border: none; background: transparent; color: inherit; cursor: pointer;
    font-size: 15px; line-height: 1; padding: 0 2px; opacity: .75;
}
.tool-chip-x:hover { opacity: 1; }
.msg-tool-tag {
    margin-top: 6px; font-size: 11px; font-weight: 600; color: var(--accent); opacity: .9;
}
@media (max-width: 600px) { .plus-menu { min-width: 260px; } }


/* ── Ekli belge etiketleri (yazma kutusunun üstü) ─────────────────────── */
.doc-chips { max-width: 760px; margin: 0 auto 6px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.doc-chips[hidden] { display: none; }
.doc-chip {
    display: inline-flex; align-items: center; gap: 5px; max-width: 320px;
    padding: 4px 6px 4px 9px; border-radius: 999px; font-size: 12.5px;
    background: var(--bg-secondary); border: 1px solid var(--border); color: var(--text-primary);
}
.doc-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-chip-x { border: none; background: transparent; color: var(--text-secondary); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 2px; }
.doc-chip-x:hover { color: var(--text-primary); }
.doc-chips-count { font-size: 11px; color: var(--text-secondary); }


/* ── Sayfa akışı: mesajlar → yazma alanı → rapor arşivi (tek kaydırma) ── */
.chat-area { overflow-y: auto; position: relative; }
.chat-messages { flex: 0 0 auto; overflow: visible; min-height: calc(100vh - 250px); }
.input-area { border-bottom: 1px solid var(--border); }

/* ── Derin Araştırma Raporları (yazma alanının altı) ───────────────────── */
.research-archive { padding: 26px 24px 56px; background: var(--bg-primary); }
.ra-inner { max-width: 760px; margin: 0 auto; }
.ra-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.ra-head-text { flex: 1; min-width: 260px; }
.ra-title { font-family: var(--font-serif); font-size: 19px; font-weight: 500; margin: 0; color: var(--text-primary); display: flex; align-items: center; gap: 8px; }
.ra-count { font-family: var(--font-sans); font-size: 12px; color: var(--text-secondary); font-weight: 400; }
.ra-sub { font-size: 12.5px; color: var(--text-secondary); margin: 6px 0 0; line-height: 1.45; }
.ra-search {
    flex: 0 0 260px; padding: 9px 12px; border-radius: 999px; border: 1px solid var(--border);
    background: var(--bg-secondary); color: var(--text-primary); font-family: var(--font-sans); font-size: 13px; outline: none;
}
.ra-search:focus { border-color: var(--accent); }
.ra-list { display: flex; flex-direction: column; gap: 8px; }
.ra-empty, .ra-muted { font-size: 13px; color: var(--text-secondary); padding: 10px 2px; }
.ra-card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-lg, 12px); overflow: hidden; transition: border-color .15s; }
.ra-card:hover { border-color: var(--accent); }
.ra-card.open { border-color: var(--accent); }
.ra-card-head {
    display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px 14px;
    background: none; border: none; cursor: pointer; color: var(--text-primary); font-family: var(--font-sans);
}
.ra-card-ico { width: 22px; text-align: center; flex-shrink: 0; }
.ra-card-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.ra-card-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ra-card.open .ra-card-title { white-space: normal; }
.ra-card-meta { font-size: 12px; color: var(--text-secondary); }
.ra-card-chevron { font-size: 11px; color: var(--text-secondary); flex-shrink: 0; }
.ra-detail { border-top: 1px solid var(--border); padding: 6px 18px 16px; }
.ra-section { padding: 12px 0; border-bottom: 1px dashed var(--border); }
.ra-section:last-of-type { border-bottom: none; }
.ra-label { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 6px; }
.ra-question { font-size: 14px; line-height: 1.5; color: var(--text-primary); }
.ra-docs { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.ra-docs li { font-size: 12.5px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg-tertiary); }
.ra-report { font-size: 14px; line-height: 1.6; max-width: none; }
.ra-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 12px; }
.ra-close { margin-left: auto; }
@media (max-width: 768px) {
    .chat-messages { min-height: calc(100dvh - 280px); }
    .research-archive { padding: 20px 14px 90px; }
    .ra-search { flex: 1 1 100%; }
}
