/* ==================== BIBLIOTECA V4 - DISEÃ‘O PROFESIONAL ==================== */

:root {
  --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --accent-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  --gold-gradient: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  
  --primary-color: #667eea;
  --primary-dark: #5568d3;
  --secondary-color: #764ba2;
  
  --text-primary: #1a1a2e;
  --text-secondary: #4a5568;
  --text-muted: #718096;
  
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fe;
  --bg-tertiary: #f1f3f9;
  
  --border-light: #e8ecf4;
  --border-medium: #d4dae8;
  
  --shadow-sm: 0 2px 8px rgba(102, 126, 234, 0.08);
  --shadow-md: 0 4px 16px rgba(102, 126, 234, 0.12);
  --shadow-lg: 0 8px 32px rgba(102, 126, 234, 0.16);
  --shadow-xl: 0 12px 48px rgba(102, 126, 234, 0.24);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.lista_contenidos_v3 {
  background: var(--bg-secondary);
  overflow-x: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.biblioteca-main {
  padding: 0;
  overflow-x: hidden;
}

.biblioteca-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0;
  overflow-x: hidden;
}

/* ==================== HEADER MEJORADO ==================== */
.page-header {
  background: var(--bg-primary);
  padding: 16px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 95px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 800;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.page-header h1 i {
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.results-badge {
  background: linear-gradient(135deg, #f0f4ff 0%, #e9ecfe 100%);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-color);
  border: 1px solid rgba(102, 126, 234, 0.2);
}

.header-right {
  display: flex;
  gap: 10px;
  align-items: center;
}

.btn-header {
  padding: 10px 18px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-header:hover {
  background: var(--primary-gradient);
  color: white;
  border-color: transparent;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-upgrade {
  background: var(--gold-gradient);
  color: #78350f;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(251, 191, 36, 0.3);
}

.btn-upgrade:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(251, 191, 36, 0.4);
}

.badge-premium {
  background: var(--gold-gradient);
  color: #78350f;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(251, 191, 36, 0.3);
}

/* ==================== BANNERS CAROUSEL MEJORADO ==================== */
.banners-carousel {
  /* height: 200px; */
  /* margin: 24px 0; */
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  margin-top: 105px;
}

.banners-carousel img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: var(--radius-lg);
}

.carousel-control-prev,
.carousel-control-next {
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  transition: all var(--transition-base);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-md);
}

.banners-carousel:hover .carousel-control-prev,
.banners-carousel:hover .carousel-control-next {
  opacity: 1;
}

.carousel-control-prev {
  left: 20px;
}

.carousel-control-next {
  right: 20px;
}

/* ==================== LAYOUT PRINCIPAL ==================== */
.main-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  padding: 0 24px 60px;
  max-width: 100%;
  overflow-x: hidden;
}

/* ==================== SIDEBAR FILTROS REDISEÃ‘ADA ==================== */
.sidebar-filters {
  position: sticky;
  top: 105px;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: 24px;
  height: fit-content;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-light);
}

.sidebar-filters::-webkit-scrollbar {
  width: 6px;
}

.sidebar-filters::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: 10px;
}

.sidebar-filters::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 10px;
}

.filters-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--bg-tertiary);
}

.filters-header h3 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

.btn-clear {
  background: var(--bg-tertiary);
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: all var(--transition-fast);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-clear:hover {
  background: #fee2e2;
  color: #ef4444;
  transform: rotate(90deg);
}

.filter-group {
  margin-bottom: 20px;
}

.filter-group label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
  margin-bottom: 8px;
}

.filter-group .form-control,
.filter-group .form-select {
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  background: var(--bg-secondary);
}

.filter-group .form-control:focus,
.filter-group .form-select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
  outline: none;
}

.categories-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cat-filter {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
  color: var(--text-primary);
  position: relative;
  overflow: hidden;
}

.cat-filter::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--primary-gradient);
  transform: scaleY(0);
  transition: transform var(--transition-fast);
}

.cat-filter:hover {
  background: var(--bg-tertiary);
  border-color: var(--primary-color);
  transform: translateX(4px);
}

.cat-filter:hover::before {
  transform: scaleY(1);
}

.cat-filter.active {
  background: var(--primary-gradient);
  color: white;
  border-color: transparent;
  box-shadow: var(--shadow-md);
}

