/**
 * Aytekin — Satış Asistanı
 * v0.1.0
 *
 * Renk değişkenleri PHP tarafından inline basılır (admin ayarlarından).
 * Buradaki fallback'ler tema paletiyle eşleşir.
 *
 * NOT: html/body'ye overflow:hidden UYGULANMAZ — tema kuralı.
 */

.aytekin-root {
  --aytekin-gold: #F5B830;
  --aytekin-gold-dark: #E89C14;
  --aytekin-black: #1a1a24;
  --aytekin-cream: #fefaeb;
  --aytekin-green: #25D366;
  --aytekin-border: #f0e6c8;
  --aytekin-bottom: 24px;
  --aytekin-side: 24px;

  position: fixed;
  z-index: 99990;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ═══════════════════════════════════════════
   BALONCUK — hybrid: altın gövde + yeşil nokta
   ═══════════════════════════════════════════ */

.aytekin-bubble {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--aytekin-gold) 0%, var(--aytekin-gold-dark) 100%);
  color: var(--aytekin-black);
  box-shadow: 0 4px 16px rgba(232, 156, 20, 0.4), 0 2px 6px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  padding: 0;
  margin-left: auto;
}

.aytekin-bubble:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 22px rgba(232, 156, 20, 0.5), 0 3px 8px rgba(0, 0, 0, 0.16);
}

.aytekin-bubble:active { transform: scale(0.97); }

.aytekin-bubble:focus-visible {
  outline: 3px solid var(--aytekin-black);
  outline-offset: 3px;
}

/* İkon geçişi — sohbet ↔ kapat */
.aytekin-bubble-icon {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.aytekin-bubble-icon--chat { opacity: 1; transform: rotate(0deg); }
.aytekin-bubble-icon--close { opacity: 0; transform: rotate(-90deg); }

.aytekin-root[data-state="open"] .aytekin-bubble-icon--chat { opacity: 0; transform: rotate(90deg); }
.aytekin-root[data-state="open"] .aytekin-bubble-icon--close { opacity: 1; transform: rotate(0deg); }

/* Yeşil çevrimiçi noktası — WhatsApp aksanı */
.aytekin-bubble-dot {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 13px;
  height: 13px;
  background: var(--aytekin-green);
  border: 2.5px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.6);
  animation: aytekin-pulse 2.4s infinite;
}

.aytekin-root[data-state="open"] .aytekin-bubble-dot { opacity: 0; }

@keyframes aytekin-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.55); }
  70%  { box-shadow: 0 0 0 9px rgba(37, 211, 102, 0); }
  100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); }
}

/* ═══════════════════════════════════════════
   PANEL
   ═══════════════════════════════════════════ */

.aytekin-panel {
  position: absolute;
  bottom: 74px;
  width: 380px;
  height: 560px;
  max-height: calc(100vh - 120px);
  background: var(--aytekin-cream);
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
  border: 1px solid var(--aytekin-border);
}

/* Konuma göre hizalama */
.aytekin-root[style*="left"] .aytekin-panel,
.aytekin-root.aytekin-left .aytekin-panel { left: 0; transform-origin: bottom left; }

.aytekin-panel { right: 0; }
.aytekin-root.aytekin-left .aytekin-panel { right: auto; left: 0; }

.aytekin-root[data-state="open"] .aytekin-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* ── Başlık ── */
.aytekin-header {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--aytekin-gold) 0%, var(--aytekin-gold-dark) 100%);
  flex-shrink: 0;
}

.aytekin-header-avatar {
  position: relative;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.aytekin-header-avatar svg { display: block; border-radius: 50%; }

.aytekin-online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  background: var(--aytekin-green);
  border: 2px solid var(--aytekin-gold-dark);
  border-radius: 50%;
}

.aytekin-header-text { flex: 1; min-width: 0; line-height: 1.3; }
.aytekin-header-text strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--aytekin-black);
}
.aytekin-header-text span {
  display: block;
  font-size: 11.5px;
  color: rgba(26, 26, 36, 0.72);
  font-weight: 500;
}

.aytekin-close {
  background: rgba(26, 26, 36, 0.1);
  border: none;
  color: var(--aytekin-black);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
  padding: 0;
}
.aytekin-close:hover { background: rgba(26, 26, 36, 0.2); }

/* ── Mesajlar ── */
.aytekin-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.aytekin-messages::-webkit-scrollbar { width: 6px; }
.aytekin-messages::-webkit-scrollbar-track { background: transparent; }
.aytekin-messages::-webkit-scrollbar-thumb {
  background: var(--aytekin-border);
  border-radius: 3px;
}

