/* ========================================
   BOTÓN FLOTANTE - HERRAMIENTAS INSTITUCIONALES
   Mesa de Partes Virtual - EPIC
   ======================================== */

/* =============================================
   CONTENEDOR PRINCIPAL
   ============================================= */
.floating-tools {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
}

/* =============================================
   BOTÓN FAB PRINCIPAL
   ============================================= */
.fab-btn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ef2b2b 0%, #961919 100%);
  border: none;
  box-shadow: 
    0 8px 24px rgba(239, 43, 43, 0.35),
    0 0 0 0 rgba(239, 43, 43, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  animation: pulse-ring 3s infinite;
}

/* Anillo de pulso institucional */
@keyframes pulse-ring {
  0%, 100% {
    box-shadow: 
      0 8px 24px rgba(30, 58, 138, 0.35),
      0 0 0 0 rgba(30, 58, 138, 0.4);
  }
  50% {
    box-shadow: 
      0 8px 24px rgba(30, 58, 138, 0.35),
      0 0 0 12px rgba(30, 58, 138, 0);
  }
}

/* Brillo interno */
.fab-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at top left, rgba(255, 255, 255, 0.3) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.3s;
}

.fab-btn:hover {
  transform: translateY(-5px) scale(1.08);
  box-shadow: 
    0 12px 32px rgba(30, 58, 138, 0.45),
    0 0 0 0 rgba(30, 58, 138, 0);
  animation: none;
}

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

.fab-btn:active {
  transform: translateY(-3px) scale(1.05);
}

/* Estado activo (menú abierto) */
.fab-btn.active {
  transform: rotate(135deg) scale(1.05);
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  box-shadow: 
    0 8px 24px rgba(30, 41, 59, 0.4),
    0 0 0 0 rgba(30, 41, 59, 0);
  animation: none;
}

/* Badge de notificación (opcional) */
.fab-btn .badge-notification {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 22px;
  height: 22px;
  background: #dc2626;
  border-radius: 50%;
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid white;
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.4);
}

/* =============================================
   ÍCONO DEL BOTÓN
   ============================================= */
.fab-icon-img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  filter: brightness(0) invert(1) drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.fab-btn:hover .fab-icon-img {
  transform: scale(1.15);
}

.fab-btn.active .fab-icon-img {
  transform: rotate(-135deg) scale(0.95);
}

/* =============================================
   MENÚ DESPLEGABLE
   ============================================= */
.fab-menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
  opacity: 1;
  transform: translateY(0);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: all;
}

.fab-menu.oculto {
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
}

/* =============================================
   ENLACES DEL MENÚ
   ============================================= */
.fab-link {
  background: white;
  color: #ef2b2b;
  padding: 15px 28px;
  border-radius: 28px;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 
    0 4px 16px rgba(0, 0, 0, 0.12),
    0 0 0 1px rgba(239, 43, 43, 0.08);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid #961919;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  letter-spacing: 0.2px;
}

/* Ícono del enlace (opcional) */
.fab-link::before {
  content: '';
  width: 20px;
  height: 20px;
  background: linear-gradient(135deg, #ef2b2b, #961919);
  border-radius: 4px;
  display: inline-block;
  transition: transform 0.3s;
}

/* Efecto de brillo al hover */
.fab-link::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(30, 58, 138, 0.08), transparent);
  transition: left 0.5s;
}

.fab-link:hover {
  transform: translateX(-10px);
  box-shadow: 
    0 6px 24px rgba(239, 43, 43, 0.2),
    0 0 0 1px rgba(239, 43, 43, 0.15);
  border-color: #ef2b2b;
  color: #961919;
}

.fab-link:hover::before {
  transform: scale(1.1) rotate(5deg);
}

.fab-link:hover::after {
  left: 100%;
}

.fab-link:active {
  transform: translateX(-8px) scale(0.98);
}

/* Variantes de enlaces por tipo */
.fab-link[href*="tupa"] {
  background: linear-gradient(135deg, rgba(30, 58, 138, 0.05), rgba(59, 130, 246, 0.05));
}

.fab-link[href*="seguimiento"] {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.05), rgba(59, 130, 246, 0.05));
}

/* =============================================
   ANIMACIONES DE ENTRADA
   ============================================= */
