/**
 * SuperClin Profesional - Componentes UI Modernos
 * Design System basado en paleta corporativa
 * WCAG 2.2 AA/AAA compliant
 * Versión: 3.0.0
 */

/* ========================================
   BOTONES MODERNOS CON ACCESIBILIDAD AAA
======================================== */

/* Botón primario - Azul oscuro con blanco AAA */
.btn-brand-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--blanco);
  background: var(--azul-oscuro-aaa);  /* Contraste AAA */
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-brand);
  text-decoration: none;
  white-space: nowrap;
}

.btn-brand-primary:hover {
  background: var(--azul-oscuro);
  transform: translateY(-2px);
  box-shadow: 0 15px 35px rgba(52, 98, 175, 0.35);
  color: var(--blanco);
}

.btn-brand-primary:active {
  transform: translateY(0);
  box-shadow: var(--shadow-md);
}

.btn-brand-primary:focus-visible {
  outline: 4px solid var(--celeste);
  outline-offset: 2px;
}

/* Botón secundario - Celeste con texto oscuro AAA */
.btn-brand-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 1rem;
  color: var(--negro);  /* Contraste AAA: 11.09:1 */
  background: var(--celeste);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-brand);
  text-decoration: none;
}

.btn-brand-secondary:hover {
  background: var(--azul-oscuro);
  color: var(--blanco);
  transform: translateY(-2px);
  box-shadow: 0 15px 35px rgba(86, 202, 239, 0.35);
}

.btn-brand-secondary:focus-visible {
  outline: 4px solid var(--azul-oscuro);
  outline-offset: 2px;
}

/* Botón de acento - Amarillo con texto negro */
.btn-brand-accent {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1rem;
  color: var(--negro);
  background: var(--amarillo);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-brand);
  text-decoration: none;
}

.btn-brand-accent:hover {
  background: #FFD700;
  transform: translateY(-2px);
  box-shadow: 0 15px 35px rgba(255, 225, 0, 0.4);
  color: var(--negro);
}

/* Tamaños de botones */
.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.btn-lg {
  padding: 1rem 2rem;
  font-size: 1.125rem;
}

/* ========================================
   CARDS DE PRODUCTO - Diseño Moderno
======================================== */

.card-product {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--blanco);
  border-radius: var(--radius-2xl);
  overflow: hidden;
  box-shadow: var(--shadow-brand);
  transition: all var(--transition-base);
  border: 1px solid var(--gris-200);
}

.card-product:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  border-color: var(--celeste);
}

.card-product-image {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--gris-100);
}

.card-product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow);
}

.card-product:hover .card-product-image img {
  transform: scale(1.05);
}

.card-product-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
}

.card-product-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--azul-oscuro);
  margin: 0;
  line-height: 1.4;
}

.card-product-description {
  font-size: 0.875rem;
  color: var(--gris-700);
  line-height: 1.5;
  margin: 0;
}

.card-product-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--gris-200);
}

.card-product-price {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--rojo);
  margin: 0;
}

.card-product-price-old {
  font-size: 1rem;
  color: var(--gris-500);
  text-decoration: line-through;
  margin-left: 0.5rem;
}

/* Badge en la card */
.card-product-badge {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--blanco);
  background: var(--rojo);
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  z-index: 10;
}

.card-product-badge.badge-new {
  background: var(--ok);
}

.card-product-badge.badge-promo {
  background: var(--amarillo);
  color: var(--negro);
}

/* ========================================
   BANNER PROFESIONAL CON GRADIENTE
======================================== */

.banner-profesional {
  position: relative;
  overflow: hidden;
  background: var(--azul-oscuro);
  color: var(--blanco);
  border-radius: var(--radius-2xl);
  padding: 3rem 2rem;
  box-shadow: var(--shadow-brand);
}

.banner-profesional::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(600px 300px at 10% 0%, var(--celeste), transparent);
  opacity: 0.15;
  pointer-events: none;
}

.banner-profesional-content {
  position: relative;
  z-index: 2;
  max-width: 800px;
}

.banner-profesional-title {
  font-family: 'Raleway', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
  font-size: clamp(1.75rem, 3vw, 2.5rem);
  font-weight: 800;
  margin: 0 0 1rem;
  line-height: 1.2;
}

.banner-profesional-text {
  font-size: 1.125rem;
  opacity: 0.95;
  margin: 0 0 1.5rem;
  line-height: 1.6;
}

.banner-profesional .btn-brand-accent {
  margin-top: 0.5rem;
}

/* ========================================
   BADGES Y ETIQUETAS - AAA Compliant
======================================== */

