/* Custom Floating Buttons Styles */

.cfb-floating-buttons {
  position: fixed;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cfb-floating-buttons.left {
  left: 20px;
}

.cfb-floating-buttons.right {
  right: 20px;
}

.cfb-floating-buttons.center-left {
  left: 50%;
  transform: translate(-10px, -50%);
  top: 50%;
}

.cfb-floating-buttons.center-right {
  right: 50%;
  transform: translate(10px, -50%);
  top: 50%;
}

.cfb-floating-buttons.top-center {
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
}

.cfb-floating-buttons.bottom-center {
  top: auto;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
}

/* Shortcode positioning variations */
.cfb-floating-buttons.cfb-floating-buttons-left {
  left: 20px;
  right: auto;
  top: 50%;
  transform: translateY(-50%);
}

.cfb-floating-buttons.cfb-floating-buttons-right {
  right: 20px;
  left: auto;
  top: 50%;
  transform: translateY(-50%);
}

.cfb-floating-buttons.cfb-shortcode-buttons {
  position: relative;
  margin: 10px;
}

/* Enhanced Collapsible toggle feature */
.cfb-has-toggle .cfb-toggle-container {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 5px;
}

/* Frontend Toggle Button Styles */
.cfb-floating-buttons .cfb-toggle-button {
  width: 44px !important;
  height: 44px !important;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.8);
  /* Background color comes from inline styles in PHP */
  color: #ffffff !important;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  margin: 0 auto;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 10;
  position: relative;
  overflow: hidden;
  font-size: 16px;
}

.cfb-floating-buttons .cfb-toggle-button i {
  font-size: 16px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  z-index: 1;
}

.cfb-floating-buttons .cfb-toggle-button::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.3s ease, height 0.3s ease;
}

.cfb-floating-buttons .cfb-toggle-button:hover::before {
  width: 120%;
  height: 120%;
}

.cfb-floating-buttons .cfb-toggle-button:hover {
  /* Dynamic hover - enhances user's chosen color */
  filter: brightness(1.15) saturate(1.3);
  /* Keep tactile visual feedback */
  transform: scale(1.08) rotate(5deg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3),
    inset 0 2px 0 rgba(255, 255, 255, 0.3);
}

.cfb-floating-buttons .cfb-toggle-button:focus {
  outline: 2px solid rgba(0, 123, 186, 0.6);
  outline-offset: 2px;
}

.cfb-floating-buttons .cfb-touch-active,
.cfb-touch-active {
  background: rgba(0, 153, 216, 1) !important;
  transform: scale(0.95) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
}

/* Toggle button rotation based on direction and state */
.cfb-floating-buttons.cfb-collapsed .cfb-toggle-left i,
.cfb-floating-buttons.cfb-collapsed .cfb-toggle-center-left i,
.cfb-floating-buttons.cfb-collapsed .cfb-toggle-up i {
  transform: scaleX(-1); /* Flip horizontally */
}

.cfb-floating-buttons.cfb-collapsed .cfb-toggle-right i,
.cfb-floating-buttons.cfb-collapsed .cfb-toggle-center-right i,
.cfb-floating-buttons.cfb-collapsed .cfb-toggle-down i {
  transform: scaleX(-1); /* Flip horizontally */
}

/* Collapse animation based on button position - High Specificity */
.cfb-floating-buttons.cfb-collapsed.left .cfb-button,
.cfb-floating-buttons.cfb-collapsed.center-left .cfb-button,
.cfb-floating-buttons.cfb-has-toggle.cfb-collapsed.left .cfb-button,
.cfb-floating-buttons.cfb-has-toggle.cfb-collapsed.center-left .cfb-button {
  transform: translate(-200px, -50%) scale(0) !important;
  -webkit-transform: translate(-200px, -50%) scale(0) !important;
  -moz-transform: translate(-200px, -50%) scale(0) !important;
  -o-transform: translate(-200px, -50%) scale(0) !important;
}

.cfb-floating-buttons.cfb-collapsed.right .cfb-button,
.cfb-floating-buttons.cfb-collapsed.center-right .cfb-button,
.cfb-floating-buttons.cfb-has-toggle.cfb-collapsed.right .cfb-button,
.cfb-floating-buttons.cfb-has-toggle.cfb-collapsed.center-right .cfb-button {
  transform: translate(200px, -50%) scale(0) !important;
  -webkit-transform: translate(200px, -50%) scale(0) !important;
  -moz-transform: translate(200px, -50%) scale(0) !important;
  -o-transform: translate(200px, -50%) scale(0) !important;
}

