/* 
   🎨 Utilidades Profesionales BIMBA
   Componentes reutilizables y utilidades avanzadas
*/

/* --- LOADING STATES --- */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(102, 126, 234, 0.3);
  border-radius: 50%;
  border-top-color: #667eea;
  animation: spin 0.8s linear infinite;
}

.loading-spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 4px;
}

.loading-spinner-sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

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

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  animation: fadeIn 0.2s ease-out;
}

.loading-content {
  background: var(--bg-surface);
  padding: var(--space-6);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--elevation-4);
  text-align: center;
  min-width: 200px;
}

.loading-content .loading-spinner {
  margin: 0 auto var(--space-4);
}

.loading-content p {
  color: var(--text-secondary);
  margin: 0;
  font-size: var(--text-base);
}

/* Skeleton Loading */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 25%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0.05) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

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

.skeleton-text {
  height: 1em;
  margin-bottom: var(--space-2);
}

.skeleton-title {
  height: 1.5em;
  width: 60%;
  margin-bottom: var(--space-3);
}

.skeleton-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
}

/* --- TOOLTIPS --- */
.tooltip {
  position: relative;
  display: inline-block;
  cursor: help;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: var(--text-sm);
  white-space: nowrap;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--elevation-3);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal), transform var(--transition-normal);
  z-index: 1000;
  margin-bottom: var(--space-2);
}

.tooltip::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--bg-surface);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
  z-index: 1001;
  margin-bottom: -1px;
}

.tooltip:hover::after,
.tooltip:hover::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.tooltip:hover::before {
  transform: translateX(-50%);
}

/* Tooltip posiciones */
.tooltip-top::after {
  bottom: 100%;
  top: auto;
}

.tooltip-bottom::after {
  top: 100%;
  bottom: auto;
  transform: translateX(-50%) translateY(8px);
}

.tooltip-left::after {
  right: 100%;
  left: auto;
  top: 50%;
  transform: translateY(-50%) translateX(-8px);
}

.tooltip-right::after {
  left: 100%;
  right: auto;
  top: 50%;
  transform: translateY(-50%) translateX(8px);
}

/* --- BADGES MEJORADOS --- */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.badge-pulse {
  animation: pulse 2s ease-in-out infinite;
}

.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: var(--space-1);
  display: inline-block;
}

.badge-success .badge-dot {
  background: var(--success);
  box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
}

.badge-warning .badge-dot {
  background: var(--warning);
  box-shadow: 0 0 8px rgba(255, 152, 0, 0.6);
}

.badge-danger .badge-dot {
  background: var(--danger);
  box-shadow: 0 0 8px rgba(244, 67, 54, 0.6);
}

.badge-info .badge-dot {
  background: var(--info);
  box-shadow: 0 0 8px rgba(33, 150, 243, 0.6);
}

/* --- PROGRESS BARS --- */
.progress {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.progress-bar {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  transition: width var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: progress-shine 2s infinite;
}

@keyframes progress-shine {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

.progress-lg {
  height: 12px;
}

.progress-sm {
  height: 4px;
}

/* --- ALERTS MEJORADOS --- */
.alert {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  border-left: 4px solid;
  margin-bottom: var(--space-4);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  animation: slideInRight 0.3s ease-out;
  position: relative;
  overflow: hidden;
}

.alert::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: currentColor;
  opacity: 0.8;
}

.alert-icon {
  font-size: var(--text-xl);
  flex-shrink: 0;
  margin-top: 2px;
}

.alert-content {
  flex: 1;
}

.alert-title {
  font-weight: 600;
  margin: 0 0 var(--space-1) 0;
  font-size: var(--text-base);
}

.alert-message {
  margin: 0;
  font-size: var(--text-sm);
  opacity: 0.9;
  line-height: 1.5;
}

.alert-close {
  background: none;
  border: none;
  color: inherit;
  font-size: var(--text-lg);
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
  flex-shrink: 0;
  opacity: 0.7;
}

.alert-close:hover {
  background: rgba(0, 0, 0, 0.1);
  opacity: 1;
}

.alert-success {
  background: var(--success-light);
  border-left-color: var(--success);
  color: #81c784;
}

.alert-error {
  background: var(--danger-light);
  border-left-color: var(--danger);
  color: #e57373;
}

.alert-warning {
  background: var(--warning-light);
  border-left-color: var(--warning);
  color: #ffb74d;
}

.alert-info {
  background: var(--info-light);
  border-left-color: var(--info);
  color: #64b5f6;
}

/* --- FOCUS STATES MEJORADOS --- */
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.btn:focus-visible,
.admin-nav-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 0;
}

/* Skip to content link para accesibilidad */
.skip-to-content {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--primary);
  color: var(--text-inverse);
  padding: var(--space-2) var(--space-4);
  text-decoration: none;
  border-radius: 0 0 var(--radius-md) 0;
  z-index: 10000;
  font-weight: 600;
}

.skip-to-content:focus {
  top: 0;
}

/* --- UTILIDADES DE ESPACIADO --- */
.mt-auto {
  margin-top: auto;
}

.mb-auto {
  margin-bottom: auto;
}

.ml-auto {
  margin-left: auto;
}

.mr-auto {
  margin-right: auto;
}

/* --- UTILIDADES DE VISIBILIDAD --- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* --- UTILIDADES DE TEXTO --- */
.text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-break {
  word-break: break-word;
  overflow-wrap: break-word;
}

/* --- UTILIDADES DE FLEXBOX --- */
.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flex-column {
  flex-direction: column;
}

.flex-wrap {
  flex-wrap: wrap;
}

/* --- UTILIDADES DE GRID --- */
.grid {
  display: grid;
}

.grid-cols-1 {
  grid-template-columns: repeat(1, minmax(0, 1fr));
}

.grid-cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.gap-1 {
  gap: var(--space-1);
}

.gap-2 {
  gap: var(--space-2);
}

.gap-3 {
  gap: var(--space-3);
}

.gap-4 {
  gap: var(--space-4);
}

/* --- RESPONSIVE UTILITIES --- */
@media (max-width: 767px) {
  .hide-mobile {
    display: none !important;
  }
  
  .show-mobile {
    display: block !important;
  }
  
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 768px) {
  .show-mobile {
    display: none !important;
  }
  
  .hide-desktop {
    display: none !important;
  }
}

/* --- ANIMACIONES ADICIONALES --- */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

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

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

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

.animate-fade-in {
  animation: fadeIn 0.3s ease-out;
}

.animate-fade-out {
  animation: fadeOut 0.3s ease-out;
}

.animate-slide-up {
  animation: slideUp 0.3s ease-out;
}

.animate-slide-down {
  animation: slideDown 0.3s ease-out;
}

.animate-scale-in {
  animation: scaleIn 0.3s ease-out;
}

/* --- DARK MODE SUPPORT (Preparado para futuro) --- */
@media (prefers-color-scheme: dark) {
  /* Ya estamos en modo oscuro por defecto */
}

/* --- PRINT STYLES --- */
@media print {
  .admin-top-nav,
  .admin-footer,
  .btn,
  .admin-nav-btn {
    display: none !important;
  }
  
  body {
    background: white;
    color: black;
  }
  
  .card {
    border: 1px solid #ccc;
    box-shadow: none;
  }
}





