/* Suu — Donation Tracker Widget
 * Floating glassmorphism FAB + panel with animated water bucket.
 * Vanilla CSS, no libraries. Auto-flips to left in RTL (Arabic) pages.
 */

:root {
  --suu-dw-blue: #4A90D9;
  --suu-dw-blue-dark: #2E6FB8;
  --suu-dw-blue-light: #6FB3FF;
  --suu-dw-water-top: rgba(111, 179, 255, 0.95);
  --suu-dw-water-bottom: rgba(46, 111, 184, 0.95);
  --suu-dw-glass-bg: rgba(255, 255, 255, 0.85);
  --suu-dw-glass-border: rgba(255, 255, 255, 0.6);
  --suu-dw-shadow: 0 8px 32px rgba(46, 111, 184, 0.18);
  --suu-dw-shadow-lg: 0 16px 48px rgba(46, 111, 184, 0.25);
  --suu-dw-text: #1a3a5c;
  --suu-dw-text-muted: #5a7a9a;
}

/* === FAB (Floating Action Button) ============================= */
#suu-donation-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fff 0%, #e8f2ff 100%);
  border: 1.5px solid var(--suu-dw-glass-border);
  box-shadow: var(--suu-dw-shadow), 0 0 0 4px rgba(74, 144, 217, 0.12);
  cursor: pointer;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
  animation: suu-dw-pulse 2.8s ease-in-out infinite;
  padding: 0;
  font-family: inherit;
}
#suu-donation-fab:hover {
  transform: scale(1.08);
  box-shadow: var(--suu-dw-shadow-lg), 0 0 0 6px rgba(74, 144, 217, 0.2);
  animation-play-state: paused;
}
#suu-donation-fab:active { transform: scale(0.96); }
#suu-donation-fab:focus-visible {
  outline: 2px solid var(--suu-dw-blue);
  outline-offset: 3px;
}
#suu-donation-fab .suu-dw-fab-drop {
  width: 28px;
  height: 32px;
  filter: drop-shadow(0 2px 4px rgba(46, 111, 184, 0.3));
}

/* RTL: flip FAB to bottom-left */
html[dir="rtl"] #suu-donation-fab,
html[lang="ar"] #suu-donation-fab {
  right: auto;
  left: 24px;
}

@keyframes suu-dw-pulse {
  0%, 100% { box-shadow: var(--suu-dw-shadow), 0 0 0 4px rgba(74, 144, 217, 0.12); }
  50%      { box-shadow: var(--suu-dw-shadow), 0 0 0 10px rgba(74, 144, 217, 0); }
}

/* === Panel ===================================================== */
#suu-donation-panel {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 340px;
  max-width: calc(100vw - 32px);
  background: var(--suu-dw-glass-bg);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1.5px solid var(--suu-dw-glass-border);
  border-radius: 24px;
  box-shadow: var(--suu-dw-shadow-lg);
  z-index: 9997;
  opacity: 0;
  transform: translateY(16px) scale(0.95);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
  font-family: inherit;
  color: var(--suu-dw-text);
}
#suu-donation-panel.suu-dw-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
html[dir="rtl"] #suu-donation-panel,
html[lang="ar"] #suu-donation-panel {
  right: auto;
  left: 24px;
  transform-origin: bottom left;
}

.suu-dw-header {
  padding: 18px 20px 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.suu-dw-header-text { flex: 1; min-width: 0; }
.suu-dw-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 4px;
  color: var(--suu-dw-text);
  line-height: 1.3;
}
.suu-dw-subtitle {
  font-size: 12px;
  color: var(--suu-dw-text-muted);
  line-height: 1.45;
  margin: 0;
}
.suu-dw-close {
  background: rgba(0, 0, 0, 0.05);
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  color: var(--suu-dw-text);
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
  padding: 0;
  font-family: inherit;
}
.suu-dw-close:hover { background: rgba(0, 0, 0, 0.1); }

