/* Modal base - igual que modal-muestra */
#pdf-modal {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.9);
  transition: opacity 0.3s ease;
}

/* Cuando el modal se abre con JS */
#pdf-modal[style*="display: block"] {
  display: flex !important;
  align-items: center;
  justify-content: center;
}

/* Contenido del modal - simplificado pero con tu estructura */
.pdf-modal-content {
  display: flex;
  flex-direction: column;
  background-color: #fff;
  max-width: 90%;
  max-height: 80%;
  border-radius: 16px;
  box-shadow: 0 0 20px rgb(255, 204, 0);
  margin: 0;
  padding: 1em;
  overflow: hidden;
  animation: fadeIn 0.3s ease-out forwards;
  width: 600px; /* Ancho por defecto */
}

/* Animación */
@keyframes fadeIn {
  0% {
    opacity: 0;
    transform: scale(0.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Contenedor del canvas */
#pdf-canvas-container {
  flex: 1 1 auto;
  overflow: auto;
  text-align: center;
  max-height: 55vh;
  min-height: 0;
}

.pdf-page-canvas {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Controles del PDF */
#pdf-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1em;
  padding: 0.8em 0 0.5em 0;
  flex-shrink: 0;
}

#pdf-controls button {
  background-color: #ffcc00;
  color: #000;
  border: none;
  padding: 0.6em 1.2em;
  font-size: 1em;
  font-weight: bold;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.3s ease;
  min-width: 80px;
}

#pdf-controls button:hover {
  background-color: #e6b800;
}

#page-num {
  font-weight: bold;
  font-size: 1.1em;
  color: #000000;
  white-space: nowrap;
}

/* Contenedor del botón cerrar - MANTENIDO */
#close-btn-container {
  display: flex;
  justify-content: center;
  padding: 0.5em 0 0 0;
  flex-shrink: 0;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  margin-top: 0.5em;
}

#close-pdf-btn {
  background-color: #ff4747;
  color: white;
  border: none;
  padding: 0.6em 1.2em;
  font-size: 1.1em;
  font-weight: bold;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.3s ease;
  width: 100%;
  max-width: 200px;
}

#close-pdf-btn:hover {
  background-color: #e63636;
}

/* ===== NUEVOS ESTILOS PARA PDF-ACTIONS ===== */
/* Estilos base para .pdf-actions - los botones en fila por defecto */
.pdf-actions {
  display: flex;
  gap: 1rem; /* Espacio horizontal entre elementos */
  flex-wrap: wrap; /* Permite que los elementos se envuelvan si es necesario */
}

/* MEDIA QUERY PARA MÓVILES VERTICAL - Botones en columna */
@media (max-width: 768px) and (orientation: portrait) {
  .pdf-actions {
    flex-direction: column; /* Cambia a columna en móvil vertical */
    gap: 1rem; /* Espacio vertical entre los botones */
    align-items: stretch; /* Los botones ocupan todo el ancho disponible */
  }
  
  .pdf-actions .pdf-link {
    width: 100%; /* Cada botón ocupa el 100% del ancho */
    text-align: center; /* Texto centrado */
    padding: 0.8rem 1rem; /* Padding más cómodo para tocar */
    margin: 0; /* Eliminar márgenes que puedan interferir */
    box-sizing: border-box; /* Asegura que el padding no desborde */
  }
}

/* Opcional: Para móviles muy pequeños en vertical */
@media (max-width: 480px) and (orientation: portrait) {
  .pdf-actions {
    gap: 0.75rem; /* Espacio ligeramente menor pero aún cómodo */
  }
  
  .pdf-actions .pdf-link {
    padding: 0.7rem 0.8rem; /* Padding ligeramente ajustado */
    font-size: 0.95rem; /* Texto ligeramente más pequeño */
  }
}
/* ===== FIN NUEVOS ESTILOS ===== */

/* MEDIA QUERIES PARA EL MODAL */

/* Tablets y móviles vertical */
@media (max-width: 768px) and (orientation: portrait) {
  .pdf-modal-content {
    max-width: 95%;
    max-height: 85%;
    padding: 0.8em;
    border-radius: 12px;
  }
  
  #pdf-canvas-container {
    max-height: 60vh;
  }
  
  #pdf-controls button {
    padding: 0.5em 1em;
    min-width: 70px;
    font-size: 0.9em;
  }
  
  #close-pdf-btn {
    max-width: 150px;
    padding: 0.5em 1em;
  }
}

/* Móviles horizontal - CORREGIDO (centrado perfecto) */
@media (max-width: 900px) and (orientation: landscape) {
  .pdf-modal-content {
    max-width: 90%;
    max-height: 85%;
    padding: 0.8em;
    border-radius: 12px;
    width: auto;
    min-width: 400px;
  }
  
  #pdf-canvas-container {
    max-height: 45vh; /* Reducido para dar espacio en horizontal */
  }
  
  #pdf-controls {
    gap: 0.5em;
    padding: 0.5em 0 0.3em 0;
  }
  
  #pdf-controls button {
    padding: 0.4em 0.8em;
    min-width: 70px;
    font-size: 0.9em;
  }
  
  #close-btn-container {
    padding: 0.3em 0 0 0;
    margin-top: 0.3em;
  }
  
  #close-pdf-btn {
    max-width: 150px;
    padding: 0.4em 0.8em;
    font-size: 1em;
  }
}

/* Dispositivos muy pequeños en horizontal */
@media (max-width: 600px) and (orientation: landscape) {
  .pdf-modal-content {
    min-width: 320px;
    padding: 0.5em;
  }
  
  #pdf-canvas-container {
    max-height: 40vh;
  }
  
  #pdf-controls button {
    padding: 0.3em 0.6em;
    min-width: 60px;
    font-size: 0.8em;
  }
  
  #close-pdf-btn {
    max-width: 120px;
    padding: 0.3em 0.6em;
    font-size: 0.9em;
  }
}

/* Pantallas grandes */
@media (min-width: 1200px) {
  .pdf-modal-content {
    width: 800px;
  }
  
  #pdf-canvas-container {
    max-height: 65vh;
  }
}

/* Loading state */
.pdf-loading {
  text-align: center;
  padding: 20px;
  font-size: 16px;
  color: #666;
}

/* Estilos para botones de PDF */
.pdf-link,
.view-pdf-btn {
  display: inline-block;
  padding: 0.5em 1em;
  background-color: #ffcc00;
  color: #000;
  text-decoration: none;
  border-radius: 4px;
  font-weight: bold;
  transition: background-color 0.3s ease, color 0.3s ease;
  cursor: pointer;
}

.pdf-link:hover,
.view-pdf-btn:hover {
  background-color: #e6b800;
  color: #000;
}

.document-actions .pdf-link,
.document-actions .view-pdf-btn {
  margin: 0.5em;
}

.pdf-page-link {
  color: #ffcc00;
  text-decoration: none;
  transition: color 0.2s ease;
  cursor: pointer;
}

.pdf-page-link:hover {
  color: #ffffff;
  text-decoration: underline;
}

.pdf-page-link:visited {
  color: #ffaa00;
}