/* ==========================================================================
   BEXGRAM — Modern Masaüstü ve Mobil Etkileşimli Bildirim Motoru
   WhatsApp Web, Telegram & Windows Bildirim Kartı / iOS Heads-up Banner
   ========================================================================== */

#bex-desktop-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  top: auto;
  z-index: 100070;
  display: flex;
  flex-direction: column-reverse;
  gap: 12px;
  pointer-events: none;
  max-width: calc(100vw - 32px);
  width: 380px;
}

.bex-desktop-toast {
  pointer-events: auto;
  position: relative;
  width: 100%;
  background: var(--wa-surface, var(--color-bg-light));
  color: var(--wa-text, var(--color-bg-dark));
  border-radius: 16px;
  border: 1px solid var(--wa-line, rgba(0, 0, 0, 0.1));
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
  padding: 12px 14px 10px 14px;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  cursor: pointer;
  user-select: none;
  overflow: hidden;
  opacity: 0;
  transform: translateY(24px) scale(0.96);
  transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1), 
              transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.2s ease,
              background 0.2s ease;
  touch-action: pan-y;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

html.dark .bex-desktop-toast,
html[data-theme="dark"] .bex-desktop-toast,
html[data-theme="midnight"] .bex-desktop-toast {
  background: var(--wa-surface, #202c33);
  color: var(--wa-text, #e9edef);
  border-color: var(--wa-line, rgba(255, 255, 255, 0.1));
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.35);
}

.bex-desktop-toast.is-shown {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.bex-desktop-toast.is-hiding {
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  transform: translateY(-20px) scale(0.94);
  pointer-events: none;
}

.bex-desktop-toast:hover {
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.18), 0 4px 12px rgba(0, 0, 0, 0.12);
}

html.dark .bex-desktop-toast:hover,
html[data-theme="dark"] .bex-desktop-toast:hover,
html[data-theme="midnight"] .bex-desktop-toast:hover {
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.65), 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* ── Üst Başlık Satırı (Bexgram Favicon & Kapatma Butonu) ── */
.bex-toast-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
}

.bex-toast-brand {
  display: flex;
  align-items: center;
  gap: 7px;
}

.bex-toast-logo {
  width: 17px;
  height: 17px;
  border-radius: 4px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

.bex-toast-app-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--wa-text, var(--color-bg-dark));
  letter-spacing: -0.01em;
}