.cat-filter.active::before {
  display: none;
}

.cat-filter span {
  background: rgba(0,0,0,0.15);
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  min-width: 24px;
  text-align: center;
}

.cat-filter.active span {
  background: rgba(255,255,255,0.25);
}

.subcats-wrapper {
  margin-top: 12px;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

.subcats-wrapper label {
  margin-bottom: 10px;
}

#subcats-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.resource-checks {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.resource-checks label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-transform: none;
  color: var(--text-primary);
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.resource-checks label:hover {
  background: var(--bg-secondary);
}

.resource-checks input {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary-color);
}

/* ==================== CONTENIDO PRINCIPAL ==================== */
.main-content {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
  overflow-x: hidden;
}

.section-header-inline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  min-width: 0;
}

.section-header-inline h2 {
  font-size: 22px;
  font-weight: 800;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-primary);
  min-width: 0;
}

.section-header-inline h2 i {
  color: var(--primary-color);
  font-size: 24px;
}

/* ==================== DESTACADOS SLIDER MEJORADO ==================== */
.destacados-section {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  border: 1px solid var(--border-light);
}

.slider-controls {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.slider-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-light);
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  font-size: 16px;
}

.slider-btn:hover {
  border-color: var(--primary-color);
  background: var(--primary-gradient);
  color: white;
  transform: scale(1.1);
  box-shadow: var(--shadow-md);
}

.destacados-slider {
  display: flex;
  gap: 20px;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: none;
  padding: 4px;
  margin: 0 -28px;
  padding: 4px 28px;
}

.destacados-slider::-webkit-scrollbar {
  display: none;
}

.destacado-item {
  flex: 0 0 240px;
}

/* ==================== CATEGORÃAS CARDS MEJORADAS ==================== */
.categorias-section {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  border: 1px solid var(--border-light);
}

.categorias-section h2 {
  font-size: 22px;
  font-weight: 800;
  margin: 0 0 24px 0;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-primary);
}

.categorias-section h2 i {
  color: var(--primary-color);
  font-size: 24px;
}

.categorias-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  width: 100%;
  overflow: hidden;
}

.cat-card {
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.cat-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--cat-color);
  transform: scaleY(0);
  transition: transform var(--transition-base);
}

.cat-card::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, var(--cat-color) 0%, transparent 70%);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.cat-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
  border-color: var(--cat-color);
}

.cat-card:hover::before {
  transform: scaleY(1);
}

.cat-card:hover::after {
  opacity: 0.05;
}

.cat-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  background: var(--cat-color);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  position: relative;
  z-index: 1;
}

.cat-icon i {
  font-size: 24px;
  color: white;
}

.cat-info {
  flex: 1;
  min-width: 0;
  position: relative;
  z-index: 1;
}

.cat-info h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 4px 0;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cat-info span {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.cat-arrow {
  color: var(--border-medium);
  font-size: 20px;
  transition: all var(--transition-base);
  position: relative;
  z-index: 1;
}

.cat-card:hover .cat-arrow {
  color: var(--cat-color);
  transform: translateX(8px);
}

/* ==================== SECCIONES DE CONTENIDO ==================== */
.content-section {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  border: 1px solid var(--border-light);
}

.btn-see-all {
  padding: 10px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary-color);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  white-space: nowrap;
}

.btn-see-all:hover {
  background: var(--primary-gradient);
  color: white;
  border-color: transparent;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-see-all i {
  transition: transform var(--transition-fast);
}

.btn-see-all:hover i {
  transform: translateX(4px);
}

/* ==================== GRID DE CONTENIDOS OPTIMIZADO ==================== */
.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  width: 100%;
  overflow: hidden;
}

/* ==================== CONTENT CARD PREMIUM ==================== */
.content-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: all var(--transition-base);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: var(--shadow-sm);
}

.content-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--primary-gradient);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--transition-base);
}

.content-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-color);
}

.content-card:hover::before {
  transform: scaleX(1);
}

.card-thumbnail {
  width: 100%;
  aspect-ratio: 16/9;
  overflow: hidden;
  background: linear-gradient(135deg, #f0f4ff 0%, #e9ecfe 100%);
  display: block;
  position: relative;
}

.card-thumbnail::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.3) 100%);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.content-card:hover .card-thumbnail::after {
  opacity: 1;
}

.card-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow);
}

