/**
 * ANIMACIONES Y EFECTOS - ATLANTIS CRM
 * Transiciones suaves, hover effects, loading spinners
 * @version 1.0
 * @date 2025-12-03
 */

/* ========================================
   ANIMACIONES KEYFRAMES
======================================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

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

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ========================================
   TRANSICIONES DE MODALES
======================================== */
.modal.fade .modal-dialog {
  transition: transform 0.3s ease-out, opacity 0.3s ease;
  transform: scale(0.9) translateY(-30px);
  opacity: 0;
}

.modal.fade.in .modal-dialog,
.modal.show .modal-dialog {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.modal-content {
  animation: scaleIn 0.3s ease-out;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.2);
}

/* Efecto de entrada para modal header */
.modal-header {
  position: relative;
  overflow: hidden;
}

.modal-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
  transform: translateX(-100%);
  animation: shimmer 2s ease-in-out infinite;
}

/* ========================================
   HOVER EFFECTS PARA BOTONES
======================================== */
.btn {
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* Efecto ripple en botones */
.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.4s ease, height 0.4s ease;
}

.btn:active::before {
  width: 200%;
  height: 200%;
}

/* Botones específicos con gradientes */
.btn-primary {
  background: linear-gradient(135deg, #3c8dbc 0%, #2c6d9c 100%);
  border: none;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #4a9fd4 0%, #3c8dbc 100%);
}

.btn-success {
  background: linear-gradient(135deg, #00a65a 0%, #008d4c 100%);
  border: none;
}

.btn-success:hover {
  background: linear-gradient(135deg, #00c06a 0%, #00a65a 100%);
}

.btn-warning {
  background: linear-gradient(135deg, #f39c12 0%, #d68910 100%);
  border: none;
}

.btn-warning:hover {
  background: linear-gradient(135deg, #f5b041 0%, #f39c12 100%);
}

.btn-danger {
  background: linear-gradient(135deg, #dd4b39 0%, #c0392b 100%);
  border: none;
}

.btn-danger:hover {
  background: linear-gradient(135deg, #e74c3c 0%, #dd4b39 100%);
}

.btn-info {
  background: linear-gradient(135deg, #00c0ef 0%, #00a0c6 100%);
  border: none;
}

.btn-info:hover {
  background: linear-gradient(135deg, #3dd5f3 0%, #00c0ef 100%);
}

/* ========================================
   EFECTOS EN CARDS/BOXES
======================================== */
.box {
  transition: all 0.3s ease;
  border-radius: 4px;
  overflow: hidden;
}

.box:hover {
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

/* Animación de entrada para boxes */
.box {
  animation: fadeInUp 0.4s ease-out;
}

/* Header de box con gradiente sutil */
.box-header.with-border {
  border-bottom: 2px solid #f4f4f4;
  background: linear-gradient(180deg, #fafafa 0%, #ffffff 100%);
}

[data-theme="dark"] .box-header.with-border {
  background: linear-gradient(180deg, rgba(255,255,255,0.02) 0%, transparent 100%);
  border-bottom-color: var(--border-color);
}

/* ========================================
   EFECTOS EN TABLAS
======================================== */
.table > tbody > tr {
  transition: all 0.2s ease;
}

.table-hover > tbody > tr:hover {
  transform: scale(1.005);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Animación para filas de tabla */
.table > tbody > tr {
  animation: fadeIn 0.3s ease-out;
  animation-fill-mode: both;
}

.table > tbody > tr:nth-child(1) { animation-delay: 0.05s; }
.table > tbody > tr:nth-child(2) { animation-delay: 0.1s; }
.table > tbody > tr:nth-child(3) { animation-delay: 0.15s; }
.table > tbody > tr:nth-child(4) { animation-delay: 0.2s; }
.table > tbody > tr:nth-child(5) { animation-delay: 0.25s; }

/* ========================================
   LOADING SPINNER
======================================== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.loading-overlay.active {
  opacity: 1;
  visibility: visible;
}

[data-theme="dark"] .loading-overlay {
  background: rgba(26, 26, 46, 0.95);
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #3c8dbc;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-container {
  text-align: center;
}

.spinner-text {
  margin-top: 15px;
  color: #666;
  font-size: 14px;
}

[data-theme="dark"] .spinner-text {
  color: #b0b0b0;
}

/* Spinner pequeño inline */
.spinner-sm {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #3c8dbc;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 5px;
}

/* ========================================
   EFECTOS EN INPUTS
======================================== */
.form-control {
  transition: all 0.2s ease;
  border-radius: 4px;
}

.form-control:focus {
  border-color: #3c8dbc;
  box-shadow: 0 0 0 3px rgba(60, 141, 188, 0.15);
  transform: translateY(-1px);
}

.input-group {
  transition: all 0.2s ease;
}

.input-group:focus-within {
  transform: translateY(-1px);
}

.input-group:focus-within .input-group-addon {
  border-color: #3c8dbc;
  color: #3c8dbc;
}

/* ========================================
   EFECTOS EN SIDEBAR
======================================== */
.sidebar-menu > li {
  transition: all 0.2s ease;
}

.sidebar-menu > li:hover {
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-menu > li > a {
  transition: all 0.2s ease;
}

.sidebar-menu > li > a:hover {
  padding-left: 20px;
}

.sidebar-menu > li > a > .fa,
.sidebar-menu > li > a > .ion {
  transition: all 0.2s ease;
}

.sidebar-menu > li:hover > a > .fa,
.sidebar-menu > li:hover > a > .ion {
  transform: scale(1.1);
}

/* ========================================
   EFECTOS EN BADGES Y LABELS
======================================== */
.label, .badge {
  transition: all 0.2s ease;
}

.label:hover, .badge:hover {
  transform: scale(1.05);
}

/* ========================================
   SMALL BOXES (Dashboard)
======================================== */
.small-box {
  transition: all 0.3s ease;
  border-radius: 4px;
  overflow: hidden;
}

.small-box:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.small-box .icon {
  transition: all 0.3s ease;
}

.small-box:hover .icon {
  transform: scale(1.1) rotate(5deg);
}

.small-box > .small-box-footer {
  transition: all 0.2s ease;
}

.small-box:hover > .small-box-footer {
  background: rgba(0, 0, 0, 0.15);
}

/* ========================================
   EFECTOS EN DROPDOWN
======================================== */
.dropdown-menu {
  animation: fadeInDown 0.2s ease-out;
  border-radius: 4px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.dropdown-menu > li > a {
  transition: all 0.15s ease;
}

.dropdown-menu > li > a:hover {
  padding-left: 25px;
}

/* ========================================
   NOTIFICACIONES / TOASTS
======================================== */
.swal2-popup {
  animation: scaleIn 0.3s ease-out !important;
  border-radius: 8px !important;
}

.swal2-show {
  animation: scaleIn 0.3s ease-out !important;
}

/* ========================================
   EFECTOS ESPECIALES
======================================== */
/* Efecto glow en elementos activos */
.glow {
  box-shadow: 0 0 15px rgba(60, 141, 188, 0.5);
  animation: pulse 2s infinite;
}

/* Efecto de escritura */
.typewriter {
  overflow: hidden;
  border-right: 2px solid #3c8dbc;
  white-space: nowrap;
  animation: typing 3s steps(40, end), blink-caret 0.75s step-end infinite;
}

@keyframes typing {
  from { width: 0; }
  to { width: 100%; }
}

@keyframes blink-caret {
  from, to { border-color: transparent; }
  50% { border-color: #3c8dbc; }
}

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}

[data-theme="dark"] .skeleton {
  background: linear-gradient(90deg, #2a3550 25%, #1f2940 50%, #2a3550 75%);
  background-size: 200% 100%;
}

/* ========================================
   RESPONSIVE ANIMATIONS
======================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
