/* Floating Action Button - Enhanced Version */
.floating-share-btn {
  position: fixed;
  bottom: calc(30px + env(safe-area-inset-bottom, 0px));
  right: calc(30px + env(safe-area-inset-right, 0px));
  z-index: 1000;
  pointer-events: none;
  -webkit-tap-highlight-color: transparent; /* suppress iOS blue tap square on container */
  will-change: transform;
  transform: translateZ(0);
}

.floating-share-btn > * {
  pointer-events: auto;
}

@supports (bottom: max(0px)) {
  .floating-share-btn {
    bottom: max(30px, calc(env(safe-area-inset-bottom, 0px) + 16px));
    right: max(30px, calc(env(safe-area-inset-right, 0px) + 16px));
  }
}

.share-main-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent; /* prevent blue tap square on iOS */
  overflow: hidden; /* clip any native highlight to the circle */
  -webkit-mask-image: -webkit-radial-gradient(white, black); /* ensure GPU-composited layers stay circular */
  will-change: transform, box-shadow;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
}

/* Circular press/focus ring to replace iOS square highlight */
.share-main-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.22);
  transition: box-shadow 140ms ease-out;
}

.share-main-btn:active::after {
  box-shadow: 0 0 0 12px rgba(59, 130, 246, 0.18);
}

/* Keep keyboard accessibility but ensure round outline */
.share-main-btn:focus { outline: none; }
.share-main-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.28), 0 6px 20px rgba(59, 130, 246, 0.6);
}

.share-icon-wrapper {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  left: 0px;
  top: 2px;
}

.share-icon-graphic {
  width: 100%;
  height: 100%;
}

.share-main-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
}

.share-main-btn:active {
  transform: scale(1.06);
}

.share-main-btn.active {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.share-menu {
  position: absolute;
  bottom: calc(75px + env(safe-area-inset-bottom, 0px));
  right: 0;
  background: white;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
  padding: 8px;
  min-width: 240px;
  max-height: 70vh;
  overflow-y: auto;
  background-clip: padding-box; /* avoid corner bleed during animation */
  opacity: 0;
  visibility: hidden;
  pointer-events: none; /* prevent clicks while hidden */
  transform: translateY(10px) scale(0.96) translateZ(0);
  transform-origin: bottom right; /* scale from the FAB corner */
  border: 1px solid rgba(0,0,0,0.05);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease-out, box-shadow 0.3s ease-in-out;
  will-change: transform, opacity;
  backface-visibility: hidden;
}

.share-menu.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1) translateZ(0);
}

/* Custom scrollbar for share menu */
.share-menu::-webkit-scrollbar {
  width: 6px;
}

.share-menu::-webkit-scrollbar-track {
  background: transparent;
}

.share-menu::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.share-menu::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.share-menu-header {
  padding: 12px 12px 8px 12px;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 4px;
}

.share-section-header {
  margin-top: 4px;
}

.share-menu-title {
  font-size: 15px;
  font-weight: 600;
  color: #1e293b;
  margin: 0;
}

.share-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  color: #0f172a;
  margin-bottom: 2px;
  position: relative;
  -webkit-tap-highlight-color: transparent; /* prevent blue tap highlight */
}

.share-option:hover {
  background: #f1f5f9;
  transform: translateX(-2px);
}

.share-option:active {
  transform: scale(0.98);
}

.share-option.saved {
  background: #ecfdf5;
  border: 1px solid #86efac;
}

.share-option.saved:hover {
  background: #d1fae5;
}

.share-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  border-radius: 8px;
  transition: transform 0.2s;
}

.share-option:hover .share-icon {
  transform: scale(1.1);
}

.share-label {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: #334155;
}

/* AI Platform Icons */
.share-option-chatgpt .share-icon {
  background: #74aa9c;
  color: white;
  box-shadow: 0 2px 8px rgba(116, 170, 156, 0.3);
}

