/* Finansyol — sağ alttaki "Finansyol'a sor" sohbet balonu (assets/fy-chat.js; backend REQUIREMENTS 244). Ana sayfa,
   kampanya listesi ve detay sayfaları (index.html, firsatlar.html, detay.html) yükler; hesap sayfalarında yoktur.
   Sınıflar fyc- ile başlar ve renkler burada tanımlanır: sayfaların kendi değişkenlerine (fy.css, vitrin.css) dayanmaz.
   Görünüm sitenin dilindedir: beyaz zemin, mürekkep siyahı, nötr gri yüzey, hap biçimli düğmeler, Instrument Sans.
   Telefonda (≤560px) panel tam ekran bir sayfadır. Çerez bandı (z-index 1000) düğmenin üstünde kalır; band açıkken
   fy-chat.js kökü .fyc-lifted yapar ve bandın yüksekliğini --fyc-lift'e yazar: düğme ve panel bandın üstüne çıkar,
   band hiçbir şeyi örtmez. */

.fyc-root {
  --fyc-ink: #111110;
  --fyc-text: #33332f;
  --fyc-muted: #66665f;
  --fyc-line: #e5e5e1;
  --fyc-sand: #f3f3f1;
  --fyc-sand-strong: #e7e7e3;
  --fyc-bg: #ffffff;
  --fyc-danger: #b42b31;
  --fyc-sans: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --fyc-shadow: 0 1px 2px rgba(31, 35, 34, .06), 0 16px 40px rgba(31, 35, 34, .16);
  /* WhatsApp görünümü (REQUIREMENTS 263) */
  --fyc-wall: #efeae2;
  --fyc-wall-dot: rgba(120, 104, 80, .09);
  --fyc-bot: #ffffff;
  --fyc-user: #d9fdd3;
  --fyc-time: #667781;
  --fyc-tick: #53bdeb;
  --fyc-accent: #008069;
  --fyc-link: #027eb5;
  --fyc-hover: #f5f6f6;
  --fyc-day-bg: #ffffff;
  --fyc-head-bg: #ffffff;
  --fyc-error-bg: #fdf0f0;
  font-family: var(--fyc-sans);
  color: var(--fyc-ink);
  font-size: 16px;
  line-height: 1.45;
  letter-spacing: -.005em;
}
.fyc-root *, .fyc-root *::before, .fyc-root *::after { box-sizing: border-box; }
.fyc-root [hidden] { display: none !important; }
.fyc-sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------------------------------------------------------------- düğme */

