/**
 * ========================================
 * STYLES.CSS - Estilos Personalizados
 * ========================================
 * 
 * Complemento a Tailwind CSS para:
 * - Animaciones personalizadas
 * - Estilos globales
 * - Mejoras de accesibilidad
 * - Micro-interacciones
 */

/* ========== VARIABLES CSS ========== */
:root {
  --color-primary: #18181b;
  --color-primary-hover: #27272a;
  --color-accent: #2563eb;
  --color-success: #16a34a;
  --color-warning: #d97706;
  --color-error: #dc2626;
  
  --shadow-soft: 0 4px 24px rgba(0, 0, 0, 0.06);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-card-hover: 0 8px 32px rgba(0, 0, 0, 0.12);
  
  --transition-fast: 150ms ease-out;
  --transition-normal: 200ms ease-out;
  --transition-slow: 300ms ease-out;
}

/* ========== RESET Y BASE ========== */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px; /* Compensar el header sticky */
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.6;
}

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

/* Slide in desde la derecha */
@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Fade in */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Scale up (para modales) */
@keyframes scaleUp {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Shake (para errores) */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-10px); }
  20%, 40%, 60%, 80% { transform: translateX(10px); }
}

/* Pulse suave */
@keyframes pulse-soft {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ========== CLASES DE UTILIDAD ========== */

.animate-slide-in {
  animation: slideIn 0.3s ease-out;
}

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

.animate-scale-up {
  animation: scaleUp 0.2s ease-out;
}

.animate-shake {
  animation: shake 0.5s ease-in-out;
}

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

/* ========== MEJORAS DE CARDS ========== */

.medication-card {
  transition: all var(--transition-normal);
}

.medication-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}

/* ========== MEJORAS DE INPUTS ========== */

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(24, 24, 27, 0.1);
}

input::placeholder,
textarea::placeholder {
  color: #a1a1aa;
}

/* ========== SCROLLBAR PERSONALIZADA ========== */

/* Para navegadores WebKit (Chrome, Safari, Edge) */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: #f4f4f5;
}

::-webkit-scrollbar-thumb {
  background: #d4d4d8;
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a1a1aa;
}

/* Para Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: #d4d4d8 #f4f4f5;
}

/* ========== MEJORAS DE ACCESIBILIDAD ========== */

/* Focus visible mejorado */
*:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Reducir movimiento para usuarios con preferencias de accesibilidad */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ========== ESTADOS DE CARGA ========== */

.loading {
  opacity: 0.6;
  pointer-events: none;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border: 2px solid #f4f4f5;
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ========== ESTADOS VACÍOS ========== */

.empty-state {
  padding: 3rem 1.5rem;
  text-align: center;
  color: #71717a;
}

/* ========== BADGES Y PILLS ========== */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
}

/* ========== MODAL OVERLAY ========== */

#modal-overlay {
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease-out;
}

#modal-content {
  max-height: 90vh;
  overflow-y: auto;
}

/* Prevenir scroll del body cuando el modal está abierto */
body.modal-open {
  overflow: hidden;
}

/* ========== NOTIFICACIONES ========== */

#notification-container {
  pointer-events: none;
}

#notification-container > * {
  pointer-events: auto;
}

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

@media (max-width: 768px) {
  table {
    font-size: 0.875rem;
  }
  
  th, td {
    padding: 0.75rem 0.5rem !important;
  }
}

/* ========== MEJORAS TIPOGRÁFICAS ========== */

h1, h2, h3, h4, h5, h6 {
  line-height: 1.2;
  font-weight: 700;
}

/* ========== BOTONES MEJORADOS ========== */

button {
  cursor: pointer;
  user-select: none;
  transition: all var(--transition-normal);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button:active:not(:disabled) {
  transform: scale(0.98);
}

/* ========== GRID RESPONSIVO MEJORADO ========== */

@media (max-width: 640px) {
  .grid {
    gap: 1rem;
  }
}

/* ========== UTILIDADES DE IMPRESIÓN ========== */

@media print {
  header,
  footer,
  button,
  #modal-overlay,
  #notification-container {
    display: none !important;
  }
  
  body {
    background: white;
  }
  
  .medication-card {
    break-inside: avoid;
    border: 1px solid #e4e4e7;
  }
}

/* ========== DARK MODE PREPARACIÓN (futuro) ========== */

@media (prefers-color-scheme: dark) {
  /* Se puede agregar dark mode en el futuro */
}

/* ========== EFECTOS DE HOVER ESPECÍFICOS ========== */

.btn-edit:hover {
  background-color: #e4e4e7;
}

.btn-delete:hover {
  background-color: #fee2e2;
}

.btn-toggle:hover {
  opacity: 0.9;
}

/* ========== SEPARADORES VISUALES ========== */

.divider {
  height: 1px;
  background: linear-gradient(to right, transparent, #e4e4e7, transparent);
  margin: 2rem 0;
}

/* ========== EFECTOS DE GLASSMORPHISM (sutiles) ========== */

.glass {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

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

[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  padding: 0.5rem 0.75rem;
  background: var(--color-primary);
  color: white;
  font-size: 0.875rem;
  border-radius: 0.5rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

[data-tooltip]:hover::after {
  opacity: 1;
}

/* ========== SKELETON LOADERS (para carga futura) ========== */

.skeleton {
  background: linear-gradient(
    90deg,
    #f4f4f5 25%,
    #e4e4e7 50%,
    #f4f4f5 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
}

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

/* ========== MEJORAS MOBILE ========== */

@media (max-width: 768px) {
  /* Aumentar área de toque en móviles */
  button,
  a {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Reducir padding en cards móviles */
  .medication-card {
    padding: 1rem !important;
  }
}

/* ========== ESTADOS DE ERROR ========== */

.error-state {
  color: var(--color-error);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

input.error,
textarea.error {
  border-color: var(--color-error);
}

/* ========== ANIMACIONES DE ENTRADA ESCALONADAS ========== */

.stagger-children > * {
  animation: fadeIn 0.3s ease-out backwards;
}

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

/* ========== FIN ========== */

