/* ═══════════════════════════════════════════════════════
   TuSocioEnChina — Widget de Contacto Flotante
   Diseño: botón circular con pulso de radar, burbujas de
   opción con física de resorte, modal QR con flip 3D.
═══════════════════════════════════════════════════════ */

:root {
  --tsc-red: #C8102E;
  --tsc-red-dark: #a50d25;
  --tsc-ink: #0D0D12;
  --tsc-wa: #25D366;
  --tsc-wa-dark: #1da851;
  --tsc-wc: #07C160;
  --tsc-wc-dark: #06a850;
  --tsc-glow: rgba(200, 16, 46, 0.35);
}

/* ── Contenedor raíz — fijo, siempre visible, no afecta el layout ── */
.tsc-widget {
  position: fixed;
  right: clamp(16px, 4vw, 28px);
  bottom: clamp(16px, 4vw, 28px);
  z-index: 99998;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --tsc-size: 60px;
}
@media (max-width: 640px) {
  .tsc-widget {
    --tsc-size: 58px;
    --tsc-opt-size: 54px;
    --tsc-opt-icon-size: 27px;
  }
}

/* ── Botón principal ── */
.tsc-fab {
  position: relative;
  width: var(--tsc-size);
  height: var(--tsc-size);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(145deg, var(--tsc-red), var(--tsc-red-dark));
  box-shadow:
    0 4px 14px rgba(200, 16, 46, 0.35),
    0 2px 4px rgba(0, 0, 0, 0.12),
    inset 0 1px 1px rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
  isolation: isolate;
}
.tsc-fab:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow:
    0 8px 22px rgba(200, 16, 46, 0.4),
    0 3px 8px rgba(0, 0, 0, 0.15),
    inset 0 1px 1px rgba(255, 255, 255, 0.3);
}
.tsc-fab:active { transform: translateY(0) scale(0.96); }
.tsc-fab:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

/* Pulso de radar — anillos concéntricos que laten hacia afuera.
   Se pausan automáticamente cuando el menú está abierto. */
.tsc-pulse-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid var(--tsc-red);
  opacity: 0;
  pointer-events: none;
  animation: tsc-pulse 3.2s cubic-bezier(0.2, 0.6, 0.4, 1) infinite;
}
.tsc-pulse-ring:nth-child(2) { animation-delay: 1.6s; }
@keyframes tsc-pulse {
  0%   { transform: scale(1);   opacity: 0.55; }
  70%  { transform: scale(1.9); opacity: 0; }
  100% { transform: scale(1.9); opacity: 0; }
}
.tsc-widget.tsc-open .tsc-pulse-ring { animation-play-state: paused; opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .tsc-pulse-ring { animation: none; display: none; }
}