.fyc-launcher {
  position: fixed;
  right: 16px;
  right: max(16px, env(safe-area-inset-right));
  bottom: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 900;
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 52px; padding: 12px 20px 12px 16px;
  border: 0; border-radius: 999px;
  background: var(--fyc-ink); color: #fff;
  font: inherit; font-weight: 600; font-size: 16px;
  box-shadow: var(--fyc-shadow);
  cursor: pointer;
  transition: transform .15s, background .15s;
}
.fyc-launcher:hover { background: #000; }
.fyc-launcher:active { transform: translateY(1px); }
.fyc-launcher:focus-visible { outline: 2px solid var(--fyc-ink); outline-offset: 3px; }
.fyc-launcher svg { width: 22px; height: 22px; flex: none; }
/* Düğme transform ile kalkar: bant sonradan gelince yer değiştirmesi sayfa kayması (CLS) sayılmaz. */
.fyc-root.fyc-lifted .fyc-launcher { transform: translateY(calc(-1 * var(--fyc-shift, 0px))); }

/* ---------------------------------------------------------------- panel */

.fyc-panel {
  position: fixed;
  right: 16px;
  bottom: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 950;
  width: min(400px, calc(100vw - 32px));
  height: min(640px, calc(100dvh - 32px));
  display: flex; flex-direction: column;
  background: var(--fyc-bg);
  border: 1px solid var(--fyc-line);
  border-radius: 20px;
  box-shadow: var(--fyc-shadow);
  overflow: hidden;
  animation: fyc-in .16s ease-out;
}
.fyc-root.fyc-lifted .fyc-panel { bottom: var(--fyc-lift); height: min(640px, calc(100dvh - 16px - var(--fyc-lift))); }
@keyframes fyc-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.fyc-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--fyc-line);
}
.fyc-head__avatar { width: 36px; height: 36px; flex: none; border-radius: 50%; background: var(--fyc-sand); display: grid; place-items: center; }
.fyc-head__avatar img { width: 36px; height: 36px; border-radius: 50%; }
.fyc-head__text { min-width: 0; flex: 1; }
.fyc-head__title { margin: 0; font-family: var(--fyc-sans); font-size: 16px; font-weight: 600; line-height: 1.25; letter-spacing: -.005em; color: var(--fyc-ink); }
.fyc-head__sub { margin: 0; font-size: 13px; color: var(--fyc-muted); }
.fyc-head { background: var(--fyc-head-bg); }
.fyc-head__avatar { position: relative; }
.fyc-head__avatar::after {
  content: ""; position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px;
  border-radius: 50%; background: #25d366; border: 2px solid var(--fyc-head-bg);
}
.fyc-close {
  flex: none; width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 0; border-radius: 999px; background: transparent; color: var(--fyc-ink);
  cursor: pointer;
}
.fyc-close:hover { background: var(--fyc-sand); }
.fyc-close:focus-visible { outline: 2px solid var(--fyc-ink); outline-offset: 2px; }
.fyc-close svg { width: 20px; height: 20px; }

.fyc-log {
  flex: 1; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain;
  padding: 12px 14px 16px;
  display: flex; flex-direction: column; gap: 3px;
  /* WhatsApp duvar kâğıdı tonu: bej zemin, çok hafif nokta deseni */
  background-color: var(--fyc-wall);
  background-image: radial-gradient(var(--fyc-wall-dot) 1px, transparent 1.2px);
  background-size: 18px 18px;
}

.fyc-day { align-self: center; margin: 8px 0 6px; }
.fyc-day span {
  display: inline-block; padding: 5px 12px; border-radius: 8px;
  background: var(--fyc-day-bg); color: var(--fyc-muted);
  font-size: 12.5px; font-weight: 500; box-shadow: 0 1px .5px rgba(11, 20, 26, .13);
}

.fyc-msg {
  position: relative;
  max-width: 82%; padding: 6px 9px 8px;
  border-radius: 8px; overflow-wrap: anywhere; font-size: 15px; line-height: 1.4;
  box-shadow: 0 1px .5px rgba(11, 20, 26, .13);
  animation: fyc-pop .18s ease-out;
}
.fyc-msg--tail { margin-top: 8px; }
.fyc-msg p { margin: 0; }
.fyc-msg p + p { margin-top: 6px; }
.fyc-msg a { color: var(--fyc-link); text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }
.fyc-msg--bot { align-self: flex-start; background: var(--fyc-bot); color: var(--fyc-ink); }
.fyc-msg--user { align-self: flex-end; background: var(--fyc-user); color: var(--fyc-ink); }
.fyc-msg--bot.fyc-msg--tail { border-top-left-radius: 0; }
.fyc-msg--user.fyc-msg--tail { border-top-right-radius: 0; }
/* Balon kuyruğu: grubun ilk balonunun üst köşesinde küçük üçgen */
.fyc-msg--tail::before {
  content: ""; position: absolute; top: 0; width: 8px; height: 13px;
}
.fyc-msg--bot.fyc-msg--tail::before { left: -8px; background: var(--fyc-bot); clip-path: polygon(0 0, 100% 0, 100% 100%); }
.fyc-msg--user.fyc-msg--tail::before { right: -8px; background: var(--fyc-user); clip-path: polygon(0 0, 100% 0, 0 100%); }
.fyc-msg__text { white-space: pre-wrap; }
.fyc-time {
  float: right; position: relative; top: 6px;
  display: inline-flex; align-items: center; gap: 3px;
  margin: 0 0 0 10px; font-size: 11px; line-height: 1; color: var(--fyc-time);
  white-space: nowrap; user-select: none;
}
.fyc-msg__body + .fyc-time, .fyc-msg__text + .fyc-time { margin-top: 2px; }
.fyc-ticks { width: 16px; height: 16px; color: var(--fyc-tick); }