.content-card:hover .card-thumbnail img {
  transform: scale(1.1);
}

.card-body {
  padding: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 8px 0;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text-primary);
  min-height: 42px;
}

.card-meta {
  font-size: 13px;
  color: #f59e0b;
  margin-bottom: 8px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-creator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 10px;
  margin-top: auto;
  border-top: 1px solid var(--border-light);
}

.creator-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.creator-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.destacado-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--gold-gradient);
  color: white;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 800;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(251, 191, 36, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ==================== ESTADOS ==================== */
.loading-state {
  text-align: center;
  padding: 60px;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.loading-state .spinner-border {
  width: 3rem;
  height: 3rem;
  border-width: 4px;
  color: var(--primary-color);
}

.empty-state {
  text-align: center;
  padding: 80px 32px;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.empty-state i {
  font-size: 64px;
  color: var(--text-muted);
  margin-bottom: 20px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.empty-state p {
  color: var(--text-muted);
  margin-bottom: 24px;
  font-size: 16px;
}

.empty-state .btn {
  padding: 12px 32px;
  font-weight: 600;
  border-radius: 10px;
}

/* ==================== BOTÃ“N FILTROS MOBILE ==================== */
.btn-filter-mobile {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  background: var(--primary-gradient);
  color: white;
  border: 3px solid white;
  border-radius: 60px;
  padding: 16px 28px;
  box-shadow: var(--shadow-xl);
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: floatBtn 3s ease-in-out infinite;
}

@keyframes floatBtn {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-8px); }
}

#filter-badge {
  background: #ef4444;
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1400px) {
  .categorias-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 1200px) {
  .main-layout {
    grid-template-columns: 1fr;
    padding: 0 16px 60px;
  }
  
  .sidebar-filters {
    position: fixed;
    top: 0;
    left: -320px;
    width: 300px;
    height: 100vh;
    z-index: 1100;
    transition: left 0.3s;
    max-height: 100vh;
    border-radius: 0;
  }
  
  .sidebar-filters.active {
    left: 0;
  }
  
  .categorias-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .page-header {
    padding: 12px 16px;
  }
  
  .page-header h1 {
    font-size: 20px;
  }
  
  .header-right {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .btn-header {
    font-size: 13px;
    padding: 8px 14px;
  }
  
  .main-layout {
    padding: 0 12px 60px;
  }
  
  .banners-carousel {
    height: 160px;
    margin: 16px 0;
  }
  
  .banners-carousel img {
    height: 160px;
  }
  
  .content-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
  
  .categorias-cards {
    grid-template-columns: 1fr;
  }
  
  .destacados-slider {
    margin: 0 -28px;
    padding: 4px 28px;
  }
  
  .destacado-item {
flex: 0 0 200px;
}
.content-section,
.destacados-section,
.categorias-section {
padding: 20px;
}
}
@media (max-width: 480px) {
.content-grid {
grid-template-columns: 1fr;
gap: 16px;
}
.main-layout {
padding: 0 8px 60px;
}
.page-header h1 {
font-size: 18px;
}
.results-badge {
font-size: 11px;
padding: 4px 10px;
}
}
.sidebar-overlay {
display: none;
position: fixed;
inset: 0;
background: rgba(26, 26, 46, 0.6);
z-index: 1050;
opacity: 0;
transition: opacity 0.3s;
backdrop-filter: blur(4px);
}
.sidebar-overlay.active {
display: block;
opacity: 1;
}
/* ==================== ANIMACIONES ADICIONALES ==================== */
@keyframes slideInUp {
from {
opacity: 0;
transform: translateY(30px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.content-card {
animation: slideInUp 0.4s ease-out backwards;
}
.content-card:nth-child(1) { animation-delay: 0.05s; }
.content-card:nth-child(2) { animation-delay: 0.1s; }
.content-card:nth-child(3) { animation-delay: 0.15s; }
.content-card:nth-child(4) { animation-delay: 0.2s; }
.content-card:nth-child(5) { animation-delay: 0.25s; }
.content-card:nth-child(6) { animation-delay: 0.3s; }

/* ============================================
   AJUSTES EXTRA MOBILE â€“ HEADER + BIBLIOTECA
   ============================================ */

/* -------- HEADER / NAV MOBILE -------- */
@media (max-width: 991.98px) {
  /* contenedor del header mÃ¡s compacto */
  #header .container {
    /* padding-inline: 1rem; */
  }

  .header-row {
    padding-block: 0.5rem;
  }

  /* logo mÃ¡s chico en celulares */
  #header .brand img {
    max-width: 170px;
    height: auto;
  }

  /* nav colapsable: oculto por defecto, visible sÃ³lo con .active */
  #header .main-nav {
    display: none;
    width: 100%;
    margin-top: 0.35rem;
  }

  #header .main-nav.active {
    display: block;
    background: rgb(50 16 133 / 86%); /* fondo oscuro sÃ³lido */
    /* border-radius: 12px; */
    padding: 0.75rem 1rem 1rem;
    margin: 0;
  }

  #header .nav-links {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
  }

  #header .nav-link.header-link {
    padding: 0.35rem 0;
    font-size: 0.95rem;
    color: #e5e7eb;
  }

  #header .nav-link.header-link:hover {
    color: #ffffff;
  }

  /* separador â€œ|â€ fuera de mobile */
  #header .nav-sep {
    display: none !important;
  }

  /* CTA flotante sÃ³lo si existe (cuando no hay usuario logueado) */
  .home-login-cta {
    position: absolute;
    top: 0.55rem;
    right: 0.75rem;
    background: #6366f1;
    color: #fff;
    border-radius: 999px;
    padding: 0.35rem 0.8rem;
    font-size: 0.8rem;
    display: none;
    align-items: center;
    gap: 0.35rem;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.4);
    z-index: 20;
  }

  .home-login-cta .label {
    display: inline;
  }
}