/* Icono del botón: morphing entre "chat" y "cerrar" (X) */
.tsc-fab-icon {
  position: relative;
  width: 24px;
  height: 24px;
}
.tsc-fab-icon svg {
  position: absolute;
  inset: 0;
  width: 24px;
  height: 24px;
  color: #fff;
  transition: opacity 0.25s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.tsc-icon-chat { opacity: 1; transform: rotate(0deg) scale(1); }
.tsc-icon-close { opacity: 0; transform: rotate(-45deg) scale(0.6); }
.tsc-widget.tsc-open .tsc-icon-chat { opacity: 0; transform: rotate(45deg) scale(0.6); }
.tsc-widget.tsc-open .tsc-icon-close { opacity: 1; transform: rotate(0deg) scale(1); }

/* Insignia de notificación sutil (punto animado) — solo antes de abrir por
   primera vez, para sugerir "hay alguien esperando", sin ser intrusivo */
.tsc-fab-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffc107;
  border: 2px solid #fff;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.tsc-widget.tsc-open .tsc-fab-badge,
.tsc-widget.tsc-dismissed .tsc-fab-badge {
  opacity: 0;
  transform: scale(0);
}

/* ── Burbujas de opción (WhatsApp / WeChat) ── */
.tsc-options {
  position: absolute;
  bottom: calc(var(--tsc-size) + 14px);
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
  pointer-events: none;
}
.tsc-option {
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(14px) scale(0.7);
  transition:
    opacity 0.28s ease,
    transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.tsc-widget.tsc-open .tsc-option {
  pointer-events: auto;
  opacity: 1;
  transform: translateY(0) scale(1);
}
/* Aparecen escalonadas: WeChat (más lejos) primero, WhatsApp después */
.tsc-widget.tsc-open .tsc-option[data-opt="wechat"] { transition-delay: 0.03s; }
.tsc-widget.tsc-open .tsc-option[data-opt="whatsapp"] { transition-delay: 0.1s; }

.tsc-option-label {
  background: rgba(13, 13, 18, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 13px;
  border-radius: 8px;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}

.tsc-option-btn {
  width: var(--tsc-opt-size, 48px);
  height: var(--tsc-opt-size, 48px);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.2),
    inset 0 1px 1px rgba(255, 255, 255, 0.3);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.tsc-option-btn:hover { transform: scale(1.1); }
.tsc-option-btn:active { transform: scale(0.94); }
.tsc-option-btn:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.tsc-option-btn svg { width: var(--tsc-opt-icon-size, 24px); height: var(--tsc-opt-icon-size, 24px); color: #fff; }

.tsc-option-btn.tsc-wa { background: linear-gradient(145deg, var(--tsc-wa), var(--tsc-wa-dark)); }
.tsc-option-btn.tsc-wc { background: linear-gradient(145deg, var(--tsc-wc), var(--tsc-wc-dark)); }

/* ── Overlay + Modal QR de WeChat ── */
.tsc-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(13, 13, 18, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.tsc-modal-overlay.tsc-modal-visible {
  opacity: 1;
  pointer-events: auto;
}

.tsc-modal-card {
  position: relative;
  width: min(380px, 100%);
  background: #fff;
  border-radius: 20px;
  padding: 32px 28px 28px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
  transform: scale(0.85) translateY(10px);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  perspective: 800px;
}
.tsc-modal-overlay.tsc-modal-visible .tsc-modal-card {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.tsc-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  border-radius: 50%;
  border: none;
  background: #f0f0f3 !important;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  line-height: 0;
  transition: background 0.15s ease, transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  -webkit-appearance: none;
  appearance: none;
}
.tsc-modal-close:hover { background: #e4e4e9 !important; transform: rotate(90deg); }
.tsc-modal-close svg {
  width: 16px !important;
  height: 16px !important;
  display: block;
  fill: none !important;
  stroke: var(--tsc-ink) !important;
  color: var(--tsc-ink) !important;
}
.tsc-modal-close svg path {
  stroke: var(--tsc-ink) !important;
  fill: none !important;
}

.tsc-modal-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--tsc-wc), var(--tsc-wc-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  box-shadow: 0 6px 16px rgba(7, 193, 96, 0.35);
}
.tsc-modal-icon svg { width: 26px; height: 26px; color: #fff; }

.tsc-modal-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 24px;
  letter-spacing: 1px;
  color: var(--tsc-ink);
  margin-bottom: 6px;
}
.tsc-modal-sub {
  font-size: 13px;
  color: #6B6B80;
  line-height: 1.5;
  margin-bottom: 20px;
}

.tsc-qr-frame {
  width: 240px;
  height: 240px;
  margin: 0 auto 18px;
  padding: 12px;
  background: #fff;
  border: 1.5px solid #E8E8EC;
  border-radius: 14px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}
.tsc-qr-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 4px;
}

.tsc-modal-id {
  font-size: 12px;
  color: #A0A0B0;
  letter-spacing: 0.3px;
}
.tsc-modal-id strong { color: var(--tsc-ink); font-weight: 700; }

/* ── Responsive: en pantallas muy pequeñas, modal ocupa ancho seguro ── */
@media (max-width: 400px) {
  .tsc-qr-frame { width: 200px; height: 200px; }
  .tsc-modal-card { padding: 28px 20px 24px; }
}

/* Reduced motion: desactivar transiciones de resorte, dejar solo fade */
@media (prefers-reduced-motion: reduce) {
  .tsc-fab, .tsc-option, .tsc-fab-icon svg, .tsc-modal-card, .tsc-option-btn {
    transition-duration: 0.15s !important;
    transition-timing-function: ease !important;
  }
}
