/* ═══════════════════════════════════════════════════════════════
   KLINAFY - ESTILOS DE BIBLIOTECA DE APARATOS
   Diseño moderno y profesional
   
   CREADO: 28 Enero 2026
   ═══════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════
   MODAL PRINCIPAL
   ═══════════════════════════════════════════════════════════════ */

.biblioteca-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(17, 24, 39, 0.8);
  backdrop-filter: blur(8px);
  z-index: 9999;
  overflow-y: auto;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.biblioteca-modal.active {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 20px;
  opacity: 1;
}

.biblioteca-container {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border-radius: 20px;
  width: 100%;
  max-width: 1200px;
  min-height: 80vh;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.4s ease;
  overflow: hidden;
}

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

/* ═══════════════════════════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════════════════════════ */

.biblioteca-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 25px 30px;
  background: linear-gradient(135deg, #3a5a8a 0%, #1b2d51 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.biblioteca-titulo {
  display: flex;
  align-items: center;
  gap: 15px;
}

.biblioteca-icono {
  font-size: 32px;
}

.biblioteca-titulo h1 {
  font-size: 24px;
  font-weight: 700;
  color: white;
  margin: 0;
}

.biblioteca-badge {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.biblioteca-cerrar {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  color: white;
  transition: all 0.2s ease;
}

.biblioteca-cerrar:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: rotate(90deg);
}

/* ═══════════════════════════════════════════════════════════════
   FILTROS Y BÚSQUEDA
   ═══════════════════════════════════════════════════════════════ */

