/* REMTA AI Destek — sohbet arayüzü.
   Dış bağımlılık yok (eskiden Bootstrap CDN'den geliyordu): tek istek, CSP'ye uygun,
   çevrimdışı CDN'den etkilenmez. Açık/koyu tema işletim sistemi tercihini izler. */

:root {
  --bg: #f2f4f7;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --line: #e3e7ed;
  --ink: #1a1e26;
  --dim: #6b7382;
  --faint: #97a0b0;
  --accent: #e8681b;
  --accent-ink: #ffffff;
  --accent-soft: #fdf0e7;
  --bubble-ai: #f4f6f9;
  --danger: #c0392b;
  --danger-soft: #fdeceb;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16, 20, 28, .04), 0 8px 28px -12px rgba(16, 20, 28, .18);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --surface: #161b22;
    --surface-2: #1c222b;
    --line: #262d38;
    --ink: #e6eaf0;
    --dim: #8b95a5;
    --faint: #6a7484;
    --accent: #ff8a3d;
    --accent-ink: #16110c;
    --accent-soft: #2a1d12;
    --bubble-ai: #1e242e;
    --danger: #f0857c;
    --danger-soft: #2c1815;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 16px;
}

.chat {
  width: 100%;
  max-width: 680px;
  flex: 1;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- başlık ---------- */
.chat__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.chat__logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: .02em;
  flex: none;
}

.chat__title { font-weight: 700; font-size: 15.5px; letter-spacing: -.01em; }

.chat__status {
  font-size: 12.5px;
  color: var(--dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat__status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  flex: none;
}

.chat__head-actions { margin-left: auto; }

.linkbtn {
  background: none;
  border: 1px solid var(--line);
  color: var(--dim);
  font: inherit;
  font-size: 12.5px;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.linkbtn:hover { color: var(--danger); border-color: var(--danger); }

/* ---------- mesaj alanı ---------- */
.chat__log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  .chat__log { scroll-behavior: auto; }
}

.row { display: flex; gap: 10px; align-items: flex-end; max-width: 100%; }
.row--user { flex-direction: row-reverse; }

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  flex: none;
  margin-bottom: 2px;
}

.bubble {
  padding: 11px 15px;
  border-radius: 15px;
  max-width: min(78%, 480px);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.row--ai .bubble {
  background: var(--bubble-ai);
  border-bottom-left-radius: 5px;
}

.row--user .bubble {
  background: var(--accent);
  color: var(--accent-ink);
  border-bottom-right-radius: 5px;
}

.bubble a { color: inherit; text-underline-offset: 2px; }
.row--ai .bubble a { color: var(--accent); }

.time {
  font-size: 11px;
  color: var(--faint);
  margin: 3px 4px 0;
  font-variant-numeric: tabular-nums;
}

.row--user .time { text-align: right; }

/* yazıyor göstergesi */
.typing { display: flex; gap: 4px; padding: 4px 2px; }

.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--faint);
  animation: bounce 1.3s infinite ease-in-out;
}

.typing span:nth-child(2) { animation-delay: .18s; }
.typing span:nth-child(3) { animation-delay: .36s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .typing span { animation: none; }
}

/* araç çalışıyor rozeti (site araması vb.) */
.tool {
  font-size: 12.5px;
  color: var(--dim);
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 5px 11px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  align-self: flex-start;
}

.caret {
  display: inline-block;
  width: 7px;
  height: 15px;
  background: var(--accent);
  vertical-align: text-bottom;
  margin-left: 2px;
  animation: blink .9s step-end infinite;
}

@keyframes blink { 50% { opacity: 0; } }

/* karşılama */
.welcome { text-align: center; color: var(--dim); padding: 22px 10px; }
.welcome h2 { color: var(--ink); font-size: 17px; margin: 0 0 6px; }
.welcome p { margin: 0 0 16px; font-size: 14px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.chip {
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  padding: 8px 13px;
  border-radius: 999px;
  cursor: pointer;
}

.chip:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- hata şeridi ---------- */
.alert {
  margin: 0 18px 10px;
  padding: 10px 14px;
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid currentColor;
  border-radius: 10px;
  font-size: 13.5px;
}

.alert[hidden] { display: none; }

/* ---------- giriş ---------- */
.chat__form {
  border-top: 1px solid var(--line);
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface);
}

.field {
  display: flex;
  gap: 9px;
  align-items: flex-end;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 7px 7px 7px 14px;
}

.field:focus-within { border-color: var(--accent); }

#msg {
  flex: 1;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  resize: none;
  max-height: 132px;
  padding: 6px 0;
  outline: none;
  line-height: 1.5;
}

#msg::placeholder { color: var(--faint); }

.send {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex: none;
}

.send:disabled { opacity: .4; cursor: default; }
.send svg { width: 17px; height: 17px; }

.meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 7px;
  padding: 0 4px;
  font-size: 11.5px;
  color: var(--faint);
}

.count { font-variant-numeric: tabular-nums; }
.count.warn { color: var(--danger); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 560px) {
  body { padding: 0; }
  .chat { border: 0; border-radius: 0; max-width: 100%; box-shadow: none; }
  .bubble { max-width: 85%; }
}
