/* ============================================================
   if-max Teknoloji — WhatsApp Mesaj Simülasyonu & Sohbet Widget'ı
   ============================================================ */

:root {
  --wa-green: #25D366;
  --wa-green-hover: #20bd5a;
  --wa-dark-green: #075E54;
  --wa-teal: #128C7E;
  --wa-light-green: #DCF8C6;
  --wa-bg-chat: #EFEAE2;
  --wa-bubble-bg: #FFFFFF;
  --wa-text-primary: #111B21;
  --wa-text-secondary: #667781;
  --wa-shadow: 0 12px 36px rgba(0, 0, 0, 0.28);
}

/* ---- Ana Kapsayıcı ---- */
.wa-widget-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  pointer-events: auto;
}

/* ---- Yüzen WhatsApp Butonu ---- */
.wa-float-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: var(--wa-green);
  color: #FFFFFF;
  padding: 12px 20px 12px 16px;
  border-radius: 50px;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.45), 0 2px 6px rgba(0, 0, 0, 0.15);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease, background-color 0.2s ease;
  position: relative;
  outline: none;
  user-select: none;
}

.wa-float-btn:hover {
  background-color: var(--wa-green-hover);
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 10px 28px rgba(37, 211, 102, 0.55), 0 4px 10px rgba(0, 0, 0, 0.2);
}

.wa-float-btn:active {
  transform: translateY(0) scale(0.97);
}

.wa-float-btn__icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wa-float-btn__icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.wa-float-btn__text {
  letter-spacing: 0.2px;
  white-space: nowrap;
}

/* Bildirim Rozeti (Kırmızı/Yeşil Sayaç) */
.wa-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background-color: #EF4444;
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #FFFFFF;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  animation: waPulseBadge 2s infinite ease-in-out;
}

@keyframes waPulseBadge {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}

/* ---- Mesaj Penceresi / Simülasyon Paneli ---- */
.wa-popup-panel {
  position: absolute;
  bottom: 68px;
  right: 0;
  width: 375px;
  max-width: calc(100vw - 32px);
  background-color: #FFFFFF;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--wa-shadow);
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.95);
  transform-origin: bottom right;
  transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1), transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.28s;
  z-index: 10000;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.wa-popup-panel.is-active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Panel Başlığı (WhatsApp Header) */
.wa-panel-header {
  background-color: var(--wa-dark-green);
  color: #FFFFFF;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background-image: linear-gradient(135deg, #075E54 0%, #128C7E 100%);
  position: relative;
}

.wa-agent-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.wa-agent-avatar {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--wa-dark-green);
  font-weight: 800;
  font-size: 16px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  flex-shrink: 0;
}

.wa-agent-avatar svg {
  width: 24px;
  height: 24px;
  fill: var(--wa-teal);
}

.wa-online-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  background-color: var(--wa-green);
  border: 2px solid #FFFFFF;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.1);
}

.wa-agent-details {
  display: flex;
  flex-direction: column;
}

.wa-agent-name {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  color: #FFFFFF;
}

.wa-agent-status {
  font-size: 12px;
  opacity: 0.88;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  color: #E2FBE8;
}

.wa-close-btn {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #FFFFFF;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  transition: background-color 0.2s, transform 0.2s;
}

.wa-close-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: rotate(90deg);
}

/* Panel Sohbet Gövdesi (WhatsApp Chat Pattern Background) */
.wa-panel-body {
  background-color: var(--wa-bg-chat);
  background-image: radial-gradient(rgba(0, 0, 0, 0.05) 1px, transparent 1px);
  background-size: 12px 12px;
  padding: 16px;
  max-height: 390px;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Scrollbar düzeni */
.wa-panel-body::-webkit-scrollbar {
  width: 5px;
}
.wa-panel-body::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 10px;
}

/* Yazıyor Animasyonu (Typing Simulator) */
.wa-typing-indicator {
  align-self: flex-start;
  background-color: var(--wa-bubble-bg);
  padding: 10px 16px;
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 2px;
  animation: waFadeIn 0.3s ease;
}

.wa-typing-indicator span {
  width: 7px;
  height: 7px;
  background-color: #8696A0;
  border-radius: 50%;
  animation: waBounceDot 1.4s infinite ease-in-out both;
}

.wa-typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.wa-typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
.wa-typing-indicator span:nth-child(3) { animation-delay: 0; }