.biblioteca-filtros {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  padding: 20px 30px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.filtro-busqueda {
  flex: 1;
  min-width: 250px;
  position: relative;
}

.busqueda-icono {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: #a0aec0;
}

.filtro-busqueda input {
  width: 100%;
  padding: 12px 15px 12px 45px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: white;
  font-size: 15px;
  transition: all 0.2s ease;
}

.filtro-busqueda input::placeholder {
  color: #718096;
}

.filtro-busqueda input:focus {
  outline: none;
  border-color: #3a5a8a;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 4px rgba(26, 111, 168, 0.2);
}

.filtros-grupo {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.filtros-grupo select {
  padding: 12px 35px 12px 15px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: white;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a0aec0' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.filtros-grupo select:focus {
  outline: none;
  border-color: #3a5a8a;
}

.filtros-grupo select option {
  background: #1a1a2e;
  color: white;
}

/* ═══════════════════════════════════════════════════════════════
   CONTADOR
   ═══════════════════════════════════════════════════════════════ */

.biblioteca-contador {
  padding: 15px 30px;
  color: #a0aec0;
  font-size: 14px;
}

.biblioteca-contador span {
  color: #3a5a8a;
  font-weight: 700;
}

/* ═══════════════════════════════════════════════════════════════
   GRID DE APARATOS
   ═══════════════════════════════════════════════════════════════ */

.biblioteca-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  padding: 20px 30px 30px;
}

/* ═══════════════════════════════════════════════════════════════
   TARJETAS DE APARATOS
   ═══════════════════════════════════════════════════════════════ */

.aparato-tarjeta {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.aparato-tarjeta::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, #3a5a8a, #1b2d51);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.aparato-tarjeta:hover {
  transform: translateY(-5px);
  border-color: rgba(26, 111, 168, 0.3);
  box-shadow: 0 10px 40px rgba(26, 111, 168, 0.2);
}

.aparato-tarjeta:hover::before {
  opacity: 1;
}

/* Categorías con colores */
.aparato-tarjeta.cat-expansor::before { background: linear-gradient(90deg, #48bb78, #38a169); }
.aparato-tarjeta.cat-funcional::before { background: linear-gradient(90deg, #4299e1, #3182ce); }
.aparato-tarjeta.cat-extraoral::before { background: linear-gradient(90deg, #ed8936, #dd6b20); }
.aparato-tarjeta.cat-miofuncional::before { background: linear-gradient(90deg, #d4a84b, #7594d5); }

.tarjeta-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.tarjeta-icono {
  font-size: 24px;
}

.tarjeta-categoria {
  font-size: 11px;
  color: #a0aec0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(255, 255, 255, 0.05);
  padding: 3px 8px;
  border-radius: 4px;
}

.tarjeta-nombre {
  color: white;
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 12px 0;
  line-height: 1.3;
}

.tarjeta-info {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.info-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #a0aec0;
}

.info-item svg {
  opacity: 0.7;
}

.tarjeta-descripcion {
  color: #718096;
  font-size: 13px;
  line-height: 1.5;
  margin: 0 0 15px 0;
}

.tarjeta-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 12px;
}

.ver-mas {
  color: #3a5a8a;
  font-size: 13px;
  font-weight: 600;
  transition: color 0.2s ease;
}

.aparato-tarjeta:hover .ver-mas {
  color: #a78bfa;
}

/* ═══════════════════════════════════════════════════════════════
   SIN RESULTADOS
   ═══════════════════════════════════════════════════════════════ */

.biblioteca-sin-resultados {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
}

.sin-resultados-icono {
  font-size: 64px;
  display: block;
  margin-bottom: 20px;
  opacity: 0.5;
}

.biblioteca-sin-resultados p {
  color: #a0aec0;
  font-size: 16px;
  margin-bottom: 20px;
}

.biblioteca-sin-resultados button {
  background: linear-gradient(135deg, #3a5a8a, #1b2d51);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.biblioteca-sin-resultados button:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(26, 111, 168, 0.4);
}

/* ═══════════════════════════════════════════════════════════════
   MODAL DE FICHA DE APARATO
   ═══════════════════════════════════════════════════════════════ */

.ficha-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 10001;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 20px;
  overflow-y: auto;
}

.ficha-overlay.active {
  display: flex;
}

.ficha-container {
  background: white;
  border-radius: 20px;
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.3);
  animation: fichaSlideIn 0.3s ease;
}

@keyframes fichaSlideIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.ficha-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 25px 30px;
  background: linear-gradient(135deg, #3a5a8a 0%, #1b2d51 100%);
  position: sticky;
  top: 0;
  z-index: 10;
}

.ficha-titulo-grupo {
  display: flex;
  align-items: center;
  gap: 15px;
}

.ficha-icono {
  font-size: 40px;
  background: rgba(255, 255, 255, 0.2);
  padding: 10px;
  border-radius: 12px;
}

.ficha-nombre {
  color: white;
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 5px 0;
}

.ficha-categoria {
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
}

.ficha-cerrar {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 10px;
  padding: 8px;
  cursor: pointer;
  color: white;
  transition: all 0.2s ease;
}

.ficha-cerrar:hover {
  background: rgba(255, 255, 255, 0.2);
}

.ficha-body {
  padding: 30px;
}

/* Info básica */
.ficha-info-basica {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  margin-bottom: 30px;
}

.info-badge {
  background: #f7fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px 16px;
  flex: 1;
  min-width: 150px;
}

.badge-label {
  display: block;
  font-size: 11px;
  color: #718096;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.badge-value {
  font-size: 14px;
  font-weight: 600;
  color: #2d3748;
}

/* Secciones */
.ficha-seccion {
  margin-bottom: 25px;
}

.ficha-seccion h3 {
  font-size: 16px;
  font-weight: 700;
  color: #2d3748;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e2e8f0;
}

.ficha-seccion p {
  color: #4a5568;
  line-height: 1.7;
  font-size: 14px;
}

.ficha-seccion ul,
.ficha-seccion ol {
  margin: 0;
  padding-left: 20px;
}

.ficha-seccion li {
  color: #4a5568;
  line-height: 1.6;
  font-size: 14px;
  margin-bottom: 8px;
}

/* Colores por tipo de sección */
.ficha-indicaciones h3 { color: #276749; }
.ficha-indicaciones li::marker { color: #48bb78; }

.ficha-contraindicaciones h3 { color: #c53030; }
.ficha-contraindicaciones li::marker { color: #fc8181; }

.ficha-efectos h3 { color: #c05621; }
.ficha-efectos li::marker { color: #ed8936; }

.ficha-cuidados h3 { color: #2b6cb0; }
.ficha-cuidados li::marker { color: #4299e1; }

.ficha-notas {
  background: #fffbeb;
  border: 1px solid #fef3c7;
  border-radius: 12px;
  padding: 20px;
}

.ficha-notas h3 {
  border-bottom-color: #fcd34d;
}

.ficha-notas p {
  color: #92400e;
}

/* Footer de ficha */
.ficha-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 20px 30px;
  background: #f7fafc;
  border-top: 1px solid #e2e8f0;
}

.btn-imprimir {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #3a5a8a, #1b2d51);
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-imprimir:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(26, 111, 168, 0.4);
}

.btn-cerrar-ficha {
  background: #e2e8f0;
  color: #4a5568;
  border: none;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-cerrar-ficha:hover {
  background: #cbd5e0;
}

/* ═══════════════════════════════════════════════════════════════
   MODAL DE BLOQUEO
   ═══════════════════════════════════════════════════════════════ */

.biblioteca-bloqueo-content {
  background: white;
  border-radius: 20px;
  padding: 50px 40px;
  text-align: center;
  max-width: 400px;
  margin: auto;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.4s ease;
}

.bloqueo-icono {
  font-size: 64px;
  margin-bottom: 20px;
}

.biblioteca-bloqueo-content h2 {
  color: #2d3748;
  font-size: 24px;
  margin-bottom: 15px;
}

.biblioteca-bloqueo-content p {
  color: #718096;
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 30px;
}

.bloqueo-acciones {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-upgrade {
  background: linear-gradient(135deg, #3a5a8a, #1b2d51);
  color: white;
  border: none;
  padding: 14px 24px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-upgrade:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(26, 111, 168, 0.4);
}

.btn-cerrar {
  background: #e2e8f0;
  color: #4a5568;
  border: none;
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-cerrar:hover {
  background: #cbd5e0;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .biblioteca-modal.active {
    padding: 10px;
  }
  
  .biblioteca-container {
    border-radius: 16px;
  }
  
  .biblioteca-header {
    padding: 20px;
  }
  
  .biblioteca-titulo h1 {
    font-size: 18px;
  }
  
  .biblioteca-filtros {
    padding: 15px 20px;
    flex-direction: column;
  }
  
  .filtros-grupo {
    width: 100%;
  }
  
  .filtros-grupo select {
    flex: 1;
    min-width: 0;
  }
  
  .biblioteca-grid {
    grid-template-columns: 1fr;
    padding: 15px 20px 20px;
    gap: 15px;
  }
  
  .ficha-overlay {
    padding: 10px;
  }
  
  .ficha-container {
    max-height: none;
    border-radius: 16px;
  }
  
  .ficha-header {
    padding: 20px;
  }
  
  .ficha-nombre {
    font-size: 18px;
  }
  
  .ficha-body {
    padding: 20px;
  }
  
  .ficha-info-basica {
    flex-direction: column;
  }
  
  .info-badge {
    min-width: 100%;
  }
  
  .ficha-footer {
    flex-direction: column;
    padding: 15px 20px;
  }
  
  .btn-imprimir,
  .btn-cerrar-ficha {
    width: 100%;
    justify-content: center;
  }
}

/* ═══════════════════════════════════════════════════════════════
   SCROLLBAR PERSONALIZADO
   ═══════════════════════════════════════════════════════════════ */

.biblioteca-container::-webkit-scrollbar,
.ficha-container::-webkit-scrollbar {
  width: 8px;
}

.biblioteca-container::-webkit-scrollbar-track,
.ficha-container::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}

.biblioteca-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.ficha-container::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 4px;
}

.biblioteca-container::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

.ficha-container::-webkit-scrollbar-thumb:hover {
  background: #a0aec0;
}

/* ═══════════════════════════════════════════════════════════════
   FIX: MODAL DE FICHA - POSICIONAMIENTO Y VISIBILIDAD
   El modal de ficha ahora está directamente en el body (no anidado)
   para que position:fixed funcione correctamente
   ═══════════════════════════════════════════════════════════════ */

/* Sobreescribir estilos del overlay para comportamiento correcto */
.ficha-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 10001; /* Mayor que biblioteca-modal (9999) */
  overflow-y: auto;
  padding: 20px;
  box-sizing: border-box;
}

.ficha-overlay.active {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  animation: fadeInOverlay 0.25s ease-out;
}

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

/* Container de ficha con animación mejorada */
.ficha-overlay.active .ficha-container {
  animation: slideInFicha 0.3s ease-out;
  margin-top: 20px;
  margin-bottom: 20px;
}

@keyframes slideInFicha {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-30px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ═══════════════════════════════════════════════════════════════
   FEATURE CARD - BIBLIOTECA DE APARATOS
   Estilos para el botón de acceso desde el formulario principal
   ═══════════════════════════════════════════════════════════════ */

/* Variante púrpura para Biblioteca */
.feature-card--purple {
  background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
  border: none;
}

.feature-card--purple:hover {
  background: linear-gradient(135deg, #6d28d9 0%, #9333ea 100%);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(124, 58, 237, 0.35);
}

.feature-card--purple .feature-card__title {
  color: white;
}

.feature-card--purple .feature-card__description {
  color: rgba(255, 255, 255, 0.9);
}

/* Badge PLUS */
.feature-card__badge--plus {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  vertical-align: middle;
  display: inline-block;
  box-shadow: 0 2px 4px rgba(245, 158, 11, 0.3);
}

/* ═══════════════════════════════════════════════════════════════
   BOTÓN ACCESO RÁPIDO - NAVEGACIÓN
   ═══════════════════════════════════════════════════════════════ */

.btn-biblioteca {
  background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
  color: white;
  border: none;
  transition: all 0.2s ease;
}

.btn-biblioteca:hover {
  background: linear-gradient(135deg, #6d28d9 0%, #9333ea 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}