@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(30px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

.fab-menu:not(.oculto) .fab-link {
  animation: fadeInRight 0.3s ease-out backwards;
}

.fab-menu:not(.oculto) .fab-link:nth-child(1) {
  animation-delay: 0.05s;
}

.fab-menu:not(.oculto) .fab-link:nth-child(2) {
  animation-delay: 0.1s;
}

.fab-menu:not(.oculto) .fab-link:nth-child(3) {
  animation-delay: 0.15s;
}

.fab-menu:not(.oculto) .fab-link:nth-child(4) {
  animation-delay: 0.2s;
}

/* =============================================
   TOOLTIP HOVER (OPCIONAL)
   ============================================= */
.fab-link[data-tooltip] {
  position: relative;
}

.fab-link[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  right: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  background: #1e293b;
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.fab-link:hover[data-tooltip]::before {
  opacity: 1;
}

/* =============================================
   RESPONSIVE DESIGN
   ============================================= */

/* Tablets */
@media (max-width: 768px) {
  .floating-tools {
    bottom: 24px;
    right: 24px;
  }

  .fab-btn {
    width: 60px;
    height: 60px;
  }

  .fab-icon-img {
    width: 34px;
    height: 34px;
  }

  .fab-link {
    padding: 13px 24px;
    font-size: 0.85rem;
  }

  .fab-link::before {
    width: 18px;
    height: 18px;
  }
}

/* Móviles */
@media (max-width: 480px) {
  .floating-tools {
    bottom: 20px;
    right: 20px;
  }

  .fab-btn {
    width: 56px;
    height: 56px;
  }

  .fab-icon-img {
    width: 30px;
    height: 30px;
  }

  .fab-link {
    padding: 12px 20px;
    font-size: 0.8rem;
    border-radius: 24px;
  }

  .fab-link::before {
    width: 16px;
    height: 16px;
  }

  /* Ajustar hover en móvil */
  .fab-link:hover {
    transform: translateX(-6px);
  }

  /* Ocultar tooltips en móvil */
  .fab-link[data-tooltip]::before {
    display: none;
  }
}

/* Móviles en landscape */
@media (max-width: 768px) and (orientation: landscape) {
  .floating-tools {
    bottom: 16px;
    right: 16px;
  }

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

/* =============================================
   ACCESIBILIDAD
   ============================================= */
.fab-btn:focus-visible {
  outline: 4px solid #3b82f6;
  outline-offset: 4px;
  animation: none;
}

.fab-link:focus-visible {
  outline: 3px solid #3b82f6;
  outline-offset: 2px;
}

/* Modo alto contraste */
@media (prefers-contrast: high) {
  .fab-btn {
    border: 3px solid white;
  }

  .fab-link {
    border: 2px solid #1e3a8a;
  }
}

/* Reducir animaciones */
@media (prefers-reduced-motion: reduce) {
  .fab-btn,
  .fab-link,
  .fab-menu,
  .fab-icon-img {
    transition: none !important;
    animation: none !important;
  }

  @keyframes pulse-ring {
    0%, 100% {
      box-shadow: 0 8px 24px rgba(30, 58, 138, 0.35);
    }
  }
}

/* =============================================
   ESTADOS ESPECIALES
   ============================================= */

/* Modo oscuro (si se implementa) */
@media (prefers-color-scheme: dark) {
  .fab-link {
    background: #1e293b;
    color: white;
    border-color: #334155;
  }

  .fab-link:hover {
    background: #334155;
    border-color: #3b82f6;
  }
}

/* Indicador de carga */
.fab-btn.loading {
  pointer-events: none;
}

.fab-btn.loading::after {
  content: '';
  position: absolute;
  width: 24px;
  height: 24px;
  border: 3px solid white;
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.fab-btn.loading .fab-icon-img {
  opacity: 0;
}

/* =============================================
   MODO IMPRESIÓN
   ============================================= */
@media print {
  .floating-tools {
    display: none;
  }
}

/* =============================================
   EFECTOS ADICIONALES
   ============================================= */

/* Indicador de nuevo contenido */
.fab-link.new::after {
  content: 'NUEVO';
  position: absolute;
  top: -8px;
  right: -8px;
  background: #dc2626;
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(220, 38, 38, 0.3);
}

/* Backdrop cuando el menú está abierto (opcional) */
.fab-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 9998;
}

.fab-backdrop.active {
  opacity: 1;
  pointer-events: all;
}
