/* ═══════════════════════════════════════════════════════════════
   SAM Support Button v1.2 — Frontend Styles
   سام وب | sam-web.ir
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700&display=swap');

:root {
  --sam-font: 'Vazirmatn', 'Tahoma', sans-serif;
  --sam-radius: 14px;
  --sam-shadow: 0 6px 28px rgba(0,0,0,.14), 0 2px 8px rgba(0,0,0,.10);
  --sam-transition: .28s cubic-bezier(.4,0,.2,1);
  --sam-popup-bg: #ffffff;
  --sam-overlay-bg: rgba(10,10,20,.45);
}

/* ══ Wrapper ══ */
#sam-support-wrap {
  position: fixed;
  bottom: 26px;
  z-index: 99990;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  font-family: var(--sam-font);
}

/* ══ FAB wrapper (icon + floating label) ══ */
#sam-fab-wrap {
  display: flex;
  align-items: center;
  gap: 0;
  cursor: pointer;
  position: relative;
}

/* The round icon button */
#sam-fab {
  all: unset;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  box-shadow:
    0 4px 18px rgba(0,0,0,.28),
    0 0 0 6px rgba(255,255,255,.10),
    0 0 0 12px rgba(255,255,255,.05);
  transition: transform var(--sam-transition), box-shadow var(--sam-transition);
  z-index: 2;
}

#sam-fab::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.18) 0%, transparent 70%);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--sam-transition);
}

#sam-fab:hover {
  transform: translateY(-3px) scale(1.06);
  box-shadow:
    0 8px 28px rgba(0,0,0,.32),
    0 0 0 8px rgba(255,255,255,.12),
    0 0 0 16px rgba(255,255,255,.06);
}

#sam-fab:hover::after { opacity: 1; }
#sam-fab:active { transform: scale(.96); }

/* Pulse ring */
.sam-fab-ring {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2.5px solid currentColor;
  opacity: .45;
  animation: samPulse 2.4s ease-out infinite;
  pointer-events: none;
}

@keyframes samPulse {
  0%   { transform: scale(1);    opacity: .45; }
  65%  { transform: scale(1.55); opacity: 0;   }
  100% { transform: scale(1.55); opacity: 0;   }
}

.sam-fab-icon { display: flex; align-items: center; justify-content: center; }
.sam-fab-icon svg { width: 24px; height: 24px; }

/* Floating label */
.sam-fab-label {
  display: inline-block;
  background: rgba(255,255,255,.95);
  color: #1a1a2e;
  font-family: var(--sam-font);
  font-size: 12.5px;
  font-weight: 700;
  padding: 5px 12px 5px 14px;
  border-radius: 20px 0 0 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,.14);
  white-space: nowrap;
  direction: rtl;
  pointer-events: none;
  margin-right: -4px;
  z-index: 1;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid rgba(0,0,0,.06);
  border-left: none;
}

#sam-support-wrap[style*="right"] #sam-fab-wrap { flex-direction: row-reverse; }
#sam-support-wrap[style*="right"] .sam-fab-label {
  border-radius: 0 20px 20px 0;
  margin-right: 0;
  margin-left: -4px;
  border-right: none;
  border-left: 1px solid rgba(0,0,0,.06);
}

/* ══ Overlay ══ */
#sam-overlay {
  position: fixed;
  inset: 0;
  background: var(--sam-overlay-bg);
  z-index: 99991;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--sam-transition);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
#sam-overlay.sam-visible { opacity: 1; pointer-events: all; }

/* ══ Popup ══ */
#sam-popup {
  position: absolute;
  bottom: calc(100% + 14px);
  z-index: 99999;
  width: 300px;
  max-width: calc(100vw - 48px);
  background: var(--sam-popup-bg);
  border-radius: var(--sam-radius);
  box-shadow: var(--sam-shadow);
  font-family: var(--sam-font);
  direction: rtl;
  transform: translateY(10px) scale(.95);
  transform-origin: bottom center;
  opacity: 0;
  pointer-events: none;
  transition: transform var(--sam-transition), opacity var(--sam-transition);
  overflow: hidden;
  border: 1px solid rgba(0,0,0,.07);
}

#sam-popup.sam-visible {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

#sam-support-wrap[style*="left:"] #sam-popup  { left: 0;  right: auto; }
#sam-support-wrap[style*="right:"] #sam-popup { right: 0; left: auto; }