.aytekin-msg {
  max-width: 84%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
  animation: aytekin-msg-in 0.22s ease;
}

@keyframes aytekin-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.aytekin-msg--bot {
  align-self: flex-start;
  background: #fff;
  color: #2a2a32;
  border: 1px solid var(--aytekin-border);
  border-bottom-left-radius: 4px;
}

.aytekin-msg--user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--aytekin-gold) 0%, var(--aytekin-gold-dark) 100%);
  color: var(--aytekin-black);
  font-weight: 500;
  border-bottom-right-radius: 4px;
}

.aytekin-msg--error {
  align-self: center;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  font-size: 13px;
  max-width: 92%;
  text-align: center;
}

.aytekin-msg strong { font-weight: 700; }
.aytekin-msg a { color: var(--aytekin-gold-dark); font-weight: 600; }
.aytekin-msg em { font-style: normal; opacity: 0.6; font-size: 12px; }

/* Yönlendirme butonu (mesaj içinde) */
.aytekin-msg-cta {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  background: var(--aytekin-green);
  color: #fff !important;
  padding: 9px 14px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none !important;
  transition: background 0.15s, transform 0.15s;
}
.aytekin-msg-cta:hover { background: #1eb85a; transform: translateY(-1px); }

/* Yazıyor göstergesi */
.aytekin-typing {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--aytekin-border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  padding: 13px 15px;
  display: flex;
  gap: 4px;
}
.aytekin-typing span {
  width: 7px;
  height: 7px;
  background: var(--aytekin-gold-dark);
  border-radius: 50%;
  animation: aytekin-bounce 1.3s infinite;
}
.aytekin-typing span:nth-child(2) { animation-delay: 0.16s; }
.aytekin-typing span:nth-child(3) { animation-delay: 0.32s; }

@keyframes aytekin-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ── Hızlı cevaplar ── */
.aytekin-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 10px;
  flex-shrink: 0;
}
.aytekin-quick:empty { display: none; }

.aytekin-quick-btn {
  background: #fff;
  border: 1px solid var(--aytekin-gold);
  color: var(--aytekin-gold-dark);
  padding: 7px 12px;
  border-radius: 16px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.aytekin-quick-btn:hover {
  background: var(--aytekin-gold);
  color: var(--aytekin-black);
}

/* ── Giriş ── */
.aytekin-input-row {
  display: flex;
  gap: 8px;
  padding: 11px 12px;
  background: #fff;
  border-top: 1px solid var(--aytekin-border);
  flex-shrink: 0;
  align-items: flex-end;
}

.aytekin-input {
  flex: 1;
  border: 1px solid var(--aytekin-border);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.4;
  resize: none;
  max-height: 96px;
  min-height: 38px;
  background: var(--aytekin-cream);
  color: var(--aytekin-black);
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}
.aytekin-input:focus {
  outline: none;
  border-color: var(--aytekin-gold);
  box-shadow: 0 0 0 3px rgba(245, 184, 48, 0.18);
}
.aytekin-input::placeholder { color: #a8a29a; }

.aytekin-send {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, var(--aytekin-gold) 0%, var(--aytekin-gold-dark) 100%);
  color: var(--aytekin-black);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, opacity 0.15s;
  padding: 0;
}
.aytekin-send:hover:not(:disabled) { transform: scale(1.06); }
.aytekin-send:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Alt bar — WhatsApp ── */
.aytekin-escalate {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px;
  background: var(--aytekin-green);
  color: #fff !important;
  text-decoration: none !important;
  font-size: 12.5px;
  font-weight: 600;
  flex-shrink: 0;
  transition: background 0.15s;
}
.aytekin-escalate:hover { background: #1eb85a; color: #fff !important; }

/* ═══════════════════════════════════════════
   MOBİL — tam ekran
   ═══════════════════════════════════════════ */

@media (max-width: 480px) {
  .aytekin-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
    transform: translateY(100%);
  }
  .aytekin-root[data-state="open"] .aytekin-panel { transform: translateY(0); }
  .aytekin-header { padding-top: max(14px, env(safe-area-inset-top)); }
  .aytekin-escalate { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .aytekin-msg { max-width: 88%; }
}

/* ═══════════════════════════════════════════
   ERİŞİLEBİLİRLİK
   ═══════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  .aytekin-bubble,
  .aytekin-panel,
  .aytekin-msg,
  .aytekin-bubble-icon,
  .aytekin-bubble-dot,
  .aytekin-typing span {
    animation: none !important;
    transition: opacity 0.1s ease !important;
  }
  .aytekin-panel { transform: none !important; }
}
