/* ============================================================================
 * Zyron Vitrin — Canlı Destek Widget'ı (sf-lc-*)
 * Sağ-altta sabit baloncuk + açılır sohbet paneli. WhatsApp benzeri konuşma
 * (avatar, durum noktası, balon kuyruğu, gün ayracı, satır-içi saat).
 * Mobilde tam ekran. Görünürlük .sf-lc.is-open ile kontrol edilir (hidden attr
 * değil — class selector display'i ezdiği için panel "hep açık" kalıyordu).
 * ==========================================================================*/

.sf-lc {
  --sf-lc-accent: #D7263D;
  --sf-lc-radius: 16px;
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9990;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* WhatsApp FAB varsa chat FAB'ı onun üstüne diz */
.sf-lc--has-wa { bottom: 94px; }

/* ── FAB ─────────────────────────────────────────────────────────────────── */
.sf-lc-fab {
  position: relative;
  width: 58px;
  height: 58px;
  border: none;
  border-radius: 50%;
  background: var(--sf-lc-accent);
  color: #fff;
  font-size: 30px;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 12px 28px -8px rgba(0, 0, 0, 0.32), 0 4px 10px -2px rgba(0, 0, 0, 0.16);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.sf-lc-fab:hover { transform: translateY(-2px) scale(1.05); }
.sf-lc-fab:focus-visible { outline: 3px solid rgba(215, 38, 61, 0.4); outline-offset: 3px; }
.sf-lc-fab i { position: absolute; line-height: 1; transition: opacity 0.18s ease, transform 0.22s ease; }
.sf-lc-fab__icon-open  { opacity: 1; transform: rotate(0deg); }
.sf-lc-fab__icon-close { opacity: 0; transform: rotate(-90deg); }
.sf-lc.is-open .sf-lc-fab__icon-open  { opacity: 0; transform: rotate(90deg); }
.sf-lc.is-open .sf-lc-fab__icon-close { opacity: 1; transform: rotate(0deg); }

.sf-lc-fab__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: #fff;
  color: var(--sf-lc-accent);
  border: 2px solid var(--sf-lc-accent);
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  animation: sf-lc-pop 0.25s ease;
}
@keyframes sf-lc-pop { from { transform: scale(0); } to { transform: scale(1); } }

/* ── Panel ───────────────────────────────────────────────────────────────── */
.sf-lc-panel {
  position: absolute;
  right: 0;
  bottom: 72px;
  width: 370px;
  max-width: calc(100vw - 28px);
  height: 540px;
  max-height: calc(100vh - 110px);
  background: #fff;
  border-radius: var(--sf-lc-radius);
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.32), 0 8px 20px -8px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  /* Görünürlük is-open ile — hidden attr'a güvenme (class selector ezerdi) */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(16px) scale(0.96);
  transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.22s;
}
.sf-lc.is-open .sf-lc-panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* ── Head ────────────────────────────────────────────────────────────────── */
.sf-lc-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 14px;
  background: linear-gradient(135deg, var(--sf-lc-accent), color-mix(in srgb, var(--sf-lc-accent) 76%, #000));
  color: #fff;
  flex: none;
}
.sf-lc-head__avatar {
  flex: none;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: grid; place-items: center;
  font-size: 22px;
}
.sf-lc-head__info { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.sf-lc-head__title { font-size: 15px; font-weight: 700; }
.sf-lc-head__sub {
  font-size: 12px;
  opacity: 0.92;
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sf-lc-head__dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #cbd5e1;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25);
  flex: none;
  transition: background 0.2s ease;
}
.sf-lc-head__dot.is-online { background: #4ade80; }
.sf-lc-head__close {
  background: rgba(255, 255, 255, 0.16);
  border: none;
  color: #fff;
  width: 32px; height: 32px;
  border-radius: 8px;
  font-size: 22px;
  cursor: pointer;
  display: grid; place-items: center;
  flex: none;
  transition: background 0.15s ease;
}
.sf-lc-head__close:hover { background: rgba(255, 255, 255, 0.28); }

/* ── Body ────────────────────────────────────────────────────────────────── */
.sf-lc-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #eae6df;
}
.sf-lc-loading { flex: 1; display: grid; place-items: center; font-size: 30px; color: var(--sf-lc-accent); }
.sf-lc-empty { flex: 1; display: grid; place-items: center; padding: 24px; text-align: center; color: #64748b; font-size: 14px; }

/* Marka şeridi (alt) */
.sf-lc-brand {
  flex: none;
  text-align: center;
  font-size: 10.5px;
  color: #8a9098;
  padding: 5px 0;
  background: #fff;
  border-top: 1px solid #eef1f4;
  letter-spacing: 0.2px;
}
.sf-lc-brand span { font-weight: 600; }

/* ── Mesajlar ────────────────────────────────────────────────────────────── */
.sf-lc-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background-color: #eae6df;
  background-image:
    radial-gradient(rgba(0,0,0,0.025) 1px, transparent 1px),
    radial-gradient(rgba(0,0,0,0.02) 1px, transparent 1px);
  background-size: 26px 26px, 26px 26px;
  background-position: 0 0, 13px 13px;
}

/* Gün ayracı + sistem mesajı */
.sf-lc-daysep { display: flex; justify-content: center; margin: 10px 0 6px; }
.sf-lc-daysep span {
  background: #fff;
  color: #54656f;
  font-size: 11.5px; font-weight: 500;
  padding: 5px 12px; border-radius: 8px;
  box-shadow: 0 1px 1px rgba(0,0,0,0.08);
  max-width: 85%; text-align: center;
}
.sf-lc-daysep--sys span { background: #fff5d6; color: #6b5e2e; }

/* Balonlar */
.sf-lc-msg { display: flex; max-width: 82%; }
.sf-lc-msg.is-visitor { align-self: flex-end; }
.sf-lc-msg.is-agent   { align-self: flex-start; }
.sf-lc-bubble {
  position: relative;
  padding: 6px 9px 7px 10px;
  border-radius: 8px;
  font-size: 13.6px;
  line-height: 1.4;
  word-break: break-word;
  white-space: pre-wrap;
  box-shadow: 0 1px 1px rgba(0,0,0,0.12);
  min-width: 56px;
}
.sf-lc-msg.is-visitor .sf-lc-bubble {
  background: var(--sf-lc-accent);
  color: #fff;
  border-top-right-radius: 0;
}
.sf-lc-msg.is-agent .sf-lc-bubble {
  background: #fff;
  color: #1e293b;
  border-top-left-radius: 0;
}
/* Kuyruklar */
.sf-lc-msg.is-visitor .sf-lc-bubble::before {
  content: ''; position: absolute; top: 0; right: -7px;
  border: 7px solid transparent; border-top-color: var(--sf-lc-accent); border-left: 0;
}
.sf-lc-msg.is-agent .sf-lc-bubble::before {
  content: ''; position: absolute; top: 0; left: -7px;
  border: 7px solid transparent; border-top-color: #fff; border-right: 0;
}
.sf-lc-who { display: block; font-size: 11.5px; font-weight: 700; color: var(--sf-lc-accent); margin-bottom: 2px; }
.sf-lc-time {
  float: right;
  font-size: 10px;
  margin: 4px 0 -2px 8px;
  opacity: 0.65;
  user-select: none;
}
.sf-lc-msg.is-agent .sf-lc-time { color: #667781; opacity: 1; }

/* ── Compose ─────────────────────────────────────────────────────────────── */
.sf-lc-compose {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 9px 10px;
  background: #f0f2f5;
  border-top: 1px solid #e4e8ec;
  flex: none;
}
.sf-lc-textarea {
  flex: 1;
  border: none;
  background: #fff;
  border-radius: 20px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 110px;
  line-height: 1.4;
  outline: none;
  box-shadow: 0 1px 1px rgba(0,0,0,0.06);
}
.sf-lc-send {
  flex: none;
  width: 42px; height: 42px;
  border: none;
  border-radius: 50%;
  background: var(--sf-lc-accent);
  color: #fff;
  font-size: 19px;
  cursor: pointer;
  display: grid; place-items: center;
  transition: transform 0.15s ease, opacity 0.15s ease, filter 0.15s ease;
}
.sf-lc-send:hover { filter: brightness(1.06); transform: scale(1.06); }
.sf-lc-send:disabled { opacity: 0.5; cursor: default; }

/* ── Formlar (ön-iletişim + offline) ─────────────────────────────────────── */
.sf-lc-intro, .sf-lc-offline { padding: 20px 18px; overflow-y: auto; flex: 1; background: #fff; }
.sf-lc-intro__txt, .sf-lc-offline__msg { font-size: 13.5px; color: #475569; line-height: 1.5; margin: 0 0 14px; }
.sf-lc-form { display: flex; flex-direction: column; gap: 10px; }
.sf-lc-input {
  border: 1px solid #d8dee6;
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.sf-lc-input:focus { border-color: var(--sf-lc-accent); box-shadow: 0 0 0 3px rgba(215,38,61,0.1); }
.sf-lc-input--area { resize: vertical; min-height: 70px; }
.sf-lc-hint { font-size: 11.5px; color: #94a3b8; margin-top: -2px; }
.sf-lc-btn {
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  background: var(--sf-lc-accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: filter 0.15s ease;
}
.sf-lc-btn:hover { filter: brightness(1.07); }
.sf-lc-btn:disabled { opacity: 0.7; cursor: default; }

.sf-lc-offline { text-align: center; }
.sf-lc-offline__badge, .sf-lc-thanks__icon {
  width: 54px; height: 54px;
  margin: 4px auto 12px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 28px;
}
.sf-lc-offline__badge { background: #e8edf3; color: #64748b; }
.sf-lc-offline .sf-lc-form { text-align: left; }

/* ── Teşekkür ────────────────────────────────────────────────────────────── */
.sf-lc-thanks { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px 24px; text-align: center; background: #fff; }
.sf-lc-thanks__icon { background: #dcfce7; color: #16a34a; font-size: 34px; }
.sf-lc-thanks__title { font-size: 17px; font-weight: 700; color: #1e293b; margin: 0 0 6px; }
.sf-lc-thanks__txt { font-size: 13.5px; color: #64748b; line-height: 1.5; margin: 0; }

/* ── Shake (validasyon) ──────────────────────────────────────────────────── */
.sf-lc-shake { animation: sf-lc-shake 0.4s ease; }
@keyframes sf-lc-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* ── Mobil — tam ekran panel ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  .sf-lc { right: 16px; bottom: 16px; }
  .sf-lc--has-wa { bottom: 82px; }
  .sf-lc-fab { width: 56px; height: 56px; font-size: 28px; }
  /* Panel açıkken viewport'u tamamen kaplar (inset:0 → 100vh URL-bar sorunu yok) */
  .sf-lc.is-open .sf-lc-panel {
    position: fixed;
    inset: 0;
    width: auto; height: auto;
    max-width: none; max-height: none;
    border-radius: 0;
    transform: none;
  }
  /* Tam ekranda FAB gizlensin (kapatma başlıktaki X ile) */
  .sf-lc.is-open .sf-lc-fab { opacity: 0; pointer-events: none; }
  .sf-lc-head { padding: 14px 12px; padding-top: max(14px, env(safe-area-inset-top)); }
  .sf-lc-msg { max-width: 88%; }
}

@media (prefers-reduced-motion: reduce) {
  .sf-lc-panel, .sf-lc-fab__badge, .sf-lc-shake { animation: none; transition: opacity 0.15s ease, visibility 0.15s ease; }
  .sf-lc-fab i { transition: none; }
}