@keyframes waBounceDot {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Gelen Mesaj Balonu */
.wa-chat-bubble {
  background-color: var(--wa-bubble-bg);
  color: var(--wa-text-primary);
  padding: 12px 14px;
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  position: relative;
  font-size: 13.5px;
  line-height: 1.5;
  animation: waPopBubble 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.wa-bubble-text {
  margin: 0 0 6px 0;
  color: #111B21;
}

.wa-bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 11px;
  color: var(--wa-text-secondary);
}

.wa-checks svg {
  width: 14px;
  height: 14px;
  fill: #53BDEB; /* Mavi tik */
}

/* Hızlı Seçenek Butonları */
.wa-options-title {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #54656F;
  margin: 4px 0 2px 2px;
}

.wa-options-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wa-option-btn {
  background: #FFFFFF;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  padding: 10px 12px;
  text-align: left;
  font-size: 13px;
  color: #111B21;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.wa-option-btn:hover {
  border-color: var(--wa-green);
  background-color: #F8FDF9;
  transform: translateX(3px);
}

.wa-option-btn.is-selected {
  background-color: var(--wa-light-green);
  border-color: #25D366;
  font-weight: 600;
  color: #0b4b24;
}

.wa-option-btn .wa-opt-check {
  display: none;
  width: 16px;
  height: 16px;
  color: #0b4b24;
  flex-shrink: 0;
}

.wa-option-btn.is-selected .wa-opt-check {
  display: block;
}

/* Özel Mesaj Yazma Alanı */
.wa-custom-input-wrap {
  margin-top: 4px;
}

.wa-custom-label {
  font-size: 11.5px;
  font-weight: 600;
  color: #54656F;
  margin-bottom: 5px;
  display: block;
}

.wa-custom-input {
  width: 100%;
  box-sizing: border-box;
  background: #FFFFFF;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 16px; /* iOS Safari zoom önleme (min 16px) */
  color: #111B21;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.wa-custom-input:focus {
  border-color: var(--wa-green);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.2);
}

.wa-custom-input::placeholder {
  font-size: 13.5px;
  color: #8696A0;
}

/* Panel Alt Çubuğu (Sohbeti Başlat Butonu) */
.wa-panel-footer {
  padding: 12px 16px;
  background-color: #F0F2F5;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.wa-submit-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background-color: var(--wa-green);
  color: #FFFFFF;
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 700;
  padding: 12px 18px;
  border-radius: 12px;
  transition: background-color 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 3px 10px rgba(37, 211, 102, 0.35);
}

.wa-submit-link:hover {
  background-color: var(--wa-green-hover);
  box-shadow: 0 6px 16px rgba(37, 211, 102, 0.45);
  transform: translateY(-1px);
}

.wa-submit-link:active {
  transform: translateY(1px);
}

.wa-submit-link svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* Animasyonlar */
@keyframes waPopBubble {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes waFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Mobil Ekran Düzenlemeleri (<= 640px) */
@media (max-width: 640px) {
  .wa-widget-wrap {
    bottom: 16px;
    right: 16px;
  }

  .wa-float-btn {
    padding: 0;
    width: 50px;
    height: 50px;
    justify-content: center;
    border-radius: 50%;
  }

  .wa-float-btn__text {
    display: none;
  }

  /* Mobil çözünürlükte sayfanın tamamını kaplamaz; genişlik %75 ve kompakt kart görünümü */
  .wa-popup-panel {
    position: fixed;
    bottom: 16px;
    right: 14px;
    left: auto;
    width: 75%;
    max-width: 325px;
    border-radius: 18px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.35);
    transform: translateY(16px) scale(0.95);
    transform-origin: bottom right;
  }

  .wa-popup-panel.is-active {
    transform: translateY(0) scale(1);
  }

  .wa-panel-header {
    padding: 10px 12px;
    gap: 8px;
  }

  .wa-agent-avatar {
    width: 34px;
    height: 34px;
  }

  .wa-agent-avatar svg {
    width: 18px;
    height: 18px;
  }

  .wa-agent-name {
    font-size: 13.5px;
  }

  .wa-agent-status {
    font-size: 10.5px;
  }

  .wa-close-btn {
    width: 28px;
    height: 28px;
    font-size: 16px;
  }

  .wa-panel-body {
    padding: 10px;
    max-height: min(52vh, 340px);
    gap: 8px;
  }

  .wa-chat-bubble {
    padding: 8px 10px;
    font-size: 12px;
    border-radius: 12px 12px 12px 3px;
  }

  .wa-bubble-text {
    margin-bottom: 4px;
  }

  .wa-options-title {
    font-size: 10.5px;
    margin: 2px 0;
  }

  .wa-options-list {
    gap: 5px;
  }

  .wa-option-btn {
    padding: 7px 10px;
    font-size: 11.5px;
    border-radius: 8px;
    min-height: auto;
  }

  .wa-custom-label {
    font-size: 10.5px;
    margin-bottom: 4px;
  }

  .wa-custom-input {
    padding: 7px 10px;
    font-size: 16px; /* iOS Safari otomatik zoom yapmasını önler */
    border-radius: 8px;
  }

  .wa-panel-footer {
    padding: 8px 10px;
  }

  .wa-submit-link {
    padding: 9px 12px;
    font-size: 13px;
    border-radius: 10px;
  }

  /* Mobil panel açıkken floating butonu gizle */
  .wa-widget-wrap.panel-open .wa-float-btn {
    display: none;
  }
}