/* Kart görseli: WhatsApp görsel mesajı gibi balonun üstünde, sabit oran */
.fyc-msg--media { padding-top: 3px; padding-left: 3px; padding-right: 3px; width: min(300px, 82%); }
.fyc-msg--media .fyc-msg__body, .fyc-msg--media .fyc-time { margin-left: 6px; margin-right: 6px; }
.fyc-msg--media .fyc-msg__body { padding-top: 6px; }
.fyc-media { aspect-ratio: 1.586 / 1; border-radius: 6px; overflow: hidden; background: var(--fyc-sand); }
.fyc-media img { display: block; width: 100%; height: 100%; object-fit: cover; }

.fyc-msg--error { align-self: flex-start; background: var(--fyc-error-bg); color: var(--fyc-danger); margin-top: 8px; }
.fyc-msg--typing {
  align-self: flex-start; background: var(--fyc-bot); color: var(--fyc-muted);
  display: inline-flex; gap: 4px; align-items: center; min-height: 36px; padding: 8px 14px; margin-top: 8px;
  border-top-left-radius: 0;
}
.fyc-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: fyc-blink 1.2s infinite ease-in-out; }
.fyc-dot:nth-child(2) { animation-delay: .15s; }
.fyc-dot:nth-child(3) { animation-delay: .3s; }
@keyframes fyc-blink { 0%, 80%, 100% { opacity: .3; transform: none; } 40% { opacity: 1; transform: translateY(-2px); } }
@keyframes fyc-pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
.fyc-log--still .fyc-msg, .fyc-log--still .fyc-chips { animation: none; }

/* Öneri çipleri (karşılama ve devam önerileri) */
.fyc-chips { display: flex; flex-wrap: wrap; gap: 6px; align-self: flex-start; max-width: 100%; margin-top: 8px; animation: fyc-pop .18s ease-out; }
.fyc-chips--next { align-self: flex-end; justify-content: flex-end; }
.fyc-chip, .fyc-retry {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 36px; padding: 7px 14px;
  border: 0; border-radius: 999px;
  background: var(--fyc-bot); color: var(--fyc-accent);
  font: inherit; font-size: 14.5px; font-weight: 500; line-height: 1.2; text-align: center;
  box-shadow: 0 1px .5px rgba(11, 20, 26, .13);
  cursor: pointer;
}
.fyc-chip:hover, .fyc-retry:hover { background: var(--fyc-hover); }
.fyc-chip:focus-visible, .fyc-linkbtn:focus-visible, .fyc-retry:focus-visible { outline: 2px solid var(--fyc-accent); outline-offset: 2px; }
.fyc-chip[disabled] { opacity: .5; cursor: default; background: var(--fyc-bot); }

/* WhatsApp etkileşimli düğmeleri: balonun altında, balon genişliğinde, alt alta */
.fyc-chips--wa { flex-direction: column; flex-wrap: nowrap; gap: 2px; width: min(300px, 82%); margin-top: 2px; }
.fyc-chips--wa .fyc-chip, .fyc-linkbtn {
  width: 100%; min-height: 40px; border-radius: 8px; padding: 9px 12px;
  background: var(--fyc-bot); color: var(--fyc-accent);
  font-weight: 600; font-size: 15px;
}
.fyc-linkbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; text-decoration: none; line-height: 1.2;
  box-shadow: 0 1px .5px rgba(11, 20, 26, .13);
}
.fyc-linkbtn:hover { background: var(--fyc-hover); }
.fyc-linkbtn__icon { font-size: 16px; line-height: 1; }
.fyc-chips:not(.fyc-chips--wa) > .fyc-linkbtn { width: auto; border-radius: 999px; }

