/**
 * FLOATING ACTION BUTTON (FAB) SYSTEM
 * Modern mobile-first conversion optimization
 * Inspired by: Intercom, Calendly, Linear, Webflow (2026)
 */

/* ============================================
   FAB CONTAINER
   ============================================ */
.fab-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1rem;
  pointer-events: none;
}

.fab-container > * {
  pointer-events: auto;
}

/* ============================================
   MAIN FAB BUTTON
   ============================================ */
.fab-main {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
  box-shadow: 
    0 8px 24px rgba(124, 58, 237, 0.4),
    0 4px 12px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  will-change: transform;
  overflow: hidden;
}

/* Animated gradient border */
.fab-main::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: linear-gradient(
    var(--fab-angle, 0deg),
    var(--primary-color),
    var(--secondary-color),
    var(--accent-color)
  );
  z-index: -1;
  opacity: 0;
  transition: opacity 0.3s ease;
  animation: rotateBorder 4s linear infinite;
}

@property --fab-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

@keyframes rotateBorder {
  from { --fab-angle: 0deg; }
  to { --fab-angle: 360deg; }
}

.fab-main:hover::before {
  opacity: 1;
}

/* Pulse animation */
.fab-main::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
  opacity: 0;
  animation: fabPulse 2s ease-in-out infinite;
}

@keyframes fabPulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0;
  }
  50% {
    transform: scale(1.2);
    opacity: 0.5;
  }
}

.fab-main:hover {
  transform: scale(1.1) translateY(-2px);
  box-shadow: 
    0 12px 32px rgba(124, 58, 237, 0.5),
    0 6px 16px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.fab-main:active {
  transform: scale(0.95);
}

/* Icon rotation when menu is open */
.fab-main.active .fab-icon {
  transform: rotate(135deg);
}

.fab-icon {
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================
   SPEED DIAL MENU
   ============================================ */
.fab-menu {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.fab-menu.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Menu items */
.fab-menu-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  opacity: 0;
  transform: translateX(20px);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fab-menu.active .fab-menu-item {
  opacity: 1;
  transform: translateX(0);
}

/* Staggered animation delays */
.fab-menu.active .fab-menu-item:nth-child(1) { transition-delay: 0.05s; }
.fab-menu.active .fab-menu-item:nth-child(2) { transition-delay: 0.1s; }
.fab-menu.active .fab-menu-item:nth-child(3) { transition-delay: 0.15s; }
.fab-menu.active .fab-menu-item:nth-child(4) { transition-delay: 0.2s; }

/* Menu item label */
.fab-menu-label {
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(12px);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 
    0 4px 12px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.1);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.fab-menu-item:hover .fab-menu-label {
  opacity: 1;
}

/* Menu item button */
.fab-menu-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: white;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 
    0 4px 12px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.fab-menu-btn:hover {
  transform: scale(1.1) translateY(-2px);
  background: rgba(30, 41, 59, 0.95);
  box-shadow: 
    0 6px 16px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.fab-menu-btn:active {
  transform: scale(0.95);
}

/* Color variants for different actions */
.fab-menu-btn.call {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-color: rgba(16, 185, 129, 0.3);
}

.fab-menu-btn.email {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  border-color: rgba(59, 130, 246, 0.3);
}

.fab-menu-btn.whatsapp {
  background: linear-gradient(135deg, #25d366 0%, #1ea952 100%);
  border-color: rgba(37, 211, 102, 0.3);
}

.fab-menu-btn.booking {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  border-color: rgba(124, 58, 237, 0.3);
}

/* ============================================
   TOOLTIP
   ============================================ */
.fab-tooltip {
  position: absolute;
  right: 80px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(12px);
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 
    0 8px 24px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.1);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 10000;
}

.fab-tooltip::after {
  content: '';
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%) rotate(45deg);
  width: 12px;
  height: 12px;
  background: rgba(17, 24, 39, 0.95);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.fab-main:hover .fab-tooltip {
  opacity: 1;
  right: 75px;
}

/* ============================================
   SCROLL BEHAVIOR
   ============================================ */
.fab-container.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(100px);
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ============================================
   MOBILE OPTIMIZATIONS
   ============================================ */
@media (max-width: 768px) {
  .fab-container {
    bottom: 1.5rem;
    right: 1.5rem;
  }

  .fab-main {
    width: 56px;
    height: 56px;
    font-size: 22px;
  }

  .fab-menu-btn {
    width: 44px;
    height: 44px;
    font-size: 18px;
  }

  .fab-menu-label {
    font-size: 13px;
    padding: 0.4rem 0.8rem;
  }

  .fab-tooltip {
    font-size: 14px;
    padding: 0.6rem 1rem;
    right: 70px;
  }

  .fab-main:hover .fab-tooltip {
    right: 65px;
  }
}

@media (max-width: 480px) {
  .fab-container {
    bottom: 1rem;
    right: 1rem;
  }

  .fab-main {
    width: 52px;
    height: 52px;
  }

  /* Hide labels on very small screens to save space */
  .fab-menu-label {
    display: none;
  }
}

/* ============================================
   DARK MODE SUPPORT
   ============================================ */
@media (prefers-color-scheme: light) {
  .fab-menu-label,
  .fab-menu-btn,
  .fab-tooltip {
    background: rgba(255, 255, 255, 0.95);
    color: var(--text-color);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 
      0 4px 12px rgba(0, 0, 0, 0.15),
      inset 0 1px 0 rgba(255, 255, 255, 0.5);
  }

  .fab-tooltip::after {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(0, 0, 0, 0.1);
  }

  .fab-menu-btn:hover {
    background: rgba(243, 244, 246, 0.95);
  }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
.fab-main:focus-visible,
.fab-menu-btn:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 4px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .fab-main,
  .fab-menu,
  .fab-menu-item,
  .fab-menu-btn,
  .fab-tooltip {
    animation: none !important;
    transition-duration: 0.05s !important;
  }

  .fab-main::after {
    display: none;
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  .fab-container {
    display: none;
  }
}
