/* ── Live Chat Widget — visitor (floating bottom-right) ─────────────── */

.chat-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  font-family: Inter, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

/* `.hidden` SADECE chat widget kapsamında !important ile ezilir.
   Sebep: widget panellerine `.chat-widget__start { display: flex }` gibi kurallar
   verdiğimden, Tailwind'in `.hidden { display: none }` specificity savaşını kaybediyor.
   Bu kuralı GLOBAL yapmak header'ın `<div class="hidden lg:flex">` orta navigation'unu
   bozar — o yüzden kesinlikle scope'lu kalmalı. */
.chat-widget .hidden { display: none !important; }

/* ── Trigger button ── */
.chat-widget__trigger {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #99d51a, #6fa012);
  border: none;
  color: #070b14;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(153, 213, 26, 0.35), 0 2px 6px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}
.chat-widget__trigger:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(153, 213, 26, 0.45), 0 2px 8px rgba(0, 0, 0, 0.25); }

.chat-widget__icon-chat,
.chat-widget__icon-close { width: 24px; height: 24px; transition: opacity 0.2s; }
.chat-widget__icon-close { position: absolute; opacity: 0; }
.chat-widget--expanded .chat-widget__icon-chat { opacity: 0; }
.chat-widget--expanded .chat-widget__icon-close { opacity: 1; }

.chat-widget__badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  background: #ef4444;
  color: #fff;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border: 2px solid #070b14;
}

/* ── Panel ── */
.chat-widget__panel {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 100px);
  background: #0b1120;
  border: 1px solid #142035;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(153, 213, 26, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(8px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.chat-widget--expanded .chat-widget__panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ── Header ── */