/* campana y menÃº de notificaciones 100% ancho en celulares chicos */
@media (max-width: 575.98px) {
  .notifications-menu {
    right: 0.5rem;
    width: calc(100vw - 1rem);
    max-width: none;
  }

  .user-dropdown-menu {
    right: 0.5rem;
    width: calc(100vw - 1rem);
  }
}

/* -------- BIBLIOTECA â€“ LAYOUT MOBILE -------- */
@media (max-width: 991.98px) {
  .biblioteca-main {
    padding-bottom: 90px; /* espacio para el botÃ³n de filtros flotante */
  }

  .page-header {
    padding: 0.75rem 1rem 0.5rem;
  }

  .page-header .header-left {
    width: 100%;
    justify-content: space-between;
  }

  .page-header .header-right {
    width: 100%;
    justify-content: flex-end;
  }

  /* botones de header sÃ³lo iconitos en mobile */
  .page-header .btn-header {
    padding: 0.45rem;
    min-width: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .page-header .btn-header .btn-text {
    display: none;
  }

  .results-badge {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
  }

  /* grid de layout: sidebar arriba del contenido, pero lo usamos como off-canvas */
  .main-layout {
    grid-template-columns: 1fr;
    padding: 0.75rem;
    gap: 1.25rem;
  }

  /* sidebar como panel deslizable */
  .sidebar-filters {
    position: fixed;
    inset: 0 auto 0 0;
    width: 85%;
    max-width: 340px;
    height: 100vh;
    background: #ffffff;
    z-index: 1050;
    overflow-y: auto;
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.25);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    padding: 1rem 1rem 1.5rem;
  }

  .sidebar-filters.active {
    transform: translateX(0);
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 1040;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

  .sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
  }
}

/* botÃ³n flotante de filtros optimizado para telÃ©fonos */
@media (max-width: 991.98px) {
  .btn-filter-mobile {
    bottom: 16px;
    right: 16px;
    width: 56px;
    height: 56px;
    font-size: 1.1rem;
  }

  .btn-filter-mobile span:not(.badge) {
    font-size: 0.65rem;
  }
}

/* -------- CARDS Y SLIDERS EN CELULAR -------- */
@media (max-width: 575.98px) {
  .banners-carousel {
    margin-bottom: 1.25rem;
    border-radius: 10px;
  }

  .banners-carousel img {
    max-height: 160px;
  }

  .destacados-section {
    margin-bottom: 1.25rem;
  }

  .section-header-inline h2 {
    font-size: 1.15rem;
  }

  .content-grid {
    grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
    gap: 0.75rem;
  }

  .content-card {
    border-radius: 10px;
  }

  .card-body {
    padding: 0.7rem 0.75rem 0.8rem;
  }

  .card-title {
    font-size: 0.85rem;
  }

  .card-meta {
    font-size: 0.72rem;
  }

  .creator-avatar {
    width: 22px;
    height: 22px;
    font-size: 0.6rem;
  }

  .creator-name {
    font-size: 0.72rem;
  }

  .categorias-cards {
    grid-template-columns: 1fr;
    gap: 0.9rem;
  }

  .cat-card {
    padding: 1.15rem;
  }
}

