/**
 * Yener Chatbot Widget — CSS
 * Shared between WordPress theme and Panel
 * SEOYEN brand color: #8b5cf6
 *
 * Class names match chatbot-widget.js DOM exactly.
 */

/* ============================================================
   ANIMATIONS
   ============================================================ */

@keyframes yenerPulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.08); }
  100% { transform: scale(1); }
}

@keyframes yenerTypingDot {
  0%, 100% { opacity: 0.3; transform: translateY(0); }
  50%       { opacity: 1;   transform: translateY(-3px); }
}

@keyframes yenerFadeIn {
  from {
    opacity: 0;
    transform: scale(0.8) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes yenerSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   FAB — Floating Action Button
   ============================================================ */

.yener-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9997;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #8b5cf6;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.45), 0 2px 6px rgba(0, 0, 0, 0.15);
  animation: yenerPulse 2s ease-in-out infinite;
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
  outline: none;
  padding: 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.yener-fab:hover {
  background: #7c3aed;
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.55), 0 3px 8px rgba(0, 0, 0, 0.18);
  animation-play-state: paused;
}

.yener-fab:active {
  transform: scale(0.94);
}

.yener-fab svg,
.yener-fab img {
  width: 28px;
  height: 28px;
  display: block;
  pointer-events: none;
}

/* ============================================================
   TOOLTIP
   ============================================================ */

.yener-tooltip {
  position: fixed;
  bottom: 90px;
  right: 24px;
  z-index: 9996;
  background: #1e293b;
  color: #fff;
  font-size: 0.82rem;
  padding: 7px 13px;
  border-radius: 10px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.yener-tooltip::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 18px;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid #1e293b;
}

.yener-tooltip-visible {
  opacity: 1;
}

/* ============================================================
   CHAT WINDOW
   ============================================================ */

.yener-window {
  position: fixed;
  bottom: 90px;
  right: 24px;
  z-index: 9998;
  width: 380px;
  height: 520px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  display: none;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
}

.yener-window.yener-open {
  display: flex;
  animation: yenerFadeIn 0.2s ease-out;
}

/* ============================================================
   HEADER
   ============================================================ */

.yener-header {
  height: 56px;
  min-height: 56px;
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 10px;
  flex-shrink: 0;
  border-radius: 16px 16px 0 0;
}

.yener-header-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  border: 2px solid rgba(255, 255, 255, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.yener-header-avatar img,
.yener-header-avatar svg {
  width: 20px;
  height: 20px;
  display: block;
}

.yener-header-info {
  flex: 1;
  min-width: 0;
  line-height: 1.2;
}

.yener-header-title {
  color: #ffffff;
  font-size: 0.92rem;
  font-weight: 700;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.yener-header-subtitle {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.72rem;
  display: block;
}

.yener-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 1.1rem;
  line-height: 1;
  transition: background 0.15s ease;
  flex-shrink: 0;
  padding: 0;
  outline: none;
}

.yener-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ============================================================
   MESSAGES AREA
   ============================================================ */

.yener-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.yener-messages::-webkit-scrollbar {
  width: 4px;
}
.yener-messages::-webkit-scrollbar-track {
  background: transparent;
}
.yener-messages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}
.yener-messages::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* ============================================================
   MESSAGE ROW
   ============================================================ */

.yener-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: yenerSlideUp 0.2s ease-out;
  width: 100%;
}

/* Bot message — left-aligned (default) */
.yener-msg-bot {
  justify-content: flex-start;
}

/* User message — right-aligned */
.yener-msg-user {
  flex-direction: row-reverse;
}

/* Bot message small avatar */
.yener-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: flex-end;
  margin-bottom: 2px;
  overflow: hidden;
  background: none;
}

.yener-msg-avatar img,
.yener-msg-avatar svg {
  width: 28px;
  height: 28px;
  display: block;
}

/* Message bubble */
.yener-msg-bubble {
  padding: 10px 14px;
  font-size: 0.875rem;
  line-height: 1.55;
  word-break: break-word;
  overflow-wrap: break-word;
}

/* Bot bubble style */
.yener-msg-bot .yener-msg-bubble {
  background: #f5f3ff;
  color: #1e293b;
  border-radius: 12px 12px 12px 4px;
}

/* User bubble style */
.yener-msg-user .yener-msg-bubble {
  background: #8b5cf6;
  color: #ffffff;
  border-radius: 12px 12px 4px 12px;
}

