/* ═══════════════════════════════════════════════════
   CHATBOT — FAB, animasyonlar, chat panel, mesajlar
═══════════════════════════════════════════════════ */

/* ── FAB — temel yerleşim ve görünüm ── */
.chat-fab {
  display: none; /* JS toggleFabVisibility() ile açılır */
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: linear-gradient(135deg, #E8007D, #F0861A);
  border: none;
  color: #fff;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 28px rgba(232, 0, 125, .6);
  z-index: 9000;
  padding: 0;
  overflow: visible;
}

/* ── Chat panel ── */
.chat-panel {
  position: fixed;
  bottom: 108px;
  right: 24px;
  width: 360px;
  height: 520px;
  background: var(--surface);
  border: 1px solid rgba(245, 240, 232, .12);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, .5);
  z-index: 8999;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.chat-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 6px;
  transition: color .12s, background .12s;
}
.chat-close:hover { color: var(--text); background: rgba(245,240,232,.07); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
  background: var(--surface2);
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: 'Outfit', sans-serif;
  outline: none;
  transition: border-color .15s;
}
.chat-input:focus { border-color: rgba(232,0,125,.4); }
.chat-send-btn {
  background: var(--accent);
  border: none;
  color: #fff;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Outfit', sans-serif;
  cursor: pointer;
  transition: opacity .15s;
}
.chat-send-btn:hover { opacity: .88; }

/* ── FAB animasyonları ── */
@keyframes fabPulse {
  0%,100% { box-shadow: 0 6px 28px rgba(232,0,125,.55); }
  50%      { box-shadow: 0 6px 36px rgba(232,0,125,.9), 0 0 0 10px rgba(232,0,125,.12); }
}
@keyframes fabAwakeGlow {
  0%,100% { box-shadow: 0 6px 28px rgba(232,0,125,.6); }
  50%      { box-shadow: 0 6px 40px rgba(240,134,26,.95), 0 0 0 8px rgba(240,134,26,.18); }
}
#chatFab[data-state="sleep"] { animation: fabPulse 2.8s ease-in-out infinite; }
#chatFab[data-state="awake"] { animation: fabAwakeGlow 1.4s ease-in-out infinite; }

/* ── Gövde hareketleri ── */
@keyframes octSleep {
  0%,100% { transform: translateY(0px) rotate(-2deg); }
  30%      { transform: translateY(-5px) rotate(1.5deg); }
  60%      { transform: translateY(-2px) rotate(2deg); }
}
@keyframes octAwake {
  0%,100% { transform: translateY(0px) rotate(-4deg) scale(1); }
  25%      { transform: translateY(-6px) rotate(4deg) scale(1.05); }
  75%      { transform: translateY(-3px) rotate(-2deg) scale(1.02); }
}
@keyframes octArm {
  0%,100% { transform: skewX(0deg) scaleY(1); }
  20%     { transform: skewX(7deg) scaleY(0.97); }
  60%     { transform: skewX(-7deg) scaleY(1.03); }
}
@keyframes octArmSleep {
  0%,100% { transform: skewX(0deg); }
  40%     { transform: skewX(3deg); }
  80%     { transform: skewX(-2deg); }
}
@keyframes zFloat {
  0%   { opacity:0; transform: translateY(6px) scale(0.7); }
  25%  { opacity:1; transform: translateY(0px) scale(1); }
  80%  { opacity:.8; }
  100% { opacity:0; transform: translateY(-14px) scale(0.6); }
}

#chatFab[data-state="sleep"] .z1 { animation: zFloat 2.2s ease-in-out infinite; }
#chatFab[data-state="sleep"] .z2 { animation: zFloat 2.2s ease-in-out 0.65s infinite; }
#chatFab[data-state="sleep"] .z3 { animation: zFloat 2.2s ease-in-out 1.3s infinite; }
#chatFab[data-state="awake"] .z1,
#chatFab[data-state="awake"] .z2,
#chatFab[data-state="awake"] .z3 { display: none; }

#chatFab[data-state="sleep"] #octopusFab { animation: octSleep 3.2s ease-in-out infinite; }
#chatFab[data-state="awake"] #octopusFab { animation: octAwake 1.4s ease-in-out infinite; }
#chatFab[data-state="sleep"] .oct-arms   { animation: octArmSleep 3.5s ease-in-out infinite; transform-origin: 50% 64px; }
#chatFab[data-state="awake"] .oct-arms   { animation: octArm 1s ease-in-out infinite; transform-origin: 50% 64px; }

/* ── Göz state'leri ── */
#chatFab[data-state="sleep"] .eye-sleep { display: block !important; }
#chatFab[data-state="sleep"] .eye-awake { display: none  !important; }
#chatFab[data-state="awake"] .eye-sleep { display: none  !important; }
#chatFab[data-state="awake"] .eye-awake { display: block !important; }

/* ── Chat mesajları ── */
.chat-msg    { display: flex; flex-direction: column; }
.chat-user   { align-items: flex-end; }
.chat-bot    { align-items: flex-start; }
.chat-bubble {
  max-width: 88%;
  padding: 9px 13px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  /* WKWebView'da metin seçimi bazen tıkanır; explicit izin ver */
  -webkit-user-select: text;
  user-select: text;
  cursor: text;
}
.chat-user .chat-bubble {
  background: linear-gradient(135deg, rgba(232,0,125,.25), rgba(240,134,26,.2));
  border: 1px solid rgba(232,0,125,.3);
  color: #F5F0E8;
}
.chat-bot .chat-bubble {
  background: #1C1B19;
  border: 1px solid rgba(245,240,232,.09);
  color: #F5F0E8;
}
.chat-typing { display: flex; gap: 5px; align-items: center; padding: 12px 16px; }
.chat-typing span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #8A8680;
  animation: chatDot 1.2s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: .2s; }
.chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes chatDot {
  0%,60%,100% { transform: translateY(0); opacity: .4; }
  30%          { transform: translateY(-5px); opacity: 1; }
}

/* ── Chat chips (asset linkleri) ── */
.chat-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0 4px; }
.chat-chip {
  background: #252422;
  border: 1px solid rgba(232,0,125,.3);
  border-radius: 20px;
  color: #F5F0E8;
  font-size: 11px;
  padding: 5px 10px;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
  text-align: left;
}
.chat-chip:hover { background: rgba(232,0,125,.15); border-color: rgba(232,0,125,.6); }