.share-option-perplexity .share-icon {
  background: #000000;
  color: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.share-option-claude .share-icon {
  background: #d97757;
  color: white;
  box-shadow: 0 2px 8px rgba(217, 119, 87, 0.3);
}

.share-option-google .share-icon {
  background: #4285F4;
  color: white;
  box-shadow: 0 2px 8px rgba(66, 133, 244, 0.3);
}

.share-option-grok .share-icon {
  background: #1DA1F2;
  color: white;
  box-shadow: 0 2px 8px rgba(29, 161, 242, 0.3);
}

/* Social Media Icons */
.share-option-native .share-icon {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

.share-option-twitter .share-icon {
  background: #1DA1F2;
  color: white;
  box-shadow: 0 2px 8px rgba(29, 161, 242, 0.3);
}

.share-option-linkedin .share-icon {
  background: #0A66C2;
  color: white;
  box-shadow: 0 2px 8px rgba(10, 102, 194, 0.3);
}

.share-option-facebook .share-icon {
  background: #1877F2;
  color: white;
  box-shadow: 0 2px 8px rgba(24, 119, 242, 0.3);
}

.share-option-whatsapp .share-icon {
  background: #25D366;
  color: white;
  box-shadow: 0 2px 8px rgba(37, 211, 102, 0.3);
}

.share-option-telegram .share-icon {
  background: #0088cc;
  color: white;
  box-shadow: 0 2px 8px rgba(0, 136, 204, 0.3);
}

.share-option-reddit .share-icon {
  background: #FF4500;
  color: white;
  box-shadow: 0 2px 8px rgba(255, 69, 0, 0.3);
}

.share-option-pinterest .share-icon {
  background: #E60023;
  color: white;
  box-shadow: 0 2px 8px rgba(230, 0, 35, 0.3);
}

.share-option-email .share-icon {
  background: #64748b;
  color: white;
  box-shadow: 0 2px 8px rgba(100, 116, 139, 0.3);
}

.share-option-copy .share-icon {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

.save-badge {
  background: #10b981;
  color: white;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 12px;
  font-weight: 600;
}

/* Section divider */
.share-divider {
  height: 1px;
  background: #e2e8f0;
  margin: 8px 0;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .floating-share-btn {
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    right: calc(20px + env(safe-area-inset-right, 0px));
  }

  .share-main-btn {
    width: 56px;
    height: 56px;
  }

  .share-menu {
    right: 0;
    min-width: min(260px, calc(100vw - 40px));
    max-width: calc(100vw - 40px);
    max-height: 70vh;
    overflow-y: auto;
    bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  }

  .share-option {
    padding: 12px;
  }

  .share-label {
    font-size: 15px;
  }

  @supports (bottom: max(0px)) {
    .floating-share-btn {
      bottom: max(20px, calc(env(safe-area-inset-bottom, 0px) + 12px));
      right: max(20px, calc(env(safe-area-inset-right, 0px) + 12px));
    }

    .share-menu {
      bottom: calc(70px + env(safe-area-inset-bottom, 0px));
    }
  }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
  .share-menu {
    min-width: 250px;
  }
}

/* Desktop large screens */
@media (min-width: 1920px) {
  .floating-share-btn {
    bottom: calc(40px + env(safe-area-inset-bottom, 0px));
    right: calc(40px + env(safe-area-inset-right, 0px));
  }

  .share-main-btn {
    width: 64px;
    height: 64px;
  }
}

/* Animation for menu items */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.share-menu.show .share-option {
  animation: slideIn 0.3s ease-out backwards;
}

.share-menu.show .share-option:nth-child(1) { animation-delay: 0.05s; }
.share-menu.show .share-option:nth-child(2) { animation-delay: 0.08s; }
.share-menu.show .share-option:nth-child(3) { animation-delay: 0.11s; }
.share-menu.show .share-option:nth-child(4) { animation-delay: 0.14s; }
.share-menu.show .share-option:nth-child(5) { animation-delay: 0.17s; }
.share-menu.show .share-option:nth-child(6) { animation-delay: 0.20s; }
.share-menu.show .share-option:nth-child(7) { animation-delay: 0.23s; }
.share-menu.show .share-option:nth-child(8) { animation-delay: 0.26s; }
.share-menu.show .share-option:nth-child(9) { animation-delay: 0.29s; }
.share-menu.show .share-option:nth-child(10) { animation-delay: 0.32s; }
.share-menu.show .share-option:nth-child(11) { animation-delay: 0.35s; }
.share-menu.show .share-option:nth-child(12) { animation-delay: 0.38s; }

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .share-menu {
    background: #1e293b;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1);
  }

  .share-menu-title {
    color: #f1f5f9;
  }

  .share-option {
    color: #f1f5f9;
  }

  .share-option:hover {
    background: #334155;
  }

  .share-label {
    color: #e2e8f0;
  }

  .share-menu-header {
    border-bottom-color: #334155;
  }

  .share-divider {
    background: #334155;
  }

  .share-menu::-webkit-scrollbar-thumb {
    background: #475569;
  }

  .share-menu::-webkit-scrollbar-thumb:hover {
    background: #64748b;
  }
}