.cfb-floating-buttons.cfb-collapsed.top-center .cfb-button,
.cfb-floating-buttons.cfb-has-toggle.cfb-collapsed.top-center .cfb-button {
  transform: translateY(-200px) scale(0) !important;
  -webkit-transform: translateY(-200px) scale(0) !important;
  -moz-transform: translateY(-200px) scale(0) !important;
  -o-transform: translateY(-200px) scale(0) !important;
}

.cfb-floating-buttons.cfb-collapsed.bottom-center .cfb-button,
.cfb-floating-buttons.cfb-has-toggle.cfb-collapsed.bottom-center .cfb-button {
  transform: translateY(200px) scale(0) !important;
  -webkit-transform: translateY(200px) scale(0) !important;
  -moz-transform: translateY(200px) scale(0) !important;
  -o-transform: translateY(200px) scale(0) !important;
}

.cfb-floating-buttons.cfb-collapsed .cfb-button,
.cfb-floating-buttons.cfb-has-toggle.cfb-collapsed .cfb-button {
  opacity: 0 !important;
  pointer-events: none !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  -webkit-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  -moz-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  -o-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Remove transition from buttons when toggle is active to prevent conflicts with entrance animations */
.cfb-has-toggle .cfb-button:not(.cfb-button-expanding) {
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Ensure entrance animation takes priority and doesn't get overridden */
.cfb-floating-buttons .cfb-button.cfb-button-expanding,
.cfb-floating-buttons.cfb-has-toggle .cfb-button.cfb-button-expanding {
  transition: none !important;
  animation-fill-mode: forwards !important;
}

/* Enhanced Toggle Animations - High Specificity to Override Conflicts */
.cfb-floating-buttons .cfb-button.cfb-button-expanding,
.cfb-floating-buttons.cfb-has-toggle .cfb-button.cfb-button-expanding {
  animation: cfb-buttonExpandIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards !important;
  -webkit-animation: cfb-buttonExpandIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1)
    forwards !important;
  -moz-animation: cfb-buttonExpandIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1)
    forwards !important;
  -o-animation: cfb-buttonExpandIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1)
    forwards !important;
  transform: translateY(0) scale(1) !important;
  -webkit-transform: translateY(0) scale(1) !important;
  -moz-transform: translateY(0) scale(1) !important;
  -o-transform: translateY(0) scale(1) !important;
  opacity: 1 !important;
}

/* Browser-specific keyframes */
@-webkit-keyframes cfb-buttonExpandIn {
  0% {
    -webkit-transform: translateY(20px) scale(0.8) !important;
    opacity: 0 !important;
  }
  50% {
    -webkit-transform: translateY(-5px) scale(1.1) !important;
    opacity: 0.8 !important;
  }
  100% {
    -webkit-transform: translateY(0) scale(1) !important;
    opacity: 1 !important;
  }
}

@-moz-keyframes cfb-buttonExpandIn {
  0% {
    -moz-transform: translateY(20px) scale(0.8) !important;
    opacity: 0 !important;
  }
  50% {
    -moz-transform: translateY(-5px) scale(1.1) !important;
    opacity: 0.8 !important;
  }
  100% {
    -moz-transform: translateY(0) scale(1) !important;
    opacity: 1 !important;
  }
}

@-o-keyframes cfb-buttonExpandIn {
  0% {
    -o-transform: translateY(20px) scale(0.8) !important;
    opacity: 0 !important;
  }
  50% {
    -o-transform: translateY(-5px) scale(1.1) !important;
    opacity: 0.8 !important;
  }
  100% {
    -o-transform: translateY(0) scale(1) !important;
    opacity: 1 !important;
  }
}

@keyframes cfb-buttonExpandIn {
  0% {
    transform: translateY(20px) scale(0.8) !important;
    opacity: 0 !important;
  }
  50% {
    transform: translateY(-5px) scale(1.1) !important;
    opacity: 0.8 !important;
  }
  100% {
    transform: translateY(0) scale(1) !important;
    opacity: 1 !important;
  }
}