.chat-widget__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #142035;
  background: linear-gradient(180deg, rgba(153, 213, 26, 0.04), transparent);
}
.chat-widget__title { font-size: 14px; font-weight: 600; color: #fff; }
.chat-widget__status { display: flex; align-items: center; gap: 6px; font-size: 11px; color: #6b7280; margin-top: 2px; }
.chat-widget__dot { width: 8px; height: 8px; border-radius: 50%; background: #6b7280; transition: background 0.2s; }
.chat-widget__dot--online { background: #99d51a; box-shadow: 0 0 8px rgba(153, 213, 26, 0.6); }
.chat-widget__close-btn { background: none; border: none; color: #6b7280; cursor: pointer; padding: 4px; border-radius: 6px; transition: color 0.15s; }
.chat-widget__close-btn:hover { color: #fff; }

/* ── Start & Offline form ── */
.chat-widget__start,
.chat-widget__offline {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  overflow-y: auto;
}
.chat-widget__start-intro,
.chat-widget__offline-intro {
  font-size: 13px;
  color: #9ca3af;
  line-height: 1.6;
}
.chat-widget__start-form { display: flex; flex-direction: column; gap: 10px; }
.chat-widget__input,
.chat-widget__textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  color: #e5e7eb;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.chat-widget__input::placeholder,
.chat-widget__textarea::placeholder { color: #4b5563; }
.chat-widget__input:focus,
.chat-widget__textarea:focus { border-color: rgba(153, 213, 26, 0.45); background: rgba(153, 213, 26, 0.025); }
.chat-widget__textarea { resize: none; }
.chat-widget__primary-btn {
  background: linear-gradient(135deg, #99d51a, #6fa012);
  color: #070b14;
  font-size: 13px;
  font-weight: 600;
  padding: 11px 16px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: opacity 0.15s;
  width: 100%;
}
.chat-widget__primary-btn:hover { opacity: 0.92; }
.chat-widget__primary-btn:disabled { opacity: 0.5; cursor: wait; }

/* ── Conversation ── */
.chat-widget__conversation { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-widget__messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}
.chat-widget__msg {
  max-width: 80%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  word-wrap: break-word;
}
.chat-widget__msg--visitor {
  align-self: flex-end;
  background: linear-gradient(135deg, #99d51a, #6fa012);
  color: #070b14;
  border-bottom-right-radius: 4px;
}
.chat-widget__msg--agent {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: #e5e7eb;
  border-bottom-left-radius: 4px;
}
.chat-widget__msg--system {
  align-self: center;
  background: transparent;
  color: #6b7280;
  font-size: 11px;
  font-style: italic;
  padding: 4px 8px;
}
.chat-widget__msg-time { font-size: 10px; opacity: 0.65; margin-top: 4px; display: block; }

/* ── Typing indicator ── */
.chat-widget__typing {
  display: flex;
  gap: 4px;
  padding: 4px 16px 8px;
}
.chat-widget__typing span {
  width: 6px; height: 6px;
  background: #6b7280;
  border-radius: 50%;
  animation: chat-typing-pulse 1.2s infinite;
}
.chat-widget__typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-widget__typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-typing-pulse {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ── Send form ── */
.chat-widget__send-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #142035;
  background: rgba(255, 255, 255, 0.02);
}
.chat-widget__send-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  color: #e5e7eb;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.chat-widget__send-input:focus { border-color: rgba(153, 213, 26, 0.45); background: rgba(153, 213, 26, 0.025); }
.chat-widget__send-btn {
  background: linear-gradient(135deg, #99d51a, #6fa012);
  color: #070b14;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.chat-widget__send-btn:hover { opacity: 0.92; }

/* ── Image attachment ── */
.chat-widget__attach-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #9ca3af;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.chat-widget__attach-btn:hover {
  color: #99d51a;
  border-color: rgba(153, 213, 26, 0.35);
  background: rgba(153, 213, 26, 0.04);
}
.chat-widget__attach-btn input { width: 0; height: 0; }

.chat-widget__attach-preview {
  position: relative;
  padding: 8px 12px 12px;
  border-top: 1px solid #142035;
  background: rgba(255, 255, 255, 0.02);
}
.chat-widget__attach-preview img {
  max-width: 120px;
  max-height: 90px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: block;
}
.chat-widget__attach-clear {
  position: absolute;
  top: 4px;
  left: 120px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-widget__attach-clear:hover { background: #ef4444; }

/* Image inside a message bubble */
.chat-widget__msg-img {
  display: block;
  max-width: 240px;
  max-height: 180px;
  border-radius: 10px;
  margin-top: 4px;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
html:not(.dark) .chat-widget__attach-btn {
  background: #f9fafb;
  border-color: #e5e7eb;
  color: #6b7280;
}
html:not(.dark) .chat-widget__attach-preview { background: #f9fafb; border-color: #e5e7eb; }

/* ── Rating modal ── */
.chat-widget__rating {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  text-align: center;
  flex: 1;
}
.chat-widget__rating-title { font-size: 15px; font-weight: 600; color: #fff; }
.chat-widget__rating-sub { font-size: 12px; color: #6b7280; margin-bottom: 8px; }
.chat-widget__stars { display: flex; gap: 6px; margin: 4px 0; }
.chat-widget__stars button {
  background: none;
  border: none;
  color: #374151;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s, transform 0.1s;
  padding: 4px;
}
.chat-widget__stars button:hover,
.chat-widget__stars button.active { color: #fbbf24; transform: scale(1.1); }
.chat-widget__skip-btn {
  background: none;
  border: none;
  color: #6b7280;
  font-size: 12px;
  cursor: pointer;
  margin-top: 4px;
  transition: color 0.15s;
}
.chat-widget__skip-btn:hover { color: #9ca3af; }

/* ── Light mode adjustments ── */
html:not(.dark) .chat-widget__panel { background: #ffffff; border-color: #e5e7eb; }
html:not(.dark) .chat-widget__header { border-color: #e5e7eb; background: linear-gradient(180deg, rgba(153, 213, 26, 0.06), transparent); }
html:not(.dark) .chat-widget__title { color: #111827; }
html:not(.dark) .chat-widget__input,
html:not(.dark) .chat-widget__textarea,
html:not(.dark) .chat-widget__send-input {
  background: #f9fafb;
  border-color: #e5e7eb;
  color: #111827;
}
html:not(.dark) .chat-widget__msg--agent {
  background: #f3f4f6;
  border-color: #e5e7eb;
  color: #111827;
}
html:not(.dark) .chat-widget__send-form { background: #f9fafb; border-color: #e5e7eb; }
html:not(.dark) .chat-widget__rating-title { color: #111827; }
html:not(.dark) .chat-widget__badge { border-color: #ffffff; }

/* ── Mobile ── */
@media (max-width: 480px) {
  .chat-widget { bottom: 16px; right: 16px; }
  .chat-widget__panel {
    width: calc(100vw - 32px);
    height: calc(100vh - 100px);
    bottom: 68px;
  }
}