.badge-superclin {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1;
  border-radius: var(--radius-full);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-primary {
  background: var(--azul-oscuro-aaa);
  color: var(--blanco);
}

.badge-secondary {
  background: var(--celeste);
  color: var(--negro);
}

.badge-success {
  background: var(--ok);
  color: var(--blanco);
}

.badge-warning {
  background: var(--amarillo);
  color: var(--negro);
}

.badge-danger {
  background: var(--rojo);
  color: var(--blanco);
}

/* ========================================
   FORMULARIOS MODERNOS
======================================== */

.form-group-modern {
  margin-bottom: 1.5rem;
}

.form-label-modern {
  display: block;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--gris-800);
  margin-bottom: 0.5rem;
  line-height: 1.4;
}

.form-label-modern.required::after {
  content: '*';
  color: var(--rojo);
  margin-left: 0.25rem;
}

.form-input-modern {
  display: block;
  width: 100%;
  padding: 0.875rem 1rem;
  font-size: 1rem;
  font-family: var(--font-sans);
  line-height: 1.5;
  color: var(--gris-900);
  background: var(--blanco);
  border: 2px solid var(--gris-300);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.form-input-modern:hover {
  border-color: var(--gris-400);
}

.form-input-modern:focus {
  border-color: var(--azul-oscuro);
  outline: 0;
  box-shadow: 0 0 0 4px rgba(52, 98, 175, 0.1);
}

.form-input-modern::placeholder {
  color: var(--gris-400);
}

.form-input-modern:disabled {
  background: var(--gris-100);
  cursor: not-allowed;
  opacity: 0.6;
}

/* Estados de validación */
.form-input-modern.is-valid {
  border-color: var(--ok);
}

.form-input-modern.is-invalid {
  border-color: var(--err);
}

.form-feedback {
  display: block;
  font-size: 0.875rem;
  margin-top: 0.375rem;
}

.form-feedback.valid-feedback {
  color: var(--ok);
}

.form-feedback.invalid-feedback {
  color: var(--err);
}

/* ========================================
   ALERTS MODERNOS
======================================== */

.alert-modern {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border: none;
  border-left: 4px solid;
  border-radius: var(--radius-lg);
  background: var(--blanco);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1rem;
}

.alert-modern-icon {
  flex-shrink: 0;
  font-size: 1.25rem;
  line-height: 1.5;
}

.alert-modern-content {
  flex: 1;
}

.alert-modern-title {
  font-weight: 600;
  font-size: 0.9375rem;
  margin: 0 0 0.25rem;
}

.alert-modern-text {
  font-size: 0.875rem;
  margin: 0;
  line-height: 1.5;
}

/* Variantes de alert */
.alert-modern.alert-success {
  border-left-color: var(--ok);
  background: #f0fdf4;
}

.alert-modern.alert-success .alert-modern-icon,
.alert-modern.alert-success .alert-modern-title {
  color: var(--ok);
}

.alert-modern.alert-danger {
  border-left-color: var(--err);
  background: #fef2f2;
}

.alert-modern.alert-danger .alert-modern-icon,
.alert-modern.alert-danger .alert-modern-title {
  color: var(--err);
}

.alert-modern.alert-warning {
  border-left-color: var(--warn);
  background: #fffbeb;
}

.alert-modern.alert-warning .alert-modern-icon,
.alert-modern.alert-warning .alert-modern-title {
  color: var(--warn);
}

.alert-modern.alert-info {
  border-left-color: var(--celeste);
  background: #f0f9ff;
}

.alert-modern.alert-info .alert-modern-icon,
.alert-modern.alert-info .alert-modern-title {
  color: var(--azul-oscuro);
}

/* ========================================
   MODALES MODERNOS
======================================== */

.modal-modern-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal-backdrop);
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease-out;
}

.modal-modern-content {
  position: relative;
  background: var(--blanco);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-2xl);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease-out;
}

.modal-modern-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem;
  border-bottom: 1px solid var(--gris-200);
}

.modal-modern-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--azul-oscuro);
  margin: 0;
}

.modal-modern-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--gris-600);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.modal-modern-close:hover {
  background: var(--gris-100);
  color: var(--gris-900);
}

.modal-modern-body {
  padding: 1.5rem;
}

.modal-modern-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1.5rem;
  border-top: 1px solid var(--gris-200);
}

/* ========================================
   TOOLTIPS
======================================== */

.tooltip-modern {
  position: relative;
  display: inline-block;
}

.tooltip-modern-content {
  position: absolute;
  bottom: calc(100% + 0.5rem);
  left: 50%;
  transform: translateX(-50%);
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--blanco);
  background: var(--gris-900);
  border-radius: var(--radius-md);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
  z-index: var(--z-tooltip);
}