/* ===============================
   PAGE HEADER â€“ MOBILE OPTIMIZADO
   =============================== */
@media (max-width: 991.98px) {

  .page-header {
    position: sticky;
    top: 64px; /* justo debajo del header principal */
    z-index: 900;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0,0,0,0.06);
    padding: 0.75rem 0.9rem 0.85rem;
    box-shadow: 0 6px 18px rgba(0,0,0,0.06);
  }

  /* ---------- fila superior ---------- */
  .page-header .header-left {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
  }

  .page-header h1 {
    font-size: 1rem;
    font-weight: 800;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    line-height: 1;
  }

  .page-header h1 i {
    font-size: 1rem;
    color: var(--primary-color);
  }

  .page-header .header-text {
    display: inline-block;
  }

  /* badge resultados compacto */
  .results-badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    white-space: nowrap;
  }

  /* ---------- acciones ---------- */
  .page-header .header-right {
    margin-top: 0.65rem;
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.15rem;
  }

  .page-header .header-right::-webkit-scrollbar {
    display: none;
  }

  .page-header .header-right {
    scrollbar-width: none;
  }

  /* botones tipo â€œchipsâ€ */
  .page-header .btn-header {
    flex: 0 0 auto;
    padding: 0.4rem 0.6rem;
    font-size: 0.75rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: #f1f3f9;
    border: 1px solid #e5e7eb;
    font-weight: 600;
  }

  .page-header .btn-header i {
    font-size: 0.75rem;
  }

  /* esconder texto largo si hace falta */
  .page-header .btn-header .btn-text {
    display: none;
  }

  /* premium como icono */
  .badge-premium {
    flex: 0 0 auto;
    padding: 0.45rem;
    border-radius: 50%;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}








/* ============================================
   OPTIMIZACIONES MOBILE - BIBLIOTECA
   DiseÃ±o compacto, profesional y fÃ¡cil de usar
   ============================================ */