/* ══ Popup Header ══ */
.sam-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 12px;
  background: var(--sam-btn-color, #1a73e8);
  color: #fff;
  position: relative;
  overflow: hidden;
}

.sam-popup-header::before {
  content: '';
  position: absolute;
  top: -30px; right: -30px;
  width: 100px; height: 100px;
  border-radius: 50%;
  background: rgba(255,255,255,.10);
  pointer-events: none;
}
.sam-popup-header::after {
  content: '';
  position: absolute;
  bottom: -20px; left: 10px;
  width: 70px; height: 70px;
  border-radius: 50%;
  background: rgba(255,255,255,.07);
  pointer-events: none;
}

.sam-popup-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  z-index: 1;
}

.sam-popup-icon {
  width: 38px; height: 38px;
  background: rgba(255,255,255,.22);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sam-popup-icon svg { width: 20px; height: 20px; }

.sam-popup-title {
  margin: 0 0 2px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  text-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.sam-popup-subtitle {
  margin: 0;
  font-size: 11px;
  opacity: .85;
  font-weight: 400;
}

#sam-close {
  all: unset;
  width: 30px; height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  cursor: pointer;
  transition: background var(--sam-transition), transform var(--sam-transition);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
#sam-close svg { width: 16px; height: 16px; }
#sam-close:hover { background: rgba(255,255,255,.32); transform: rotate(90deg); }

/* ══ Platforms ══ */
.sam-platforms {
  padding: 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sam-platform-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  text-decoration: none;
  color: #1a1a2e;
  transition: background var(--sam-transition), transform var(--sam-transition);
  position: relative;
  overflow: hidden;
}

.sam-platform-item::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--plat-color);
  opacity: 0;
  transition: opacity var(--sam-transition);
  border-radius: 10px;
}

.sam-platform-item:hover { transform: translateX(-2px); color: #fff; }
.sam-platform-item:hover::before { opacity: 1; }
.sam-platform-item:hover .sam-plat-label { color: #fff; }
.sam-platform-item:hover .sam-plat-arrow { color: rgba(255,255,255,.65); transform: translateX(-3px); }
.sam-platform-item:hover .sam-plat-icon-wrap { background: rgba(255,255,255,.25); }

/* آیکون رپر — بدون بک‌گراند اختصاصی، رنگ از --plat-color */
.sam-plat-icon-wrap {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--plat-color) 13%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--sam-transition);
  position: relative;
  z-index: 1;
  overflow: hidden;
}

/* همه SVGها با currentColor رنگ می‌گیرند — بدون بک‌گراند دایره */
.sam-plat-icon-wrap svg {
  width: 22px;
  height: 22px;
  color: var(--plat-color);
  flex-shrink: 0;
  display: block;
}

/* روی hover، آیکون سفید می‌شه */
.sam-platform-item:hover .sam-plat-icon-wrap svg {
  color: #fff;
}

/* آیکون‌های تصویری */
.sam-plat-img-icon {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 9px;
  display: block;
}

.sam-plat-label {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: #2d2d3a;
  transition: color var(--sam-transition);
  position: relative;
  z-index: 1;
}

.sam-plat-arrow {
  color: #ccc;
  display: flex;
  align-items: center;
  transition: color var(--sam-transition), transform var(--sam-transition);
  position: relative;
  z-index: 1;
}
.sam-plat-arrow svg { width: 16px; height: 16px; }

/* ══ Mobile ══ */
@media (max-width: 600px) {
  #sam-popup {
    width: 280px;
    max-width: calc(100vw - 40px);
  }
  #sam-support-wrap { bottom: 20px; }
  .sam-fab-ring { animation: samPulse 2.8s ease-out infinite; }
}

/* ══ Dark Mode ══ */
@media (prefers-color-scheme: dark) {
  :root {
    --sam-popup-bg: #1c1c2e;
    --sam-overlay-bg: rgba(0,0,0,.65);
  }
  .sam-platform-item { color: #e0e0f0; }
  .sam-plat-label { color: #dde0f5; }
  .sam-plat-arrow { color: #444465; }
  .sam-fab-label {
    background: rgba(30,30,50,.92);
    color: #e8e8ff;
    border-color: rgba(255,255,255,.1);
  }
}
