/* css/ux-improvements.css - Mejoras reales de UX/UI sin marketing falso
   Enfoque: Micro-interacciones, accesibilidad, feedback visual genuino
   v1.0 - Febrero 2026
*/

/* ========================================
   MEJORAS DE HOVER STATES EN CARDS
   ======================================== */

.card {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.3s ease;
  will-change: transform;
}

.card:hover {
  transform: translateY(-8px) scale(1.01);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.12),
              0 8px 16px rgba(22, 163, 74, 0.1);
  border-color: var(--tn-green-300, #86efac);
}

/* Animación suave de imagen en hover */
.card-image {
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

.card:hover .card-image {
  transform: scale(1.05);
}

/* Prevenir layout shift con aspect-ratio */
.card-image {
  aspect-ratio: 16 / 10;
  width: 100%;
  height: auto;
  object-fit: cover;
  display: block;
}

/* ========================================
   MEJORAS DE FOCUS STATES (ACCESIBILIDAD)
   ======================================== */

/* Focus visible mejorado para todos los elementos interactivos */
.btn:focus-visible,
.card:focus-visible,
input:focus-visible,
select:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--tn-green-600);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(22, 163, 74, 0.2);
}

/* Focus states más sutiles pero visibles */
.btn-primary:focus-visible {
  outline-color: white;
  outline-offset: 2px;
}

/* Respetar preferencias de movimiento reducido */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ========================================
   MICRO-INTERACCIONES EN BOTONES
   ======================================== */

.btn {
  position: relative;
  overflow: hidden;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Efecto ripple sutil al hacer click */
.btn::after {
  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.4s ease, height 0.4s ease;
  pointer-events: none;
}

.btn:active::after {
  width: 300px;
  height: 300px;
}

/* Mejora del botón secundario en hero */
.btn-acceder-hero {
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(8px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-acceder-hero:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.9);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.btn-acceder-hero:active {
  transform: translateY(0);
}

/* ========================================
   MEJORAS EN TRANSICIONES DE RESULTADOS
   ======================================== */

.results {
  opacity: 1;
  transition: opacity 0.3s ease-out;
}

.results.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* Asegurar que los resultados sean visibles cuando no están en loading */
.results:not(.loading) {
  opacity: 1 !important;
}

/* Animación suave al mostrar nuevos resultados */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  animation: fadeInUp 0.4s ease-out backwards;
}

.card:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2) { animation-delay: 0.1s; }
.card:nth-child(3) { animation-delay: 0.15s; }
.card:nth-child(4) { animation-delay: 0.2s; }
.card:nth-child(5) { animation-delay: 0.25s; }
.card:nth-child(6) { animation-delay: 0.3s; }

/* ========================================
   FEEDBACK VISUAL EN BÚSQUEDA
   ======================================== */

.search-text-input-wrapper {
  position: relative;
}

.search-indicator {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--tn-slate-500);
  pointer-events: none;
}

.search-indicator.active {
  display: flex;
}

.search-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--tn-slate-200);
  border-top-color: var(--tn-green-600);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========================================
   MEJORAS EN SKELETON LOADERS
   ======================================== */

.skeleton-card {
  background: linear-gradient(
    90deg,
    var(--tn-slate-100) 0%,
    var(--tn-slate-50) 50%,
    var(--tn-slate-100) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* ========================================
   MEJORAS EN PRECIO (DESTACAR INFORMACIÓN CLAVE)
   ======================================== */

.card .price {
  font-weight: 900;
  letter-spacing: -0.02em;
  transition: color 0.2s ease;
}

.card:hover .price {
  color: var(--tn-green-700);
}

/* ========================================
   MEJORAS EN SELECT DE ORDENAMIENTO
   ======================================== */

.sort-wrapper select {
  transition: all 0.2s ease;
  cursor: pointer;
}

.sort-wrapper select:hover {
  border-color: var(--tn-green-400);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1);
}

.sort-wrapper select:focus {
  outline: none;
  border-color: var(--tn-green-600);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}

/* ========================================
   MEJORAS EN BOTÓN DE FILTROS TÉCNICOS
   ======================================== */

.btn-mas-filtros {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.btn-mas-filtros:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.4);
}

.btn-mas-filtros:active {
  transform: translateY(0);
}