/* ========== AJUSTES GENERALES MOBILE ========== */
@media (max-width: 991.98px) {
  
  /* Reducir padding general del contenedor */
  .biblioteca-main {
    padding-bottom: 80px;
  }
  
  .biblioteca-container {
    padding: 0;
  }

  /* Layout principal: columna Ãºnica */
  .main-layout {
    grid-template-columns: 1fr;
    padding: 0.5rem;
    gap: 1rem;
  }

  /* ========== PAGE HEADER COMPACTO ========== */
  .page-header {
    position: sticky;
    top: 60px;
    z-index: 900;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    padding: 0.6rem 0.75rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    flex-wrap: wrap;
  }

  .page-header .header-left {
    width: 100%;
    flex-wrap: nowrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
  }

  .page-header h1 {
    font-size: 1.1rem;
    gap: 0.4rem;
  }

  .page-header h1 i {
    font-size: 1rem;
  }

  .results-badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    white-space: nowrap;
  }

  .page-header .header-right {
    width: 100%;
    gap: 0.4rem;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 0.25rem;
  }

  .page-header .header-right::-webkit-scrollbar {
    display: none;
  }

  /* Botones header: mÃ¡s pequeÃ±os y compactos */
  .page-header .btn-header {
    flex: 0 0 auto;
    padding: 0.4rem 0.6rem;
    font-size: 0.75rem;
    min-width: auto;
    border-radius: 8px;
    gap: 0.3rem;
  }

  .page-header .btn-header i {
    font-size: 0.8rem;
  }

  /* Ocultar textos de botones en pantallas muy pequeÃ±as */
  .page-header .btn-header .btn-text {
    display: inline;
  }

  .badge-premium {
    padding: 0.4rem 0.7rem;
    font-size: 0.75rem;
  }

  /* ========== BANNERS CAROUSEL - COMPACTO ========== */
  .banners-carousel {
    height: 120px;
    margin: 0.75rem 0;
    border-radius: 10px;
  }

  .banners-carousel img {
    height: 120px;
    object-fit: cover;
  }

  .carousel-control-prev,
  .carousel-control-next {
    width: 32px;
    height: 32px;
  }

  .carousel-control-prev {
    left: 10px;
  }

  .carousel-control-next {
    right: 10px;
  }

  /* ========== DESTACADOS SLIDER - OPTIMIZADO ========== */
  .destacados-section {
    padding: 1rem;
    margin-bottom: 1rem;
  }

  .section-header-inline {
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .section-header-inline h2 {
    font-size: 1.1rem;
    gap: 0.5rem;
  }

  .section-header-inline h2 i {
    font-size: 1.1rem;
  }

  .slider-controls {
    gap: 0.4rem;
  }

  .slider-btn {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }

  /* Viewport del slider mÃ¡s compacto */
  .destacados-viewport {
    padding: 0;
    /* margin: 0 -1rem; */
  }

  .destacados-slider {
    padding: 0 1rem;
    gap: 0.75rem;
  }

  /* Items destacados: mÃ¡s pequeÃ±os */
  .destacado-item {
    flex: 0 0 160px;
  }

  .destacado-item .content-card {
    margin: 0;
  }

  .destacado-badge {
    top: 8px;
    right: 8px;
    padding: 4px 8px;
    font-size: 0.65rem;
  }

  /* ========== CATEGORÃAS CARDS - COMPACTAS ========== */
  .categorias-section {
    padding: 1rem;
    margin-bottom: 1rem;
  }

  .categorias-section h2 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
  }

  .categorias-cards {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .cat-card {
    padding: 0.9rem;
    gap: 0.75rem;
    border-radius: 10px;
  }

  .cat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
  }

  .cat-icon i {
    font-size: 1.1rem;
  }

  .cat-info h3 {
    font-size: 0.9rem;
  }

  .cat-info span {
    font-size: 0.75rem;
  }

  .cat-arrow {
    font-size: 1rem;
  }

  /* ========== CONTENT SECTIONS - COMPACTAS ========== */
  .content-section {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 12px;
  }

  .btn-see-all {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    gap: 0.3rem;
    border-radius: 8px;
  }

  /* ========== CONTENT GRID - OPTIMIZADO ========== */
  .content-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  /* ========== CONTENT CARDS - COMPACTAS ========== */
  .content-card {
    border-radius: 10px;
  }

  .card-thumbnail {
    aspect-ratio: 16/9;
  }

  .card-body {
    padding: 0.7rem;
  }

  .card-title {
    font-size: 0.85rem;
    line-height: 1.3;
    margin-bottom: 0.5rem;
    min-height: 34px;
    -webkit-line-clamp: 2;
  }

  .card-meta {
    font-size: 0.7rem;
    margin-bottom: 0.5rem;
  }

  .card-creator {
    padding-top: 0.5rem;
    gap: 0.5rem;
  }

  .creator-avatar {
    width: 24px;
    height: 24px;
    font-size: 0.65rem;
  }

  .creator-name {
    font-size: 0.7rem;
  }

  /* ========== BOTÃ“N FILTROS FLOTANTE ========== */
  .btn-filter-mobile {
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    padding: 0;
    flex-direction: column;
    gap: 0.2rem;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.35);
  }

  .btn-filter-mobile i {
    font-size: 1.2rem;
  }

  .btn-filter-mobile span:not(.badge) {
    font-size: 0.6rem;
    font-weight: 700;
  }

  #filter-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    min-width: 18px;
    height: 18px;
    font-size: 0.65rem;
  }

  /* ========== SIDEBAR FILTROS COMO DRAWER ========== */
  .sidebar-filters {
    position: fixed;
    top: 0;
    left: -100%;
    width: 85%;
    max-width: 320px;
    height: 100vh;
    z-index: 1100;
    transition: left 0.3s ease;
    max-height: 100vh;
    border-radius: 0;
    padding: 1rem;
  }

  .sidebar-filters.active {
    left: 0;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1050;
    opacity: 0;
    transition: opacity 0.3s;
  }

  .sidebar-overlay.active {
    display: block;
    opacity: 1;
  }

  /* Filtros mÃ¡s compactos */
  .filters-header {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
  }

  .filters-header h3 {
    font-size: 1.1rem;
  }

  .filter-group {
    margin-bottom: 1rem;
  }

  .filter-group label {
    font-size: 0.7rem;
    margin-bottom: 0.5rem;
  }

  .filter-group .form-control,
  .filter-group .form-select {
    font-size: 0.85rem;
    padding: 0.5rem;
  }

  .cat-filter {
    padding: 0.6rem 0.75rem;
    font-size: 0.85rem;
  }

  .cat-filter span {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
  }

  .subcats-wrapper {
    padding: 0.75rem;
  }

  .resource-checks label {
    font-size: 0.85rem;
    padding: 0.5rem;
  }

  /* ========== ESTADOS ========== */
  .loading-state {
    padding: 2rem 1rem;
  }

  .loading-state .spinner-border {
    width: 2.5rem;
    height: 2.5rem;
  }

  .empty-state {
    padding: 3rem 1rem;
  }

  .empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
  }

  .empty-state h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
  }

  .empty-state p {
    font-size: 0.9rem;
    margin-bottom: 1rem;
  }

  /* ========== RESULTADOS FILTRADOS ========== */
  #resultados-filtrados .content-section {
    padding: 1rem;
  }

  #listado-contenidos {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
}