.tooltip-modern:hover .tooltip-modern-content,
.tooltip-modern:focus-within .tooltip-modern-content {
  opacity: 1;
}

.tooltip-modern-content::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 0.375rem solid transparent;
  border-top-color: var(--gris-900);
}

/* ========================================
   ANIMACIONES
======================================== */

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

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

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

/* ========================================
   SKELETON LOADERS
======================================== */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--gris-200) 0%,
    var(--gris-100) 50%,
    var(--gris-200) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite linear;
  border-radius: var(--radius-md);
}

.skeleton-text {
  height: 1rem;
  margin-bottom: 0.5rem;
}

.skeleton-title {
  height: 1.5rem;
  width: 60%;
  margin-bottom: 1rem;
}

.skeleton-image {
  width: 100%;
  aspect-ratio: 16 / 9;
}

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

@media (max-width: 768px) {
  .banner-profesional {
    padding: 2rem 1.5rem;
  }
  
  .btn-brand-primary,
  .btn-brand-secondary,
  .btn-brand-accent {
    width: 100%;
    justify-content: center;
  }
  
  .modal-modern-content {
    margin: 1rem;
  }
}

/* ========================================
   PREFERS-REDUCED-MOTION
======================================== */

@media (prefers-reduced-motion: reduce) {
  .card-product,
  .card-product-image img,
  .btn-brand-primary,
  .btn-brand-secondary,
  .btn-brand-accent,
  .form-input-modern {
    transition: none !important;
  }
  
  .skeleton {
    animation: none !important;
  }
}

/* ========================================
   LOADER / SPINNER MODERNO REUTILIZABLE
======================================== */

.page-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.page-loader.show {
  opacity: 1;
  visibility: visible;
}

.page-loader-content {
  text-align: center;
  max-width: 300px;
  padding: 2rem;
}

/* Spinner animado moderno */
.page-loader-spinner {
  width: 64px;
  height: 64px;
  margin: 0 auto 1.5rem;
  position: relative;
}

.page-loader-spinner::before,
.page-loader-spinner::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  border: 4px solid transparent;
  border-top-color: var(--sc-primary, #3462AF);
  animation: spinLoader 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.page-loader-spinner::before {
  width: 64px;
  height: 64px;
  border-width: 4px;
  border-top-color: var(--sc-primary, #3462AF);
  border-right-color: rgba(52, 98, 175, 0.3);
}

.page-loader-spinner::after {
  width: 48px;
  height: 48px;
  top: 8px;
  left: 8px;
  border-width: 3px;
  border-top-color: var(--sc-secondary, #EC3337);
  border-right-color: rgba(236, 51, 55, 0.2);
  animation-duration: 0.8s;
  animation-direction: reverse;
}

@keyframes spinLoader {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.page-loader-text {
  font-family: var(--font-sans, 'Raleway', sans-serif);
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--sc-dark, #1e293b);
  margin-bottom: 0.5rem;
}

.page-loader-subtext {
  font-size: 0.875rem;
  color: var(--sc-gray-600, #64748b);
  font-weight: 400;
}

/* Loader inline para secciones específicas */
.section-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  min-height: 300px;
}

.section-loader-spinner {
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
  position: relative;
}

.section-loader-spinner::before {
  content: '';
  position: absolute;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 4px solid rgba(52, 98, 175, 0.1);
  border-top-color: var(--sc-primary, #3462AF);
  animation: spinLoader 0.8s linear infinite;
}

.section-loader-text {
  font-family: var(--font-sans, 'Raleway', sans-serif);
  font-size: 1rem;
  font-weight: 500;
  color: var(--sc-gray-600, #64748b);
}

/* Skeleton loader mejorado para tablas */
.table-skeleton {
  display: table;
  width: 100%;
}

.table-skeleton-row {
  display: table-row;
}

.table-skeleton-cell {
  display: table-cell;
  padding: 1rem;
  vertical-align: middle;
}

.table-skeleton-cell .skeleton {
  height: 1rem;
  margin-bottom: 0.5rem;
}

.table-skeleton-cell .skeleton:last-child {
  margin-bottom: 0;
  width: 60%;
}

/* Loader para cards */
.card-loader {
  background: white;
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

/* Animación de pulso suave */
@keyframes pulseLoader {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.page-loader-spinner.pulse {
  animation: pulseLoader 1.5s ease-in-out infinite;
}

/* Prefers reduced motion */
@media (prefers-reduced-motion: reduce) {
  .page-loader-spinner::before,
  .page-loader-spinner::after,
  .section-loader-spinner::before {
    animation: none !important;
  }
  
  .page-loader-spinner::before,
  .page-loader-spinner::after {
    border-top-color: var(--sc-primary, #3462AF);
  }
}