/* Hover Preview - Subtle reveal on collapsed state */
.cfb-hover-preview .cfb-button {
  transform: translateY(0) scale(0.1) !important;
  opacity: 0.3 !important;
  pointer-events: none !important;
  transition: all 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.cfb-hover-preview .cfb-button:nth-child(1) {
  transform: translateY(0) scale(0.3) !important;
}

.cfb-hover-preview .cfb-button:nth-child(2) {
  transform: translateY(0) scale(0.25) !important;
}

.cfb-hover-preview .cfb-button:nth-child(3) {
  transform: translateY(0) scale(0.2) !important;
}

/* Better mobile touch feedback */
@media (max-width: 768px) {
  .cfb-floating-buttons .cfb-toggle-button {
    width: 48px !important;
    height: 48px !important;
  }

  .cfb-floating-buttons .cfb-toggle-button i {
    font-size: 18px;
  }
}

/* Hover labels feature */
.cfb-has-labels .cfb-button::after {
  content: attr(title);
  position: absolute;
  background: rgba(0, 0, 0, 0.85);
  color: #ffffff;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
}

/* Position labels intelligently based on button position */
.cfb-floating-buttons.left .cfb-button::after,
.cfb-floating-buttons.center-left .cfb-button::after {
  top: 50%;
  transform: translateY(-50%);
  left: 100%;
  margin-left: 10px;
}

.cfb-floating-buttons.right .cfb-button::after,
.cfb-floating-buttons.center-right .cfb-button::after {
  top: 50%;
  transform: translateY(-50%);
  right: 100%;
  margin-right: 10px;
}

.cfb-floating-buttons.top-center .cfb-button::after {
  left: 50%;
  transform: translateX(-50%);
  bottom: 100%;
  margin-bottom: 10px;
}

.cfb-floating-buttons.bottom-center .cfb-button::after {
  left: 50%;
  transform: translateX(-50%);
  top: 100%;
  margin-top: 10px;
}

.cfb-has-labels .cfb-button:hover::after {
  opacity: 1;
}

/* Prevent label from showing when buttons are collapsed */
.cfb-floating-buttons.cfb-collapsed .cfb-button::after {
  opacity: 0 !important;
}

.cfb-button {
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  text-decoration: none;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.cfb-button:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.cfb-button i,
.cfb-button img {
  object-fit: contain;
}

/* Ensure FontAwesome icons display properly */
.cfb-button i {
  display: block !important;
  line-height: 1 !important;
  font-style: normal !important;
}

/* Unicode arrow fallback styles for when FontAwesome fails */
.cfb-unicode-arrow {
  font-size: 16px !important;
  font-weight: bold !important;
  color: inherit !important;
  text-decoration: none !important;
  line-height: 1 !important;
  display: inline-block !important;
}

.cfb-floating-buttons.fade-in {
  opacity: 1;
}

.cfb-floating-buttons.fade-out {
  opacity: 0;
}

.cfb-floating-buttons.slide-left-enter {
  transform: translateY(-50%) translateX(100%);
}

.cfb-floating-buttons.slide-left-active {
  transform: translateY(-50%) translateX(0);
  transition: transform 0.3s ease;
}

.cfb-floating-buttons.slide-right-enter {
  transform: translateY(-50%) translateX(-100%);
}

.cfb-floating-buttons.slide-right-active {
  transform: translateY(-50%) translateX(0);
  transition: transform 0.3s ease;
}

.cfb-floating-buttons.bounce-in {
  animation: bounceIn 0.6s ease;
}

.cfb-floating-buttons.scale-in {
  animation: scaleIn 0.5s ease;
}

.cfb-floating-buttons.pulse {
  animation: pulse 2s ease-in-out infinite;
}

@keyframes scaleIn {
  0% {
    transform: translateY(-50%) scale(0);
    opacity: 0;
  }
  100% {
    transform: translateY(-50%) scale(1);
    opacity: 1;
  }
}

@keyframes pulse {
  0% {
    transform: translateY(-50%) scale(1);
  }
  50% {
    transform: translateY(-50%) scale(1.05);
  }
  100% {
    transform: translateY(-50%) scale(1);
  }
}

@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: translateY(-50%) scale(0.3);
  }
  50% {
    opacity: 1;
    transform: translateY(-50%) scale(1.05);
  }
  70% {
    transform: translateY(-50%) scale(0.9);
  }
  100% {
    opacity: 1;
    transform: translateY(-50%) scale(1);
  }
}