/* ========== PANTALLAS MUY PEQUEÃ‘AS (< 576px) ========== */
@media (max-width: 575.98px) {
  
  /* Header aÃºn mÃ¡s compacto */
  .page-header {
    padding: 0.5rem;
  }

  .page-header h1 {
    font-size: 1rem;
  }

  .page-header .btn-header .btn-text {
    display: none; /* Ocultar textos completamente */
  }

  .page-header .btn-header {
    padding: 0.45rem;
    min-width: 36px;
  }

  /* Banners mÃ¡s pequeÃ±os */
  .banners-carousel {
    height: 100px;
    margin: 0.5rem 0;
  }

  .banners-carousel img {
    height: 100px;
  }

  /* Sections mÃ¡s compactas */
  .destacados-section,
  .categorias-section,
  .content-section {
    padding: 0.75rem;
    margin-bottom: 0.75rem;
  }

  .section-header-inline h2 {
    font-size: 1rem;
  }

  /* Destacados slider aÃºn mÃ¡s pequeÃ±o */
  .destacado-item {
    flex: 0 0 140px;
  }

  /* CategorÃ­as cards mÃ¡s compactas */
  .cat-card {
    padding: 0.75rem;
  }

  .cat-icon {
    width: 40px;
    height: 40px;
  }

  .cat-icon i {
    font-size: 1rem;
  }

  .cat-info h3 {
    font-size: 0.85rem;
  }

  /* Content grid: 2 columnas mÃ¡s estrechas */
  .content-grid,
  #listado-contenidos {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
  }

  /* Cards mÃ¡s compactas */
  .card-body {
    padding: 0.6rem;
  }

  .card-title {
    font-size: 0.8rem;
    min-height: 32px;
  }

  .card-meta {
    font-size: 0.68rem;
  }

  .creator-avatar {
    width: 22px;
    height: 22px;
    font-size: 0.6rem;
  }

  .creator-name {
    font-size: 0.68rem;
  }

  /* BotÃ³n filtros */
  .btn-filter-mobile {
    bottom: 16px;
    right: 16px;
    width: 52px;
    height: 52px;
  }

  /* Sidebar mÃ¡s estrecho */
  .sidebar-filters {
    width: 90%;
    max-width: 280px;
  }
}

