/* ---------- Asistan (yapay zekâ sohbeti) ---------- */
.ai { flex: 1; min-height: 0; display: flex; background: var(--bg); }
.ai-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; width: 100%; max-width: 860px; margin: 0 auto; }
.ai-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 18px 8px; }
.ai-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ai-title b { font-size: 17px; }
.ai-logo { display: inline-flex; color: var(--accent); }
.ai-acts { display: flex; gap: 4px; }
.ai-list { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 18px 16px; display: flex; flex-direction: column; gap: 12px; scroll-behavior: smooth; }

.ai-msg { display: flex; }
.ai-msg.user { justify-content: flex-end; }
.ai-bub { max-width: 100%; min-width: 0; }
.ai-msg.user .ai-bub {
  max-width: 82%; padding: 9px 14px; border-radius: 16px 16px 4px 16px; background: var(--accent); color: #fff;
  white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45;
}
.ai-msg.bot .ai-bub {
  width: 100%; padding: 12px 16px; border-radius: 4px 16px 16px 16px; background: var(--panel); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 8px;
}

/* Markdown */
.ai-md { line-height: 1.55; overflow-wrap: anywhere; color: var(--text); }
.ai-md > :first-child { margin-top: 0; }
.ai-md > :last-child { margin-bottom: 0; }
.ai-md p { margin: 0 0 8px; }
.ai-md h3, .ai-md h4, .ai-md h5, .ai-md h6 { margin: 12px 0 6px; font-size: 15px; color: var(--strong); }
.ai-md ul, .ai-md ol { margin: 0 0 8px; padding-left: 22px; }
.ai-md li { margin: 2px 0; }
.ai-md code { font-family: ui-monospace, Consolas, monospace; font-size: .9em; background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
.ai-md pre { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; overflow-x: auto; margin: 0 0 8px; }
.ai-md pre code { border: none; padding: 0; background: none; }
.ai-md blockquote { margin: 0 0 8px; padding: 2px 10px; border-left: 3px solid var(--accent-line); color: var(--text-2); }
.ai-md hr { border: none; border-top: 1px solid var(--line); margin: 10px 0; }
.ai-md a { color: var(--accent-2); }
.ai-tw { overflow-x: auto; margin: 2px 0 10px; border: 1px solid var(--line); border-radius: 10px; }
.ai-md table { border-collapse: collapse; width: 100%; font-size: 14px; }
.ai-md th, .ai-md td { padding: 7px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.ai-md th { background: var(--panel-2); font-weight: 700; color: var(--strong); white-space: nowrap; }
.ai-md tbody tr:last-child td { border-bottom: none; }
.ai-md tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--panel-2) 55%, transparent); }
.ai-md td:first-child { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* araç adımları */
.ai-tool { display: inline-flex; align-self: flex-start; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px 3px 8px; }
.ai-tool .ai-ti { display: inline-flex; width: 13px; height: 13px; }
.ai-tool.run .ai-ti { border: 2px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: aiSpin .8s linear infinite; box-sizing: border-box; }
.ai-tool.ok.w { color: var(--ok-text); background: var(--ok-soft); border-color: var(--ok-line); font-weight: 600; }
.ai-tool.err { color: var(--warn-text); background: var(--warn-soft); border-color: var(--warn-line); }
@keyframes aiSpin { to { transform: rotate(360deg); } }
.ai-note { font-style: italic; }
.ai-typing { display: flex; gap: 4px; padding: 4px 0; }
.ai-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted-2); animation: aiDot 1.2s infinite ease-in-out; }
.ai-typing i:nth-child(2) { animation-delay: .15s; }
.ai-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes aiDot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.ai-err { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--danger-text); background: var(--danger-soft); border: 1px solid var(--danger-line); border-radius: 8px; padding: 8px 10px; font-size: 14px; }
.ai-err > span:first-child { display: inline-flex; }
.ai-err .btn { margin-left: auto; }
.ai-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; border-top: 1px dashed var(--line); padding-top: 8px; font-size: 13px; color: var(--ok-text); font-weight: 600; }
.ai-foot > span { margin-right: auto; }
.ai-foot.undone { color: var(--muted); font-weight: 500; }

/* boş durum ve bağlantı kurulumu */
.ai-empty { text-align: center; margin: auto 0; padding: 24px 8px 8px; }
.ai-hello { display: inline-flex; width: 62px; height: 62px; align-items: center; justify-content: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent-2); margin-bottom: 10px; }
.ai-empty h2 { margin: 0 0 6px; font-size: 20px; color: var(--strong); }
.ai-empty p { margin: 0 auto 16px; max-width: 520px; line-height: 1.5; }
.ai-sugs { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.ai-sug { font: inherit; font-size: 14px; color: var(--text); background: var(--panel); border: 1px solid var(--line-2); border-radius: 999px; padding: 8px 14px; cursor: pointer; }
.ai-sug:hover { border-color: var(--accent); color: var(--accent-2); }
.ai-setup { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; max-width: 560px; margin: 0 auto; width: 100%; box-sizing: border-box; }
.ai-setup h3 { margin: 0 0 6px; }
.ai-setup > p { margin: 0 0 12px; line-height: 1.5; }
.ai-opt { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-top: 10px; }
.ai-opt.on { border-color: var(--accent-line); background: var(--accent-soft); }
.ai-opt p { margin: 4px 0 8px; line-height: 1.45; }
.ai-opt .row { gap: 8px; }

/* yazma alanı */
.ai-comp { display: flex; align-items: flex-end; gap: 8px; padding: 10px 18px 16px; }
.ai-input { flex: 1; resize: none; min-height: 44px; max-height: 160px; line-height: 1.4; padding: 11px 14px; border-radius: 22px; font: inherit; }
.ai-send, .ai-stop { width: 44px; height: 44px; border-radius: 50%; flex: none; }
.ai-send .ic { margin-left: -2px; }

.st-key { font-family: ui-monospace, Consolas, monospace; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; }
.st-ok { color: var(--ok-text); font-weight: 600; }

@media (max-width: 900px) {
  .ai-head { padding: 6px 10px 0; justify-content: flex-end; }
  .ai-title { display: none; }
  .ai-list { padding: 10px 12px 12px; }
  .ai-msg.user .ai-bub { max-width: 88%; }
  .ai-msg.bot .ai-bub { padding: 10px 12px; }
  .ai-comp { padding: 8px 10px 10px; background: var(--bg); }
  .ai-md table { font-size: 13px; }
  .ai-md th, .ai-md td { padding: 6px 9px; }
  .ai-empty h2 { font-size: 18px; }
  .ai-sug { font-size: 13.5px; }
}
@media (prefers-reduced-motion: reduce) { .ai-tool.run .ai-ti, .ai-typing i { animation: none; } }
/* bildirim yazma alanını örtmesin */
body.mode-ai .toast { bottom: 96px; }
@media (max-width: 900px) { body.mode-ai .toast { bottom: calc(var(--nav-h) + var(--safe-b) + 76px); } }