/* ---------------------------------------------------------------- yazma alanı */

.fyc-foot { background: var(--fyc-head-bg); border-top: 1px solid var(--fyc-line); padding: 12px 16px 14px; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.fyc-form { display: flex; align-items: flex-end; gap: 8px; }
.fyc-input {
  flex: 1; min-width: 0;
  min-height: 44px; max-height: 128px;
  padding: 11px 14px;
  border: 1px solid var(--fyc-line); border-radius: 22px;
  background: var(--fyc-bg); color: var(--fyc-ink);
  font: inherit; font-size: 16px; line-height: 1.35;
  resize: none;
}
.fyc-input:focus { outline: none; border-color: #00a884; box-shadow: 0 0 0 1px #00a884; }
.fyc-input::placeholder { color: #8a8a84; }
.fyc-send {
  flex: none; width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: #00a884; color: #fff;
  cursor: pointer;
}
.fyc-send:hover { background: #008f6f; }
.fyc-send[disabled] { opacity: .4; cursor: default; }
.fyc-send:focus-visible { outline: 2px solid var(--fyc-ink); outline-offset: 2px; }
.fyc-send svg { width: 20px; height: 20px; }
.fyc-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; margin-top: 8px; font-size: 12px; color: var(--fyc-muted); }
.fyc-meta a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.fyc-left { font-weight: 600; color: var(--fyc-text); }

.fyc-gate { text-align: center; }
.fyc-gate__text { margin: 0 0 12px; font-size: 15px; color: var(--fyc-text); }
.fyc-gate__actions { display: flex; gap: 8px; justify-content: center; }
.fyc-gate__btn {
  flex: 1; max-width: 180px;
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 10px 18px;
  border-radius: 999px; border: 1px solid var(--fyc-ink);
  background: var(--fyc-ink); color: #fff;
  font: inherit; font-weight: 600; font-size: 16px; text-decoration: none;
}
.fyc-gate__btn--ghost { background: var(--fyc-bg); color: var(--fyc-ink); border-color: var(--fyc-line); }
.fyc-gate__btn:focus-visible { outline: 2px solid var(--fyc-ink); outline-offset: 2px; }

/* ---------------------------------------------------------------- telefon: tam ekran */

@media (max-width: 560px) {
  .fyc-panel {
    inset: 0;
    width: 100%; height: 100%;
    height: 100dvh;
    border: 0; border-radius: 0;
    box-shadow: none;
  }
  .fyc-root.fyc-lifted .fyc-panel { top: 0; bottom: var(--fyc-lift); height: auto; }
  .fyc-msg { max-width: 88%; }
  .fyc-chips--wa, .fyc-msg--media { width: min(300px, 88%); }
  html.fyc-lock, html.fyc-lock body { overflow: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  .fyc-panel { animation: none; }
  .fyc-msg, .fyc-chips { animation: none; }
  .fyc-dot { animation: none; opacity: .6; }
  .fyc-launcher { transition: none; }
}

/* ---------------------------------------------------------------- hesap paneli: sekme içinde (data-inline) */

.fyc-root--inline .fyc-panel {
  position: relative; inset: auto; z-index: auto;
  width: 100%; height: min(680px, calc(100dvh - 200px)); min-height: 420px;
  border: 1px solid var(--fyc-line); border-radius: 16px;
  box-shadow: none; animation: none;
}
.fyc-root--inline .fyc-close { display: none; }
@media (max-width: 560px) {
  .fyc-root--inline .fyc-panel { height: calc(100dvh - 170px); min-height: 380px; border-radius: 14px; }
}


@media print { .fyc-root { display: none !important; } }