html.dark .bex-toast-app-name,
html[data-theme="dark"] .bex-toast-app-name,
html[data-theme="midnight"] .bex-toast-app-name {
  color: var(--wa-text, #e9edef);
}

.bex-toast-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bex-toast-expand-toggle {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(0, 168, 132, 0.12);
  color: var(--wa-primary, #00a884);
  border: 1px solid rgba(0, 168, 132, 0.28);
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.bex-toast-expand-toggle:hover {
  background: rgba(0, 168, 132, 0.22);
  color: var(--wa-green-deep, #25d366);
}

.bex-toast-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--wa-muted, #8696a0);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s ease, background 0.15s ease;
}

.bex-toast-close:hover {
  color: var(--wa-text, var(--color-bg-dark));
  background: rgba(0, 0, 0, 0.08);
}

html.dark .bex-toast-close:hover,
html[data-theme="dark"] .bex-toast-close:hover,
html[data-theme="midnight"] .bex-toast-close:hover {
  color: var(--color-bg-light);
  background: rgba(255, 255, 255, 0.1);
}

/* ── Ana İçerik Satırı (Sol Avatar + Sağ Metinler) ── */
.bex-toast-body {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.bex-toast-avatar-wrapper {
  position: relative;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.bex-toast-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--wa-search, #f0f2f5);
  display: block;
}

.bex-toast-icon-placeholder {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--wa-primary, #00a884) 0%, #056162 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-bg-light);
}

.bex-toast-icon-placeholder.is-quest {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.bex-toast-content {
  flex: 1 1 0%;
  min-width: 0;
}

.bex-toast-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--wa-text, var(--color-bg-dark));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
  line-height: 1.3;
}

html.dark .bex-toast-title,
html[data-theme="dark"] .bex-toast-title,
html[data-theme="midnight"] .bex-toast-title {
  color: var(--wa-text, #e9edef);
}

.bex-toast-subtitle {
  font-size: 12.5px;
  color: var(--wa-muted, #667781);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
  line-height: 1.25;
}

.bex-toast-text {
  font-size: 13px;
  color: var(--wa-text, #3b4a54);
  line-height: 1.4;
  margin: 4px 0 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

html.dark .bex-toast-text,
html[data-theme="dark"] .bex-toast-text,
html[data-theme="midnight"] .bex-toast-text {
  color: var(--wa-text, #d1d7db);
}

/* ── Hızlı Yanıt (Quick Reply) Paneli ── */
.bex-toast-quick-reply {
  display: none;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--wa-line, rgba(0, 0, 0, 0.08));
}

html.dark .bex-toast-quick-reply,
html[data-theme="dark"] .bex-toast-quick-reply,
html[data-theme="midnight"] .bex-toast-quick-reply {
  border-top-color: var(--wa-line, rgba(255, 255, 255, 0.08));
}

.bex-desktop-toast.is-expanded .bex-toast-quick-reply {
  display: flex;
}

.bex-toast-reply-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 36px;
  border-radius: 18px;
  background: var(--wa-search, #f0f2f5);
  border: 1px solid var(--wa-line, rgba(0, 0, 0, 0.12));
  color: var(--wa-text, var(--color-bg-dark));
  padding: 0 14px;
  font-size: 13px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s, background 0.15s;
}

html.dark .bex-toast-reply-input,
html[data-theme="dark"] .bex-toast-reply-input,
html[data-theme="midnight"] .bex-toast-reply-input {
  background: rgba(0, 0, 0, 0.28);
  border-color: rgba(255, 255, 255, 0.14);
  color: var(--color-bg-light);
}

.bex-toast-reply-input:focus {
  border-color: var(--wa-primary, #00a884);
}

.bex-toast-reply-input::placeholder {
  color: var(--wa-muted, #8696a0);
}

.bex-toast-reply-send {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  background: var(--wa-primary, #00a884);
  color: var(--color-bg-light);
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 168, 132, 0.35);
}

.bex-toast-reply-send:hover {
  background: #029070;
  transform: scale(1.05);
}

.bex-toast-reply-send:active {
  transform: scale(0.95);
}

.bex-toast-reply-status {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  margin-top: 6px;
  display: none;
}

.bex-toast-reply-status.is-success {
  display: block;
  background: rgba(0, 168, 132, 0.18);
  color: var(--wa-green-deep, #25d366);
  font-weight: 600;
}

.bex-toast-reply-status.is-error {
  display: block;
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
  font-weight: 500;
}

/* ── Alt Durum Çubuğu (Zarf / Rozet / Bilgi) ── */
.bex-toast-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px solid var(--wa-line, rgba(0, 0, 0, 0.06));
}

html.dark .bex-toast-footer,
html[data-theme="dark"] .bex-toast-footer,
html[data-theme="midnight"] .bex-toast-footer {
  border-top-color: var(--wa-line, rgba(255, 255, 255, 0.06));
}

.bex-toast-footer-icon {
  color: var(--wa-muted, #8696a0);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
}

.bex-toast-footer-text {
  font-size: 12px;
  color: var(--wa-muted, #667781);
  font-weight: 500;
  letter-spacing: -0.01em;
}

html.dark .bex-toast-footer-text,
html[data-theme="dark"] .bex-toast-footer-text,
html[data-theme="midnight"] .bex-toast-footer-text {
  color: var(--wa-muted, #8696a0);
}

.bex-toast-footer-text.is-success {
  color: var(--wa-green-deep, #25d366);
  font-weight: 600;
}

.bex-toast-coin-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 9999px;
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  font-size: 11.5px;
  font-weight: 700;
  border: 1px solid rgba(245, 158, 11, 0.3);
  margin-left: auto;
}

/* ── Mobil / Tablet / Çentik Uyumlu Konumlandırma ── */
@media (max-width: 767px) {
  #bex-desktop-toast-container {
    top: max(10px, env(safe-area-inset-top, 10px)) !important;
    bottom: auto !important;
    right: 12px !important;
    left: 12px !important;
    width: auto !important;
    max-width: 100% !important;
    flex-direction: column !important;
    gap: 8px !important;
    z-index: 100070 !important;
  }
  .bex-desktop-toast {
    padding: 11px 13px 9px 13px;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14), 0 2px 6px rgba(0, 0, 0, 0.08);
    transform: translateY(-24px) scale(0.95);
  }
  html.dark .bex-desktop-toast,
  html[data-theme="dark"] .bex-desktop-toast,
  html[data-theme="midnight"] .bex-desktop-toast {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.65), 0 3px 10px rgba(0, 0, 0, 0.4);
  }
  .bex-desktop-toast.is-shown {
    transform: translateY(0) scale(1);
  }
  .bex-desktop-toast.is-hiding {
    transform: translateY(-24px) scale(0.95);
  }
}