/* Mobile Sidebar Trigger - Minimal bar button */
.cfb-sidebar-trigger {
  position: fixed !important;
  left: 0 !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  width: 8px !important;
  height: 60px !important;
  background: rgba(0, 0, 0, 0.3) !important;
  border-radius: 0 4px 4px 0 !important;
  cursor: pointer !important;
  z-index: 9998 !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  box-shadow: 1px 0 4px rgba(0, 0, 0, 0.1) !important;
}

.cfb-sidebar-trigger:hover {
  width: 12px !important;
  background: rgba(0, 0, 0, 0.5) !important;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.2) !important;
}

/* Mobile Sidebar Panel - Hidden by default, slides in when triggered */
.cfb-mobile-sidebar {
  position: fixed !important;
  left: -200px !important; /* Hidden off-screen */
  top: 50% !important;
  transform: translateY(-50%) !important;
  width: 200px !important;
  max-height: 70vh !important; /* Not full height */
  background: rgba(255, 255, 255, 0.95) !important;
  backdrop-filter: blur(20px) !important;
  -webkit-backdrop-filter: blur(20px) !important;
  border-radius: 0 12px 12px 0 !important;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15) !important;
  z-index: 9999 !important;
  padding: 20px 16px !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 12px !important;
  align-items: center !important;
  transition: left 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
}

/* Sidebar open state */
.cfb-mobile-sidebar.cfb-sidebar-open {
  left: 0 !important; /* Slide in from left */
}

/* Sidebar overlay when open */
.cfb-sidebar-overlay {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  background: rgba(0, 0, 0, 0.3) !important;
  z-index: 9997 !important;
  opacity: 0 !important;
  visibility: hidden !important;
  transition: all 0.3s ease !important;
}

.cfb-sidebar-overlay.cfb-overlay-visible {
  opacity: 1 !important;
  visibility: visible !important;
}

/* Sidebar button styling - Connected to main button settings */
.cfb-mobile-sidebar .cfb-button {
  /* Let buttons inherit custom styling from settings - only override layout properties */
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
  position: relative !important;
  overflow: hidden !important;
  flex-shrink: 0 !important;
  /* Custom background, color, shadow, etc. come from button settings via inline styles */
}

.cfb-mobile-sidebar .cfb-button:hover {
  transform: scale(1.1) !important;
}

.cfb-mobile-sidebar .cfb-button:active {
  transform: scale(0.95) !important;
}

/* Mobile responsive - Switch to sidebar on mobile */
@media (max-width: 768px) {
  .cfb-hidden-mobile.cfb-floating-buttons {
    display: none !important;
  }

  /* Hide floating buttons on mobile, show sidebar instead */
  .cfb-floating-buttons:not(.cfb-mobile-sidebar) {
    display: none !important;
  }

  /* Show sidebar on mobile */
  .cfb-mobile-sidebar {
    display: flex !important;
  }

  .cfb-floating-buttons.left,
  .cfb-floating-buttons.right,
  .cfb-floating-buttons.center-left,
  .cfb-floating-buttons.center-right,
  .cfb-floating-buttons.top-center,
  .cfb-floating-buttons.bottom-center {
    display: none !important;
  }
}

/* Desktop fallback - keep floating buttons on desktop */
@media (min-width: 769px) {
  .cfb-mobile-sidebar {
    display: none !important;
  }

  /* Hide trigger bar on desktop */
  .cfb-sidebar-trigger {
    display: none !important;
  }

  .cfb-floating-buttons.left {
    left: 20px;
  }

  .cfb-floating-buttons.right {
    right: 20px;
  }

  .cfb-floating-buttons.center-left {
    left: 50%;
    transform: translate(-10px, -50%);
    top: 50%;
  }

  .cfb-floating-buttons.center-right {
    right: 50%;
    transform: translate(10px, -50%);
    top: 50%;
  }

  .cfb-floating-buttons.top-center {
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
  }

  .cfb-floating-buttons.bottom-center {
    top: auto;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
  }

  .cfb-button {
    width: 44px;
    height: 44px;
  }

  .cfb-button i,
  .cfb-button img {
    width: 20px;
    height: 20px;
  }

  .cfb-button i {
    font-size: 16px;
  }
}
