/* 
 * Mobile Floating Action Button (FAB)
 * Fade in/out animation untuk action buttons
 */

/* FAB Container - only show on mobile when logged in */
.mobile-fab-container {
  display: none !important; /* Hidden by default */
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999;
  flex-direction: column-reverse;
  gap: 12px;
  align-items: flex-end;
  pointer-events: none;
}

/* Only show FAB on mobile (max-width: 768px) */
@media (max-width: 768px) {
  .mobile-fab-container {
    display: flex !important;
  }
  
  /* Hide desktop bulk bar on mobile */
  #bulkBar {
    display: none !important;
  }
  
  /* Add padding bottom to file list to prevent FAB overlap */
  #fileListMobile {
    padding-bottom: 100px !important;
  }
}

/* Desktop: Ensure FAB never shows */
@media (min-width: 769px) {
  .mobile-fab-container {
    display: none !important;
  }
}

/* FAB elements need pointer events */
.mobile-fab-container.visible {
  pointer-events: auto;
}

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

/* Hide FAB when login card is visible */
#loginCard:not(.hidden) ~ .mobile-fab-container,
#loginCard:not(.hidden) ~ * .mobile-fab-container {
  display: none !important;
}

/* Hide FAB when any modal is open */
body:has(#modalContainer:not(:empty)) .mobile-fab-container,
body:has(#searchModal:not(.hidden)) .mobile-fab-container,
body:has(.modal-backdrop) .mobile-fab-container {
  display: none !important;
}

/* Main FAB button */
.fab-main {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

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

.fab-main.active {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  transform: rotate(45deg);
}

.fab-main svg {
  width: 24px;
  height: 24px;
  transition: transform 0.3s ease;
}

.fab-main.active svg {
  transform: rotate(-45deg);
}

/* Badge for selected count */
.fab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
  animation: bounceIn 0.3s ease;
}

@keyframes bounceIn {
  0% { transform: scale(0); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* Action buttons */
.fab-actions {
  display: flex;
  flex-direction: column-reverse;
  gap: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.fab-actions.show {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

.fab-action {
  display: flex;
  align-items: center;
  gap: 12px;
  animation: fadeInRight 0.3s ease forwards;
  opacity: 0;
}

.fab-actions.show .fab-action:nth-child(1) {
  animation-delay: 0.05s;
}

.fab-actions.show .fab-action:nth-child(2) {
  animation-delay: 0.1s;
}

.fab-actions.show .fab-action:nth-child(3) {
  animation-delay: 0.15s;
}

.fab-actions.show .fab-action:nth-child(4) {
  animation-delay: 0.2s;
}

@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Action button label */
.fab-label {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Action button icon */
.fab-button {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.fab-button:active {
  transform: scale(0.9);
}

.fab-button svg {
  width: 20px;
  height: 20px;
}

/* Button colors */
.fab-download {
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  color: white;
}

.fab-download:hover {
  box-shadow: 0 6px 16px rgba(14, 165, 233, 0.4);
}

.fab-move {
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  color: white;
}

.fab-move:hover {
  box-shadow: 0 6px 16px rgba(139, 92, 246, 0.4);
}

.fab-delete {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
}

.fab-delete:hover {
  box-shadow: 0 6px 16px rgba(239, 68, 68, 0.4);
}

.fab-share {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
}

.fab-share:hover {
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

.fab-share-btn {
  background: linear-gradient(135deg, #06b6d4, #0891b2);
  color: white;
}

.fab-share-btn:hover {
  box-shadow: 0 6px 16px rgba(6, 182, 212, 0.4);
}

.fab-preview {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
}

.fab-preview:hover {
  box-shadow: 0 6px 16px rgba(245, 158, 11, 0.4);
}

/* Hide FAB on supervised users */
body.supervised-user .fab-delete {
  display: none !important;
}

/* Backdrop when FAB is open */
.fab-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(2px);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.fab-backdrop.show {
  display: block;
  opacity: 1;
}

/* Smooth show/hide */
.mobile-fab-container.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8) translateY(20px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-fab-container.visible {
  opacity: 1;
  pointer-events: all;
  transform: scale(1) translateY(0);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Ripple effect */
.fab-button::after,
.fab-main::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.5s ease;
}

.fab-button:active::after,
.fab-main:active::after {
  transform: translate(-50%, -50%) scale(2);
  opacity: 0;
}