/* User message inner wrapper — sağa hizalı, bubble genişliğini kısıtlama */
.yener-msg-user > div {
  max-width: 85%;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

/* Bot message inner wrapper */
.yener-msg-bot > div {
  max-width: 85%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

/* Bot bubble internal formatting */
.yener-msg-bot .yener-msg-bubble ul {
  margin: 4px 0;
  padding-left: 16px;
}
.yener-msg-bot .yener-msg-bubble li {
  margin-bottom: 2px;
}
.yener-msg-bot .yener-msg-bubble strong {
  font-weight: 600;
}
.yener-msg-bot .yener-msg-bubble code {
  background: #e2e8f0;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.82rem;
}
.yener-msg-bot .yener-msg-bubble a {
  color: #7c3aed;
  text-decoration: underline;
}

/* Timestamp */
.yener-msg-time {
  font-size: 0.7rem;
  color: #94a3b8;
  margin-top: 4px;
  padding: 0 4px;
}

/* ============================================================
   TYPING INDICATOR
   ============================================================ */

.yener-typing-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.yener-typing {
  background: #f5f3ff;
  border-radius: 12px 12px 12px 4px;
  padding: 10px 14px;
  display: flex;
  gap: 5px;
  align-items: center;
}

.yener-typing-dot {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8b5cf6;
  animation: yenerTypingDot 1.2s ease-in-out infinite;
}

.yener-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.yener-typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* ============================================================
   QUICK SUGGESTION CHIPS
   ============================================================ */

.yener-chips {
  padding: 6px 0 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: 28px;
}

.yener-chip {
  border: 1px solid #8b5cf6;
  color: #8b5cf6;
  background: transparent;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
  outline: none;
  line-height: 1.3;
  flex-shrink: 0;
}

.yener-chip:hover,
.yener-chip:focus {
  background: #8b5cf6;
  color: #ffffff;
}

.yener-chip:active {
  background: #7c3aed;
  border-color: #7c3aed;
  color: #ffffff;
}

/* ============================================================
   CLEAR HISTORY BUTTON
   ============================================================ */

.yener-clear-history {
  display: block;
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 0.7rem;
  cursor: pointer;
  padding: 3px 12px;
  text-align: right;
  width: 100%;
  flex-shrink: 0;
  transition: color 0.15s ease;
  font-family: inherit;
}

.yener-clear-history:hover {
  color: #ef4444;
}

/* ============================================================
   INPUT AREA
   ============================================================ */

.yener-input-area {
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: flex-end;
  padding: 8px 12px;
  gap: 8px;
  flex-shrink: 0;
  background: #ffffff;
  min-height: 48px;
}

.yener-input-hidden {
  display: none !important;
}

.yener-input-field {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  font-size: 0.9rem;
  color: #1e293b;
  background: transparent;
  line-height: 1.5;
  max-height: 80px;
  overflow-y: auto;
  padding: 6px 0;
  font-family: inherit;
  scrollbar-width: thin;
}

.yener-input-field::placeholder {
  color: #94a3b8;
}

.yener-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #8b5cf6;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease, transform 0.1s ease;
  outline: none;
  padding: 0;
  color: #ffffff;
}

.yener-send-btn:hover {
  background: #7c3aed;
}

.yener-send-btn:active {
  transform: scale(0.92);
}

.yener-send-btn:disabled {
  background: #c4b5fd;
  cursor: not-allowed;
}

.yener-send-btn svg {
  width: 16px;
  height: 16px;
  display: block;
  pointer-events: none;
}

/* ============================================================
   INLINE CONTACT FORM
   ============================================================ */

/* Form wrapper tam genislik */
.yener-msg-bot:has(.yener-contact-form) > div {
  max-width: 100%;
}

.yener-contact-form {
  background: #f8fafc;
  border-radius: 12px;
  padding: 16px;
  margin: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid #e2e8f0;
  width: 100%;
}

.yener-form-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.yener-form-group label {
  font-size: 0.78rem;
  color: #64748b;
  font-weight: 600;
  display: block;
}

.yener-form-input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.85rem;
  color: #1e293b;
  background: #ffffff;
  outline: none;
  transition: border-color 0.15s ease;
  font-family: inherit;
}

.yener-form-textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.85rem;
  color: #1e293b;
  background: #ffffff;
  outline: none;
  transition: border-color 0.15s ease;
  font-family: inherit;
  resize: none;
  min-height: 72px;
}

.yener-form-input:focus,
.yener-form-textarea:focus {
  border-color: #8b5cf6;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12);
}

.yener-form-submit {
  width: 100%;
  background: #8b5cf6;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s ease;
  outline: none;
  font-family: inherit;
}

.yener-form-submit:hover {
  background: #7c3aed;
}

.yener-form-submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.yener-form-success {
  color: #059669;
  font-weight: 500;
  padding: 12px;
  text-align: center;
  font-size: 0.875rem;
}

/* Honeypot — must never be visible */
.yener-honeypot {
  display: none !important;
}

/* ============================================================
   RESPONSIVE — TABLET
   ============================================================ */

@media (max-width: 768px) {
  .yener-window {
    width: 340px;
    height: 480px;
  }
}

/* ============================================================
   RESPONSIVE — MOBILE FULLSCREEN
   ============================================================ */

@media (max-width: 480px) {
  .yener-fab {
    width: 48px;
    height: 48px;
    bottom: 16px;
    right: 16px;
  }

  .yener-tooltip {
    bottom: 74px;
    right: 16px;
  }

  .yener-window {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    bottom: 0;
    right: 0;
    border-radius: 0;
    border: none;
    box-shadow: none;
    padding-bottom: env(safe-area-inset-bottom, 0);
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
  }

  .yener-header {
    border-radius: 0;
  }
}