/* ========== PANTALLAS EXTRA PEQUEÃ‘AS (< 400px) ========== */
@media (max-width: 399.98px) {
  
  /* Layout ultra compacto */
  .main-layout {
    padding: 0.35rem;
  }

  /* Header minimalista */
  .page-header {
    padding: 0.4rem;
  }

  .page-header h1 {
    font-size: 0.95rem;
  }

  .results-badge {
    font-size: 0.65rem;
    padding: 0.2rem 0.4rem;
  }

  /* Banners mÃ­nimos */
  .banners-carousel {
    height: 90px;
  }

  .banners-carousel img {
    height: 90px;
  }

  /* Content grid: podrÃ­a ser 1 columna si lo prefieres */
  .content-grid,
  #listado-contenidos {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  /* Cards ultra compactas */
  .content-card {
    border-radius: 8px;
  }

  .card-body {
    padding: 0.5rem;
  }

  .card-title {
    font-size: 0.75rem;
    min-height: 30px;
  }

  .card-meta {
    font-size: 0.65rem;
    margin-bottom: 0.4rem;
  }

  .card-creator {
    padding-top: 0.4rem;
  }

  .creator-avatar {
    width: 20px;
    height: 20px;
    font-size: 0.55rem;
  }

  .creator-name {
    font-size: 0.65rem;
  }

  /* Sections ultra compactas */
  .destacados-section,
  .categorias-section,
  .content-section {
    padding: 0.6rem;
    margin-bottom: 0.6rem;
  }

  .section-header-inline {
    margin-bottom: 0.6rem;
  }

  .section-header-inline h2 {
    font-size: 0.95rem;
  }

  /* Destacados muy pequeÃ±os */
  .destacado-item {
    flex: 0 0 130px;
  }

  /* CategorÃ­as cards ultra compactas */
  .categorias-cards {
    gap: 0.6rem;
  }

  .cat-card {
    padding: 0.65rem;
    gap: 0.6rem;
  }

  .cat-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
  }

  .cat-icon i {
    font-size: 0.95rem;
  }

  .cat-info h3 {
    font-size: 0.8rem;
  }

  .cat-info span {
    font-size: 0.7rem;
  }
}

/* ========== AJUSTES PARA LANDSCAPE EN MÃ“VILES ========== */
@media (max-width: 991.98px) and (orientation: landscape) {
  
  .page-header {
    position: sticky;
    top: 0;
  }

  .banners-carousel {
    height: 140px;
  }

  .banners-carousel img {
    height: 140px;
  }

  /* Grid mÃ¡s amplio en landscape */
  .content-grid,
  #listado-contenidos {
    grid-template-columns: repeat(3, 1fr);
  }

  .destacado-item {
    flex: 0 0 180px;
  }
}

/* ========== OPTIMIZACIÃ“N DE RENDIMIENTO ========== */
@media (max-width: 991.98px) {
  
  /* Reducir animaciones en mÃ³viles para mejor performance */
  .content-card {
    animation: none;
  }

  /* Transiciones mÃ¡s rÃ¡pidas */
  .content-card,
  .cat-card,
  .btn-header,
  .cat-filter {
    transition-duration: 0.2s;
  }

  /* Optimizar hover/active states para touch */
  .content-card:active,
  .cat-card:active {
    transform: scale(0.98);
  }

  .btn-header:active,
  .cat-filter:active,
  .slider-btn:active {
    transform: scale(0.95);
  }
}

/* ========== ACCESIBILIDAD MOBILE ========== */
@media (max-width: 991.98px) {
  
  /* Ãreas de toque mÃ­nimas de 44x44px */
  .btn-header,
  .slider-btn,
  .btn-clear,
  .cat-filter {
    min-height: 44px;
    min-width: 44px;
  }

  /* Espaciado tÃ¡ctil adecuado */
  .header-right {
    gap: 0.5rem;
  }

  .slider-controls {
    gap: 0.5rem;
  }

  /* Contraste mejorado en pantallas pequeÃ±as */
  .card-title,
  .cat-info h3,
  .section-header-inline h2 {
    color: #1a1a2e;
    font-weight: 700;
  }
}

/* ========== SCROLL SUAVE EN MOBILE ========== */
@media (max-width: 991.98px) {
  
  .destacados-slider,
  .header-right {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
  }

  /* Ocultar scrollbars en mÃ³vil para diseÃ±o mÃ¡s limpio */
  .destacados-slider::-webkit-scrollbar,
  .header-right::-webkit-scrollbar {
    display: none;
  }
}

/* ========== AJUSTES FINALES DE ESPACIADO ========== */
@media (max-width: 991.98px) {
  
  /* Espaciado consistente entre secciones */
  .destacados-section + .categorias-section,
  .categorias-section + .content-section,
  .content-section + .content-section {
    margin-top: 0;
  }

  /* Padding inferior para scroll cÃ³modo */
  .main-content {
    padding-bottom: 1rem;
  }

  .destacados-section .card-thumbnail {
    width: 100vh!important;
  
  }

  .btn-filter-mobile span:not(.badge) {
  font-size: 0.7rem;
  margin-top: 2px;
  display: none!important;
}

.section-header-inline {
  margin-bottom: 0!important;
}
}