/* --------------------------------------------------------------------------
   Canlı destek balonu
   -------------------------------------------------------------------------- */

.chat {
  --chat-z: 60;
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: var(--chat-z);
  font-family: inherit;
}

.chat__launcher {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 16px 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font: 500 14px/1 inherit;
  font-family: inherit;
  box-shadow: 0 6px 18px -6px rgba(0, 99, 251, 0.45);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
}
.chat__launcher:hover { transform: translateY(-1px); box-shadow: 0 10px 24px -8px rgba(0, 99, 251, 0.5); }
.chat__launcher:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--primary-ring), 0 6px 18px -6px rgba(0, 99, 251, 0.45); }
.chat__launcher svg { width: 18px; height: 18px; }
.chat__launcher-dot {
  position: absolute; top: 9px; left: 26px; width: 8px; height: 8px; border: 1.5px solid var(--primary); border-radius: 50%; background: #9aa6c4;
}
.chat--online .chat__launcher-dot { background: #22c55e; }
.chat__badge {
  position: absolute; top: -4px; right: -4px; display: grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 999px; background: var(--danger); color: #fff; font-size: 12px; font-weight: 700;
}
.chat__badge[hidden] { display: none; }
.chat.is-open .chat__launcher { display: none; }

.chat__panel {
  position: absolute;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: 380px;
  height: min(600px, calc(100vh - 48px));
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  box-shadow: 0 30px 70px -20px rgba(2, 16, 45, 0.35);
  transform-origin: bottom right;
  animation: chat-in 0.22s ease-out;
}
.chat__panel[hidden] { display: none; }
@keyframes chat-in { from { opacity: 0; transform: translateY(10px) scale(0.97); } }

.chat__head {
  display: flex; align-items: center; gap: 12px; padding: 18px 18px 16px; background: var(--grad-brand); color: #fff;
}
.chat__avatar {
  position: relative; display: grid; place-items: center; width: 42px; height: 42px; flex-shrink: 0; border-radius: 50%;
  background: rgba(255, 255, 255, 0.18); font-weight: 700;
}
.chat__avatar svg { width: 22px; height: 22px; }
.chat__avatar::after {
  content: ""; position: absolute; right: 0; bottom: 0; width: 11px; height: 11px; border: 2px solid #0a5cf0; border-radius: 50%; background: #9aa6c4;
}
.chat--online .chat__avatar::after { background: #22c55e; }
.chat__title { margin: 0; font-size: 16px; font-weight: 600; }
.chat__subtitle { margin: 2px 0 0; font-size: 12.5px; opacity: 0.85; }
.chat__head-actions { display: flex; gap: 4px; margin-left: auto; }
.chat__icon-btn {
  display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 10px; background: transparent; color: #fff; cursor: pointer;
}
.chat__icon-btn:hover { background: rgba(255, 255, 255, 0.16); }
.chat__icon-btn svg { width: 18px; height: 18px; }
.chat__icon-btn[hidden] { display: none; }

.chat__body { flex: 1; min-height: 0; overflow-y: auto; padding: 18px; background: var(--bg-subtle); }

.chat__intro { margin: 0 0 16px; font-size: 14px; line-height: 1.55; color: var(--fg-3, var(--muted)); }
.chat__form { display: grid; gap: 10px; }
.chat__form label { display: grid; gap: 6px; font-size: 13px; font-weight: 500; color: var(--fg); }
.chat__form label small { font-weight: 400; color: var(--muted); }
.chat__input {
  width: 100%; padding: 11px 13px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); color: var(--fg);
  font: inherit; font-size: 14px; resize: none;
}
.chat__input:focus { outline: none; border-color: var(--primary); box-shadow: none; }
.chat__hp { position: absolute; left: -9999px; }
.chat__submit {
  height: 46px; border: 0; border-radius: 12px; background: var(--primary); color: #fff; font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
}
.chat__submit:hover { background: var(--primary-hover); }
.chat__submit:disabled { opacity: 0.6; cursor: default; }
.chat__error { margin: 0; font-size: 13px; color: var(--danger); }
.chat__error[hidden] { display: none; }
.chat__legal { margin: 2px 0 0; font-size: 11.5px; line-height: 1.5; color: var(--muted); }

.chat__thread { display: grid; gap: 10px; }
.chat__msg { display: grid; max-width: 82%; }
.chat__msg p {
  margin: 0; padding: 10px 14px; border-radius: 18px; font-size: 14px; line-height: 1.5; white-space: pre-line; overflow-wrap: anywhere;
}
.chat__msg small { margin-top: 4px; font-size: 11px; color: var(--muted); }
.chat__msg--visitor { justify-self: end; }
.chat__msg--visitor p { border-bottom-right-radius: 6px; background: var(--primary); color: #fff; }
.chat__msg--visitor small { text-align: right; }
.chat__msg--agent p { border: 1px solid var(--border); border-bottom-left-radius: 6px; background: var(--bg); color: var(--fg); }
.chat__msg--system { justify-self: center; max-width: 100%; }
.chat__msg--system p { padding: 5px 12px; border-radius: 999px; background: var(--bg-muted); color: var(--muted); font-size: 12px; }
.chat__notice { margin: 4px 0 0; padding: 10px 12px; border-radius: 12px; background: var(--bg-muted); font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.chat__notice[hidden] { display: none; }

.chat__compose { display: flex; align-items: flex-end; gap: 8px; padding: 12px; border-top: 1px solid var(--border); background: var(--bg); }
.chat__compose[hidden] { display: none; }
.chat__compose .chat__input { max-height: 120px; border-radius: 14px; }
.chat__send {
  display: grid; place-items: center; width: 44px; height: 44px; flex-shrink: 0; border: 0; border-radius: 14px; background: var(--primary); color: #fff; cursor: pointer;
}
.chat__send:disabled { opacity: 0.5; cursor: default; }
.chat__send svg { width: 18px; height: 18px; }

.chat__restart { display: block; margin: 14px auto 0; padding: 9px 16px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg); color: var(--fg); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; }
.chat__restart[hidden] { display: none; }

@media (max-width: 560px) {
  .chat { right: 16px; bottom: 16px; }
  .chat__launcher { width: 48px; height: 48px; padding: 0; justify-content: center; }
  .chat__launcher-label { display: none; }
  .chat__launcher-dot { top: 12px; left: 27px; }
  .chat.is-open { inset: 0; }
  .chat__panel { position: fixed; inset: 0; width: auto; height: auto; border: 0; border-radius: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .chat__panel { animation: none; }
  .chat__launcher { transition: none; }
}
