* {
  box-sizing: border-box;
}

body {
  box-sizing: border-box;
  scroll-behavior: smooth;
}

/* ===== ANIMACIONES MEJORADAS ===== */
.course-card {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.course-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.course-card:hover::before {
  left: 100%;
}

.course-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.course-card:active {
  transform: translateY(-4px) scale(1.01);
}

/* Efecto de arrastre mejorado */
.course-card[draggable="true"] {
  cursor: grab;
}

.course-card[draggable="true"]:active {
  cursor: grabbing;
}

.checkbox-custom {
  width: 20px;
  height: 20px;
  cursor: pointer;
  transition: transform 0.2s;
}

.checkbox-custom:hover {
  transform: scale(1.1);
}

.completed-card {
  opacity: 0.7;
  position: relative;
}

.completed-card::after {
  content: '✓';
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(16, 185, 129, 0.9);
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 18px;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

/* ===== TOAST MEJORADO ===== */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 16px 24px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  z-index: 10000;
  animation: toastSlideIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  min-width: 250px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.toast::before {
  content: '';
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes toastSlideIn {
  from {
    transform: translateX(400px) scale(0.8);
    opacity: 0;
  }
  to {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
}

@keyframes slideInMenu {
  from {
    transform: translateX(-280px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ===== MODAL MEJORADO ===== */
.modal-overlay {
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ===== BADGES Y CATEGORÍAS ===== */
.category-badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.category-badge::before {
  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.3s, height 0.3s;
}

.category-badge:hover::before {
  width: 200px;
  height: 200px;
}

.category-badge:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ===== LOADING STATES ===== */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Skeleton Loader */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: 8px;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.skeleton-card {
  height: 300px;
  margin-bottom: 24px;
}

/* ===== BOTONES MEJORADOS ===== */
button {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

button::before {
  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, height 0.4s;
}

button:hover::before {
  width: 300px;
  height: 300px;
}

button:active {
  transform: scale(0.98);
}

/* ===== BÚSQUEDA Y FILTROS ===== */
.search-container {
  position: relative;
}

.search-container input {
  transition: all 0.3s;
}

.search-container input:focus {
  transform: scale(1.02);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

/* ===== ESTADÍSTICAS ===== */
.stats-card {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: all 0.3s;
}

.stats-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

/* ===== VISTA GRID/LISTA ===== */
.view-toggle {
  display: flex;
  gap: 8px;
  background: rgba(255, 255, 255, 0.1);
  padding: 4px;
  border-radius: 8px;
}

.view-toggle button {
  padding: 8px 16px;
  border-radius: 6px;
  transition: all 0.2s;
}

.view-toggle button.active {
  background: rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ===== FAVORITOS ===== */
.favorite-btn {
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.favorite-btn:hover {
  transform: scale(1.2) rotate(10deg);
}

.favorite-btn.active {
  animation: heartBeat 0.5s;
}

@keyframes heartBeat {
  0%, 100% { transform: scale(1); }
  25% { transform: scale(1.3); }
  50% { transform: scale(1.1); }
  75% { transform: scale(1.2); }
}

/* ===== SCROLLBAR PERSONALIZADO ===== */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  transition: background 0.3s;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* ===== CONTENEDOR DE BLOQUES - ANCHO COMPLETO ===== */
#blocksContent {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

#blocksContent > div {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* ===== IMÁGENES EN BLOQUES - MEJORAS PARA MÓVILES ===== */
#blocksContent img {
  max-width: 100% !important;
  width: 100% !important;
  height: auto !important;
  display: block;
  margin: 0 auto;
  border-radius: 8px;
  box-sizing: border-box !important;
}

#blocksContent img[src=""],
#blocksContent img:not([src]) {
  display: none;
}

/* Asegurar que las imágenes se carguen correctamente */
#blocksContent img {
  object-fit: contain;
}

/* Videos e iframes también a ancho completo */
#blocksContent iframe,
#blocksContent video {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

/* Párrafos y texto también a ancho completo */
#blocksContent p,
#blocksContent div {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .course-card:hover {
    transform: translateY(-4px) scale(1.01);
  }
  
  .toast {
    right: 10px;
    left: 10px;
    min-width: auto;
  }
  
  /* Mejoras para imágenes en móviles */
  #blocksContent {
    padding: 16px !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  
  #blocksContent > div {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  
  #blocksContent img {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: none !important;
    object-fit: contain !important;
    display: block !important;
  }
  
  #blocksContent iframe,
  #blocksContent video {
    width: 100% !important;
    max-width: 100% !important;
  }
  
  /* Modal a pantalla completa en móviles */
  .modal-overlay {
    padding: 0 !important;
  }
  
  .modal-overlay > div {
    width: 100% !important;
    height: 100vh !important;
    max-width: 100% !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
  }
  
  /* Botón de cerrar más grande en móviles */
  .close-float-btn {
    width: 48px !important;
    height: 48px !important;
    font-size: 24px !important;
    top: 12px !important;
    right: 12px !important;
  }
  
  /* Asegurar que los botones del modal siempre sean visibles */
  .course-detail-footer {
    position: relative !important;
    z-index: 200 !important;
    background-color: inherit !important;
    min-height: 80px !important;
  }
  
  .course-detail-content {
    padding-bottom: 150px !important; /* Espacio para los botones */
  }
  
  .modal-overlay button.delete-course-btn,
  .modal-overlay button.edit-course-btn,
  .modal-overlay button.edit-content-btn {
    position: relative !important;
    z-index: 201 !important;
    opacity: 1 !important;
    visibility: visible !important;
  }
  
  .course-detail-header {
    position: relative !important;
    z-index: 100 !important;
  }
}

/* ===== EFECTOS DE ENTRADA ===== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-up {
  animation: fadeInUp 0.5s ease-out;
}

/* ===== PULSO PARA NOTIFICACIONES ===== */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* ===== CARRUSEL Y LISTA HORIZONTAL ===== */
.carousel-container {
  display: flex;
  gap: 16px;
  transition: transform 0.5s ease-in-out;
}

.horizontal-scroll-container {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 16px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
}

.horizontal-scroll-container::-webkit-scrollbar {
  height: 8px;
}

.horizontal-scroll-container::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 10px;
}

.horizontal-scroll-container::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  transition: background 0.3s;
}

.horizontal-scroll-container::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* Sección de categoría */
.category-section {
  margin-bottom: 48px;
}

/* Sección de categoría */
.category-section {
  margin-bottom: 48px;
  width: 100%;
}

.category-section > div {
  width: 100%;
}

/* Asegurar que las tarjetas en cuadrícula 2x2 ocupen el espacio correcto */
.category-section .course-card {
  width: 100%;
  box-sizing: border-box;
}

/* Asegurar que las tarjetas en lista horizontal no se compriman */
.horizontal-scroll-container .course-card {
  flex-shrink: 0;
  width: auto;
  min-width: 320px;
  max-width: none;
}

/* Responsive para cuadrículas */
@media (max-width: 768px) {
  .category-section > div[style*="grid-template-columns: repeat(2"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }
  
  /* Cuadrícula 3x3 - Responsive */
  .grid-3x3-container {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 16px !important;
    width: 100% !important;
  }
  
  /* Cuadrícula 4x4 - Responsive */
  .grid-4x4-container {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 16px !important;
    width: 100% !important;
  }
  
  /* En tablets, la cuadrícula 4x4 se adapta a 3 columnas */
  @media (min-width: 641px) and (max-width: 1024px) {
    .grid-4x4-container {
      grid-template-columns: repeat(3, 1fr) !important;
      gap: 12px !important;
    }
  }
  
  /* En móviles, las cuadrículas 3x3 y 4x4 se adaptan a 2 columnas */
  @media (max-width: 640px) {
    .grid-3x3-container {
      grid-template-columns: repeat(2, 1fr) !important;
      gap: 12px !important;
    }
    
    .grid-4x4-container {
      grid-template-columns: repeat(2, 1fr) !important;
      gap: 12px !important;
    }
  }
  
  .horizontal-scroll-container > .course-card {
    min-width: 280px !important;
  }
  
  .carousel-container > .course-card {
    min-width: 100% !important;
  }
}