/* ========================================
   MEJORAS EN EMPTY STATES (HONESTOS)
   ======================================== */

.empty-state {
  padding: 3rem 1.5rem;
  text-align: center;
}

.empty-state__icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.6;
}

.empty-state__title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--tn-slate-900);
  margin-bottom: 0.75rem;
}

.empty-state__text {
  font-size: 1rem;
  color: var(--tn-slate-600);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.empty-state__hint {
  font-size: 0.875rem;
  color: var(--tn-slate-500);
  margin-top: 1rem;
  font-style: italic;
}

.empty-state__actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 2rem;
}

/* ========================================
   MEJORAS EN FILTER PILLS
   ======================================== */

.filter-pill {
  transition: all 0.2s ease;
}

.filter-pill:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.filter-pill__remove {
  transition: transform 0.2s ease;
}

.filter-pill__remove:hover {
  transform: scale(1.2);
  background: rgba(239, 68, 68, 0.1);
}

/* ========================================
   MEJORAS EN NAVEGACIÓN
   ======================================== */

.nav-dropdown-menu {
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.nav-dropdown-item {
  transition: background 0.15s ease, transform 0.15s ease;
}

.nav-dropdown-item:hover {
  transform: translateX(4px);
}

/* ========================================
   MEJORAS EN PAGINACIÓN
   ======================================== */

.pagination button,
.pagination a {
  transition: all 0.2s ease;
}

.pagination button:hover:not(:disabled),
.pagination a:hover:not(.disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.pagination button:active:not(:disabled),
.pagination a:active:not(.disabled) {
  transform: translateY(0);
}

/* ========================================
   MEJORAS EN INPUTS Y FORMULARIOS
   ======================================== */

input[type="text"],
input[type="number"],
select {
  transition: all 0.2s ease;
}

input[type="text"]:hover,
input[type="number"]:hover,
select:hover {
  border-color: var(--tn-slate-300);
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: var(--tn-green-600);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1);
}

/* Indicador de error visual mejorado */
.input-error {
  border-color: var(--tn-danger) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
}

/* ========================================
   MEJORAS EN SCROLL TOP BUTTON
   ======================================== */

.scroll-top-btn {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.scroll-top-btn:hover {
  transform: translateY(-4px) scale(1.1);
  box-shadow: 0 8px 24px rgba(22, 163, 74, 0.3);
}

.scroll-top-btn:active {
  transform: translateY(-2px) scale(1.05);
}

/* ========================================
   MEJORAS EN MODALES
   ======================================== */

.modal {
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-content {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.3s ease;
}

.modal:not(.hidden) .modal-content {
  animation: modalSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ========================================
   MEJORAS EN BADGES Y ETIQUETAS
   ======================================== */

.badge-new,
.badge-urgent {
  animation: none; /* Sin animaciones molestas por defecto */
}

/* Solo animar si el usuario no prefiere movimiento reducido */
@media (prefers-reduced-motion: no-preference) {
  .badge-urgent {
    animation: pulse-subtle 2s ease-in-out infinite;
  }
}

@keyframes pulse-subtle {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.9;
  }
}

/* ========================================
   MEJORAS EN RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
  .card:hover {
    transform: translateY(-4px) scale(1.005);
  }
  
  .btn:active::after {
    width: 200px;
    height: 200px;
  }
}

/* ========================================
   MEJORAS EN ACCESIBILIDAD DE TECLADO
   ======================================== */

/* Skip link para navegación por teclado */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--tn-green-600);
  color: white;
  padding: 1rem;
  z-index: 10000;
  text-decoration: none;
  font-weight: 600;
  border-radius: 0 0 8px 0;
}

.skip-link:focus {
  top: 0;
}

/* ========================================
   MEJORAS EN LOADING STATES
   ======================================== */

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loading-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ========================================
   MEJORAS EN TOOLTIPS Y HINTS
   ======================================== */

[title]:hover::after {
  content: attr(title);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.5rem 0.75rem;
  background: var(--tn-slate-900);
  color: white;
  font-size: 0.75rem;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 1000;
  margin-bottom: 0.5rem;
}

[title]:hover::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--tn-slate-900);
  pointer-events: none;
  z-index: 1000;
  margin-bottom: -0.5rem;
}