/* === Bucket animation ========================================== */
.suu-dw-bucket-wrap {
  padding: 8px 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.suu-dw-bucket {
  position: relative;
  width: 130px;
  height: 130px;
  margin: 0 auto 12px;
}
.suu-dw-bucket svg {
  width: 100%;
  height: 100%;
  display: block;
}
/* The mask reveals water inside the bucket shape; height is set via JS */
.suu-dw-water {
  fill: url(#suu-dw-water-gradient);
  transition: transform 1.2s cubic-bezier(0.22, 1, 0.36, 1);
  transform-origin: center bottom;
}
.suu-dw-wave {
  fill: rgba(255, 255, 255, 0.25);
  animation: suu-dw-wave 4s ease-in-out infinite;
}

@keyframes suu-dw-wave {
  0%, 100% { transform: translateX(-4px); }
  50%      { transform: translateX(4px); }
}

.suu-dw-percent {
  font-size: 22px;
  font-weight: 800;
  color: var(--suu-dw-blue-dark);
  letter-spacing: -0.5px;
  margin-top: 2px;
}
.suu-dw-amount-row {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 6px;
  font-size: 13px;
  color: var(--suu-dw-text-muted);
  margin-top: 2px;
}
.suu-dw-amount-row strong {
  color: var(--suu-dw-text);
  font-weight: 700;
}

/* === Actions =================================================== */
.suu-dw-actions {
  padding: 0 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.suu-dw-btn {
  width: 100%;
  background: var(--suu-dw-blue);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.suu-dw-btn:hover { background: var(--suu-dw-blue-dark); }
.suu-dw-btn:active { transform: scale(0.98); }
.suu-dw-btn.suu-dw-btn-secondary {
  background: rgba(74, 144, 217, 0.1);
  color: var(--suu-dw-blue-dark);
}
.suu-dw-btn.suu-dw-btn-secondary:hover { background: rgba(74, 144, 217, 0.2); }

.suu-dw-footer {
  font-size: 10.5px;
  color: var(--suu-dw-text-muted);
  text-align: center;
  padding: 0 20px 14px;
  line-height: 1.4;
}

/* === Receipts view ============================================= */
.suu-dw-receipts {
  display: none;
  padding: 8px 20px 18px;
  max-height: 320px;
  overflow-y: auto;
}
.suu-dw-receipts.suu-dw-show { display: block; }
.suu-dw-receipts-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.suu-dw-back-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--suu-dw-blue);
  font-size: 18px;
  padding: 0 4px;
  font-family: inherit;
  line-height: 1;
}
html[dir="rtl"] .suu-dw-back-btn,
html[lang="ar"] .suu-dw-back-btn {
  transform: scaleX(-1);
}
.suu-dw-receipts-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--suu-dw-text);
}
.suu-dw-receipt-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.suu-dw-receipt-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(74, 144, 217, 0.07);
  border-radius: 10px;
  font-size: 12.5px;
}
.suu-dw-receipt-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.suu-dw-receipt-charity {
  font-weight: 600;
  color: var(--suu-dw-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.suu-dw-receipt-date {
  font-size: 11px;
  color: var(--suu-dw-text-muted);
}
.suu-dw-receipt-amount {
  font-weight: 700;
  color: var(--suu-dw-blue-dark);
  font-size: 12px;
  margin-right: 4px;
}
html[dir="rtl"] .suu-dw-receipt-amount,
html[lang="ar"] .suu-dw-receipt-amount {
  margin-right: 0;
  margin-left: 4px;
}
.suu-dw-receipt-link {
  background: var(--suu-dw-blue);
  color: white !important;
  text-decoration: none;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  transition: background 0.15s;
  flex-shrink: 0;
}
.suu-dw-receipt-link:hover { background: var(--suu-dw-blue-dark); }
.suu-dw-no-receipts {
  font-size: 12px;
  color: var(--suu-dw-text-muted);
  text-align: center;
  padding: 24px 12px;
  line-height: 1.5;
}

/* === Mobile ====================================================
 * NOT: Sitede 768px altında .sticky-download-bar (App Store / Google
 * Play butonları, ~72px yüksek, bottom:0, z-index:9999) görünüyor.
 * FAB'i bu barın üstüne çıkarmak için bottom değerini artırıyoruz.
 */
@media (max-width: 768px) {
  #suu-donation-fab {
    bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    right: 14px;
    width: 54px;
    height: 54px;
  }
  html[dir="rtl"] #suu-donation-fab,
  html[lang="ar"] #suu-donation-fab {
    right: auto;
    left: 14px;
  }
  #suu-donation-fab .suu-dw-fab-drop {
    width: 24px;
    height: 28px;
  }
  #suu-donation-panel {
    bottom: calc(156px + env(safe-area-inset-bottom, 0px));
    right: 12px;
    width: calc(100vw - 24px);
  }
  html[dir="rtl"] #suu-donation-panel,
  html[lang="ar"] #suu-donation-panel {
    left: 12px;
    right: auto;
  }
}

/* === Reduced motion =========================================== */
@media (prefers-reduced-motion: reduce) {
  #suu-donation-fab { animation: none; }
  .suu-dw-wave { animation: none; }
  .suu-dw-water { transition: none; }
}

/* === Dark mode (system preference) ============================ */
@media (prefers-color-scheme: dark) {
  #suu-donation-panel {
    background: rgba(26, 38, 56, 0.92);
    color: #e8f2ff;
    border-color: rgba(255, 255, 255, 0.1);
  }
  #suu-donation-fab {
    background: linear-gradient(135deg, #2a3a52 0%, #1a2638 100%);
  }
  .suu-dw-title { color: #e8f2ff; }
  .suu-dw-subtitle, .suu-dw-amount-row, .suu-dw-receipt-date { color: #9ab4d4; }
  .suu-dw-amount-row strong, .suu-dw-receipts-title, .suu-dw-receipt-charity { color: #e8f2ff; }
  .suu-dw-percent { color: var(--suu-dw-blue-light); }
  .suu-dw-close { background: rgba(255, 255, 255, 0.08); color: #e8f2ff; }
  .suu-dw-close:hover { background: rgba(255, 255, 255, 0.15); }
  .suu-dw-receipt-item { background: rgba(111, 179, 255, 0.1); }
  .suu-dw-btn.suu-dw-btn-secondary {
    background: rgba(111, 179, 255, 0.15);
    color: var(--suu-dw-blue-light);
  }
}
