/* ==========================================================================
   FLIPBOOK STUDIO - SISTEMA DE DISEÑO PREMIUM (MODO OSCURO VIBRANTE)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

:root {
  /* Paleta de Colores Curada (HSL para Control de Luminosidad) */
  --bg-deep-space: hsl(224, 45%, 7%);
  --bg-card-glass: hsla(223, 47%, 13%, 0.65);
  --bg-input-glass: hsla(223, 40%, 8%, 0.5);
  --border-glass: hsla(223, 35%, 25%, 0.35);
  --border-focus: hsla(188, 100%, 35%, 0.6);
  
  /* Gradientes de Acentuación */
  --accent-primary: hsl(188, 100%, 35%);     /* Cyan Teal Brand Color (#009ab1) */
  --accent-secondary: hsl(188, 100%, 45%);   /* Slightly lighter Cyan for highlights (#00ceec) */
  --accent-danger: hsl(342, 90%, 60%);      /* Rose Crimson */
  
  --grad-primary: linear-gradient(135deg, var(--accent-primary) 0%, hsl(188, 100%, 40%) 50%, var(--accent-secondary) 100%);
  --grad-sunset: linear-gradient(135deg, hsl(342, 90%, 60%) 0%, var(--accent-primary) 100%);
  --grad-glow: 0 8px 32px 0 hsla(188, 100%, 35%, 0.25);
  --grad-teal-glow: 0 8px 32px 0 hsla(188, 100%, 45%, 0.2);

  /* Texto */
  --text-white: hsl(0, 0%, 100%);
  --text-primary: hsl(210, 38%, 95%);
  --text-secondary: hsl(215, 20%, 65%);
  --text-muted: hsl(218, 15%, 45%);

  /* Animaciones y Bordes */
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --transition-smooth: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: all 0.2s ease;
}

/* ==========================================================================
   RESETS Y ESTILOS BASE
   ========================================================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background-color: var(--bg-deep-space);
  background-image: 
    radial-gradient(at 10% 10%, hsla(188, 100%, 35%, 0.12) 0px, transparent 45%),
    radial-gradient(at 90% 90%, hsla(188, 100%, 45%, 0.08) 0px, transparent 40%),
    radial-gradient(at 50% 10%, hsla(188, 100%, 40%, 0.05) 0px, transparent 50%);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

h1, h2, h3, h4, .font-display {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Scrollbar Personalizada */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-deep-space);
}
::-webkit-scrollbar-thumb {
  background: var(--border-glass);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

/* ==========================================================================
   ESTILOS DE CONTENEDORES Y GLASSMORPHISM
   ========================================================================== */

.glass-card {
  background: var(--bg-card-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  transition: var(--transition-smooth);
}

.glass-card:hover {
  border-color: hsla(223, 35%, 35%, 0.5);
  box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.5);
}

/* ==========================================================================
   PANTALLA DE ACCESO (LOGIN)
   ========================================================================== */

.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 460px;
  padding: 48px 40px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: '';
  position: absolute;
  top: -150px;
  left: -150px;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, hsla(263, 90%, 65%, 0.15) 0%, transparent 70%);
  pointer-events: none;
}

.brand-logo {
  font-size: 2.2rem;
  background: var(--grad-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
  display: inline-block;
}

.brand-tagline {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 36px;
}

.login-btn-group {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

/* Botones de Proveedores de Identidad (SSO) */
.btn-sso {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 24px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glass);
  background: var(--bg-input-glass);
  color: var(--text-primary);
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  outline: none;
  width: 100%;
}

.btn-sso:hover {
  background: hsla(223, 40%, 18%, 0.8);
  border-color: var(--border-focus);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.btn-sso svg {
  width: 20px;
  height: 20px;
}

.btn-sso.corporate {
  background: linear-gradient(135deg, hsla(263, 90%, 65%, 0.1) 0%, hsla(190, 95%, 50%, 0.05) 100%);
  border: 1px solid hsla(263, 90%, 65%, 0.25);
}

.btn-sso.corporate:hover {
  border-color: var(--accent-secondary);
  box-shadow: var(--grad-teal-glow);
}

/* Formulario Simulado SSO */
.mock-sso-form {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px dashed var(--border-glass);
  text-align: left;
}

.mock-title {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
  text-align: center;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-glass);
  background: var(--bg-input-glass);
  color: var(--text-primary);
  outline: none;
  font-family: inherit;
  transition: var(--transition-fast);
}

.form-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px hsla(263, 90%, 65%, 0.25);
}

.btn-submit {
  width: 100%;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--grad-primary);
  color: var(--text-white);
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  text-align: center;
}

.btn-submit:hover {
  transform: translateY(-1px);
  box-shadow: var(--grad-glow);
  opacity: 0.95;
}

/* ==========================================================================
   DASHBOARD DE ADMINISTRACIÓN
   ========================================================================== */

.nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 48px;
  border-bottom: 1px solid var(--border-glass);
}

.nav-logo {
  font-size: 1.6rem;
  font-weight: 800;
  background: var(--grad-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-decoration: none;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 20px;
  background: var(--bg-card-glass);
  border: 1px solid var(--border-glass);
  font-size: 0.85rem;
}

.user-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-secondary);
  box-shadow: 0 0 8px var(--accent-secondary);
}

.btn-logout {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-glass);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.85rem;
  transition: var(--transition-fast);
  text-decoration: none;
}

.btn-logout:hover {
  border-color: var(--accent-danger);
  color: var(--accent-danger);
}

.main-dashboard {
  max-width: 1200px;
  margin: 40px auto;
  padding: 0 24px;
}

.dashboard-header {
  margin-bottom: 32px;
}

.dashboard-header h2 {
  font-size: 2.2rem;
  margin-bottom: 6px;
}

.dashboard-header p {
  color: var(--text-secondary);
}

/* Área Drag & Drop para PDF */
.upload-section {
  margin-bottom: 48px;
}

.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  border: 2px dashed var(--border-glass);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, hsla(263, 90%, 65%, 0.02) 0%, hsla(190, 95%, 50%, 0.02) 100%);
  cursor: pointer;
  transition: var(--transition-smooth);
  text-align: center;
}

.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent-primary);
  background: linear-gradient(135deg, hsla(263, 90%, 65%, 0.05) 0%, hsla(190, 95%, 50%, 0.05) 100%);
  box-shadow: var(--grad-glow);
}

.upload-icon {
  width: 64px;
  height: 64px;
  background: var(--grad-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 16px;
  animation: float 3s ease-in-out infinite;
}

.upload-zone h3 {
  font-size: 1.25rem;
  margin-bottom: 8px;
}

.upload-zone p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  max-width: 320px;
}

.upload-file-info {
  display: none;
  margin-top: 16px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-input-glass);
  border: 1px solid var(--border-glass);
  font-size: 0.9rem;
}

.upload-controls {
  display: none;
  margin-top: 20px;
  width: 100%;
  max-width: 300px;
}

/* Barra de progreso de subida */
.progress-bar-container {
  width: 100%;
  height: 6px;
  background: var(--bg-input-glass);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: var(--grad-primary);
  transition: width 0.1s ease;
}

/* Grilla de Flipbooks */
.grid-title {
  margin-bottom: 24px;
  font-size: 1.5rem;
  position: relative;
  display: inline-block;
}

.grid-title::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 40px;
  height: 3px;
  background: var(--grad-primary);
  border-radius: 1.5px;
}

.flipbook-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 24px;
}

.no-flipbooks {
  grid-column: 1 / -1;
  text-align: center;
  padding: 64px 24px;
  border: 1px dashed var(--border-glass);
  border-radius: var(--radius-lg);
  background: var(--bg-card-glass);
}

.no-flipbooks p {
  color: var(--text-secondary);
  margin-bottom: 16px;
}

/* Tarjeta del Flipbook */
.flip-card {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.flip-card:hover {
  transform: translateY(-5px);
  border-color: var(--border-focus);
}

.flip-preview-container {
  position: relative;
  width: 100%;
  height: 180px;
  background: var(--bg-input-glass);
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.flip-thumbnail {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  border-radius: 2px;
  transition: var(--transition-smooth);
}

.flip-card:hover .flip-thumbnail {
  transform: scale(1.05);
}

.flip-details {
  padding: 20px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.flip-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.flip-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.flip-actions {
  display: flex;
  gap: 10px;
}

.btn-action {
  flex: 1;
  padding: 10px 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-glass);
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-action.view {
  background: var(--bg-input-glass);
  color: var(--text-primary);
}

.btn-action.view:hover {
  background: hsla(223, 40%, 20%, 0.5);
  border-color: var(--accent-secondary);
}

.btn-action.share {
  background: var(--grad-primary);
  color: var(--text-white);
  border: none;
}

.btn-action.share:hover {
  box-shadow: var(--grad-glow);
  opacity: 0.95;
}

.btn-delete {
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-glass);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-delete:hover {
  border-color: var(--accent-danger);
  color: var(--accent-danger);
  background: rgba(244, 63, 94, 0.05);
}

/* ==========================================================================
   MODAL DE COMPARTIR E IFRAME
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 7, 12, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  width: 100%;
  max-width: 580px;
  padding: 32px;
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.open .modal-box {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h3 {
  font-size: 1.4rem;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-close:hover {
  color: var(--text-white);
}

.modal-body p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.iframe-code-container {
  position: relative;
  background: var(--bg-input-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 24px;
}

.iframe-code {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.85rem;
  color: var(--accent-secondary);
  word-break: break-all;
  user-select: all;
  white-space: pre-wrap;
}

.btn-copy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent-secondary);
  background: transparent;
  color: var(--accent-secondary);
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-copy:hover {
  background: hsla(190, 95%, 50%, 0.1);
}

/* ==========================================================================
   ALERTA FLOTANTE (TOAST)
   ========================================================================== */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1100;
}

.toast {
  padding: 16px 24px;
  border-radius: var(--radius-sm);
  background: var(--bg-card-glass);
  backdrop-filter: blur(10px);
  border-left: 4px solid var(--accent-primary);
  border-right: 1px solid var(--border-glass);
  border-top: 1px solid var(--border-glass);
  border-bottom: 1px solid var(--border-glass);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  color: var(--text-white);
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast.error {
  border-left-color: var(--accent-danger);
}

.toast.success {
  border-left-color: var(--accent-secondary);
}

/* ==========================================================================
   MOTOR DEL VISOR PÚBLICO (FLIPBOOK)
   ========================================================================== */

.viewer-body {
  overflow: hidden;
  height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
}

.viewer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: rgba(5, 7, 12, 0.5);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-glass);
  z-index: 10;
}

.viewer-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.viewer-actions {
  display: flex;
  gap: 12px;
}

.viewer-container {
  flex-grow: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;
}

/* Visor central del Flipbook */
.flipbook-viewport {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  perspective: 2000px; /* Para efecto 3D en transiciones CSS */
}

.flipbook-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  display: flex;
  justify-content: center;
  align-items: center;
}

.flipbook {
  position: relative;
  display: block; /* Cambiado a block para evitar conflictos de Flexbox con los absolute de StPageFlip */
  transform-style: preserve-3d;
}

/* Páginas del libro */
.page {
  position: absolute;
  width: 100%;
  height: 100%;
  background: white;
  transform-origin: left center;
  transition: transform 0.8s cubic-bezier(0.25, 1, 0.5, 1);
  backface-visibility: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.page.left-page {
  box-shadow: -10px 10px 30px rgba(0,0,0,0.5);
}

.page.right-page {
  box-shadow: 10px 10px 30px rgba(0,0,0,0.5);
}

.page canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Control flotante inferior */
.viewer-controls {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 24px;
  background: rgba(8, 12, 22, 0.35); /* Cristal oscuro muy traslúcido y futurista */
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1.5px solid rgba(0, 154, 177, 0.35); /* Borde cian neón semi-transparente */
  border-radius: 24px;
  box-shadow: 
    0 20px 45px rgba(0, 0, 0, 0.65), 
    0 0 25px rgba(0, 154, 177, 0.2), 
    inset 0 0 15px rgba(0, 154, 177, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  z-index: 10;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), transform 0.5s cubic-bezier(0.16, 1, 0.3, 1), background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.viewer-controls:hover {
  background: rgba(8, 12, 22, 0.5); /* Se intensifica al pasar el mouse */
  border-color: rgba(0, 154, 177, 0.85); /* Se enciende el borde cian */
  box-shadow: 
    0 25px 55px rgba(0, 0, 0, 0.75), 
    0 0 35px rgba(0, 154, 177, 0.45), 
    inset 0 0 20px rgba(0, 154, 177, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.viewer-controls.hidden-ctrl {
  opacity: 0;
  transform: translateX(-50%) translateY(28px);
  visibility: hidden;
  pointer-events: none;
}

.btn-ctrl {
  background: rgba(0, 154, 177, 0.04); /* Fondo cian muy sutil */
  border: 1px solid rgba(0, 154, 177, 0.2);
  color: var(--text-secondary);
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.05);
}

.btn-ctrl svg {
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-ctrl:hover:not(:disabled) {
  background: rgba(0, 154, 177, 0.25); /* Resaltado cian más fuerte */
  border-color: #009ab1; /* Color principal */
  color: var(--text-white);
  transform: translateY(-3px) scale(1.05);
  box-shadow: 
    0 0 15px rgba(0, 154, 177, 0.6), 
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  text-shadow: 0 0 8px #ffffff;
}

.btn-ctrl:hover:not(:disabled) svg {
  transform: scale(1.15);
}

.btn-ctrl:active:not(:disabled) {
  transform: translateY(-1px) scale(0.98);
}

.btn-ctrl:disabled {
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.25;
  background: rgba(255, 255, 255, 0.01);
  border-color: rgba(255, 255, 255, 0.05);
}

.page-info {
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  min-width: 90px;
  text-align: center;
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.45); /* Fondo oscuro digital */
  border: 1px solid rgba(0, 154, 177, 0.4);
  color: #00ceec; /* Cyan más brillante */
  text-shadow: 0 0 10px rgba(0, 154, 177, 0.8);
  letter-spacing: 0.05em;
  transition: all 0.3s ease;
}

.viewer-controls:hover .page-info {
  border-color: rgba(0, 154, 177, 0.75);
  box-shadow: inset 0 0 10px rgba(0, 154, 177, 0.3);
}

.divider-line {
  width: 2px;
  height: 28px;
  background: linear-gradient(180deg, transparent, rgba(0, 154, 177, 0.45), transparent);
  margin: 0 4px;
}

/* Indicador de Carga */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #ffffff !important;
  color: #000000 !important;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 100;
  transition: opacity 0.5s ease;
}

.loading-overlay h3 {
  color: #000000 !important;
}

.loading-overlay p {
  color: #4b5563 !important;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 3px solid #e5e7eb;
  border-top-color: #009ab1;
  border-bottom-color: #009ab1;
  border-radius: 50%;
  animation: spin 1.2s linear infinite;
  margin-bottom: 20px;
}

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

@keyframes float {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-8px); }
  100% { transform: translateY(0px); }
}

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

@keyframes slideIn {
  from { transform: translateX(100%) translateY(20px); opacity: 0; }
  to { transform: translateX(0) translateY(0); opacity: 1; }
}

/* ==========================================================================
   EFECTO 3D REALISTA DE PASO DE PÁGINAS Y SEGURIDAD
   ========================================================================== */

/* Contenedor central del motor StPageFlip */
.stPageFlip {
  box-shadow: 0 35px 85px rgba(0, 0, 0, 0.78); /* Sombra pesada fotorrealista flotante */
  background: transparent;
  border-radius: 8px; /* Bordes un poco más redondeados */
  overflow: visible !important; /* CRÍTICO: permite que las sombras y curvas no se recorten */
  position: relative;
}

/* Simulación física tridimensional de la acumulación de páginas a la izquierda (grosor dinámico) */
.stPageFlip::before {
  content: '';
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: calc(-1 * var(--left-thickness, 0px));
  width: var(--left-thickness, 0px);
  background: repeating-linear-gradient(to right, 
    #ffffff 0px, 
    #ffffff 1px, 
    #e2e8f0 1.5px, 
    #cbd5e1 2px);
  border-left: 1px solid rgba(0, 0, 0, 0.22);
  border-top: 1px solid rgba(0, 0, 0, 0.12);
  border-bottom: 1px solid rgba(0, 0, 0, 0.12);
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
  box-shadow: -4px 6px 15px rgba(0, 0, 0, 0.4);
  transition: width 0.35s cubic-bezier(0.25, 1, 0.5, 1), left 0.35s cubic-bezier(0.25, 1, 0.5, 1);
  pointer-events: none;
  z-index: -1;
  opacity: 0.95;
}

/* Simulación física tridimensional de la acumulación de páginas a la derecha (grosor dinámico) */
.stPageFlip::after {
  content: '';
  position: absolute;
  top: 4px;
  bottom: 4px;
  right: calc(-1 * var(--right-thickness, 0px));
  width: var(--right-thickness, 0px);
  background: repeating-linear-gradient(to left, 
    #ffffff 0px, 
    #ffffff 1px, 
    #e2e8f0 1.5px, 
    #cbd5e1 2px);
  border-right: 1px solid rgba(0, 0, 0, 0.22);
  border-top: 1px solid rgba(0, 0, 0, 0.12);
  border-bottom: 1px solid rgba(0, 0, 0, 0.12);
  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px;
  box-shadow: 4px 6px 15px rgba(0, 0, 0, 0.4);
  transition: width 0.35s cubic-bezier(0.25, 1, 0.5, 1), right 0.35s cubic-bezier(0.25, 1, 0.5, 1);
  pointer-events: none;
  z-index: -1;
  opacity: 0.95;
}

/* Hojas del Libro (Páginas Interactivas) */
.page-sheet {
  background-color: #ffffff;
  box-shadow: 0 15px 45px rgba(0, 0, 0, 0.38); /* Sombra pronunciada de hoja física */
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  border-radius: 4px; /* Hojas con bordes sutilmente suavizados */
}

/* Degradado interno más pronunciado para simular la curvatura real y el relieve de la hoja */
.page-sheet::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to right, 
    rgba(0, 0, 0, 0.07) 0%, 
    rgba(255, 255, 255, 0.08) 6%, 
    rgba(255, 255, 255, 0) 15%, 
    rgba(0, 0, 0, 0.03) 90%, 
    rgba(0, 0, 0, 0.12) 100%);
  pointer-events: none;
  z-index: 5;
}

/* Canvas del PDF en cada página */
.page-sheet canvas {
  width: 100% !important;
  height: 100% !important;
  object-fit: fill; /* Rellena completamente la hoja */
  background-color: #ffffff;
  display: block;
}

/* Tapa Dura (Hard Cover) - Primera y Última Página (Simulación visual blanda para Revista/Folleto) */
.page-sheet[data-density="hard"] {
  background-color: #ffffff !important;
  border: 1px solid rgba(0, 0, 0, 0.08) !important;
  box-shadow: 0 15px 45px rgba(0, 0, 0, 0.38) !important;
  border-radius: 4px;
}

/* Ocultar el marco dorado y la costura por completo para mantener el estilo limpio */
.page-sheet[data-density="hard"]::before {
  display: none !important;
}

/* Sombras interiores más pronunciadas de la página para simular curvatura hacia el lomo */
.book-page-shadow-left {
  position: absolute;
  top: 0;
  right: 0;
  width: 32%; /* Aumentado a 32% para mayor profundidad visual */
  height: 100%;
  background: linear-gradient(to left, rgba(0,0,0,0.28) 0%, rgba(0,0,0,0) 100%); /* Degradado de sombra aumentado */
  pointer-events: none;
  z-index: 10;
}

.book-page-shadow-right {
  position: absolute;
  top: 0;
  left: 0;
  width: 32%; /* Aumentado a 32% para mayor profundidad visual */
  height: 100%;
  background: linear-gradient(to right, rgba(0,0,0,0.28) 0%, rgba(0,0,0,0) 100%); /* Degradado de sombra aumentado */
  pointer-events: none;
  z-index: 10;
}

/* Sombras en el lomo (spine shadow) ensanchadas y oscurecidas para relieve marcado */
.book-spine-shadow {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 52px; /* Ensanchado de 36px a 52px */
  height: 100%;
  background: linear-gradient(to right, 
    rgba(0,0,0,0) 0%, 
    rgba(0,0,0,0.28) 25%, 
    rgba(0,0,0,0.58) 50%, 
    rgba(0,0,0,0.28) 75%, 
    rgba(0,0,0,0) 100%);
  z-index: 25;
  pointer-events: none;
  mix-blend-mode: multiply;
}

/* Hojas de giro (Flipping Sheets) */
.flip-sheet {
  position: absolute;
  top: 0;
  transform-style: preserve-3d;
  z-index: 20;
  pointer-events: none;
}

.flip-sheet-face {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: white;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.flip-sheet-face canvas {
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.flip-sheet-face.back {
  transform: rotateY(180deg);
}

/* Reglas de impresión seguras */
@media print {
  body, html, .viewer-body, .viewer-container, .flipbook-viewport, .flipbook, .page, .page-sheet {
    display: none !important;
    background: none !important;
  }
}

/* Deshabilitar selección de contenido */
.no-select {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

/* ==========================================================================
   MEDIAS QUERIES Y RESPONSIVIDAD
   ========================================================================== */

@media (max-width: 768px) {
  .stPageFlip::before, .stPageFlip::after {
    display: none !important; /* Desactivar efecto de grosor en página móvil simple */
  }
  .nav-bar {
    padding: 16px 20px;
  }
  .nav-user span {
    display: none;
  }
  .main-dashboard {
    margin: 24px auto;
  }
  .login-card {
    padding: 32px 20px;
  }
  .viewer-controls {
    width: 90%;
    justify-content: space-between;
    bottom: 16px;
  }
  .bg-selector-menu {
    bottom: 72px;
  }
}

/* ==========================================================================
   SELECTOR DE FONDOS Y SOPORTE DE TEMAS PARA EL VISOR
   ========================================================================== */

.bg-selector-menu {
  position: absolute;
  bottom: 84px; /* Justo arriba de la barra de controles */
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  display: flex;
  gap: 12px;
  padding: 12px;
  background: hsla(223, 50%, 8%, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.bg-selector-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.bg-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: var(--transition-fast);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.bg-option:hover {
  transform: translateY(-2px);
}

.bg-preview {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  transition: var(--transition-fast);
}

.bg-option.active .bg-preview {
  border-color: var(--accent-secondary);
  box-shadow: 0 0 10px var(--accent-secondary);
}

.bg-option span {
  font-size: 0.75rem;
  font-family: 'Outfit', sans-serif;
  color: var(--text-secondary);
}

.bg-option.active span {
  color: var(--text-white);
  font-weight: 500;
}

/* Previsualizaciones de Fondo */
.cosmic-preview {
  background: radial-gradient(circle at 10% 10%, hsla(263, 90%, 55%, 0.4) 0%, #080a10 100%);
}
.blur-preview {
  background: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
  filter: blur(2px);
}
.light-preview {
  background: #f1f5f9;
  border-color: rgba(0, 0, 0, 0.1);
}
.neutral-preview {
  background: #1e293b;
}

/* 1. Tema Cósmico (Por Defecto) */
.viewer-body.theme-cosmic {
  background-color: var(--bg-deep-space);
  background-image: 
    radial-gradient(at 10% 10%, hsla(263, 90%, 55%, 0.12) 0px, transparent 45%),
    radial-gradient(at 90% 90%, hsla(190, 95%, 45%, 0.08) 0px, transparent 40%),
    radial-gradient(at 50% 10%, hsla(280, 85%, 60%, 0.05) 0px, transparent 50%);
}

/* 2. Tema Desenfoque Dinámico */
.viewer-body.theme-blur {
  background-color: #05070a;
  background-image: none;
}

/* Capa de desenfoque dinámico */
.bg-blur-container {
  position: fixed;
  top: -10%;
  left: -10%;
  width: 120%;
  height: 120%;
  background-size: cover;
  background-position: center;
  filter: blur(60px) brightness(0.28) saturate(1.3);
  opacity: 0;
  transition: opacity 0.8s ease, background-image 0.8s ease;
  z-index: -2;
  pointer-events: none;
}

.viewer-body.theme-blur .bg-blur-container {
  opacity: 1;
}

/* 3. Tema Claro Minimalista */
.viewer-body.theme-light {
  background-color: #f3f4f6;
  background-image: 
    radial-gradient(at 0% 0%, rgba(255,255,255,0.8) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(229,231,235,0.5) 0px, transparent 50%);
  color: #1f2937;
}

.viewer-body.theme-light .viewer-header {
  background: rgba(243, 244, 246, 0.7);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.viewer-body.theme-light .viewer-title {
  color: #111827;
}

.viewer-body.theme-light .viewer-controls {
  background: rgba(255, 255, 255, 0.65);
  border: 1.5px solid rgba(0, 154, 177, 0.35);
  box-shadow: 
    0 15px 35px rgba(0, 0, 0, 0.06), 
    0 0 20px rgba(0, 154, 177, 0.15), 
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.viewer-body.theme-light .viewer-controls:hover {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(0, 154, 177, 0.7);
  box-shadow: 
    0 20px 45px rgba(0, 0, 0, 0.1), 
    0 0 25px rgba(0, 154, 177, 0.3), 
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.viewer-body.theme-light .btn-ctrl {
  color: #374151;
  background: rgba(255, 255, 255, 0.4);
  border-color: rgba(0, 154, 177, 0.15);
}

.viewer-body.theme-light .btn-ctrl:hover:not(:disabled) {
  background: rgba(0, 154, 177, 0.12);
  border-color: #009ab1;
  color: #009ab1;
  box-shadow: 0 0 12px rgba(0, 154, 177, 0.3);
}

.viewer-body.theme-light .page-info {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 154, 177, 0.25);
  color: #009ab1;
  text-shadow: 0 0 4px rgba(0, 154, 177, 0.2);
}

.viewer-body.theme-light .divider-line {
  background: linear-gradient(180deg, transparent, rgba(0, 154, 177, 0.3), transparent);
}

.viewer-body.theme-light .bg-selector-menu {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
}

.viewer-body.theme-light .bg-option span {
  color: #4b5563;
}

.viewer-body.theme-light .bg-option.active span {
  color: #111827;
}

/* 4. Tema Gris Neutro */
.viewer-body.theme-neutral {
  background-color: #181d28;
  background-image: none;
  color: var(--text-primary);
}

/* Selector de temas del Dashboard premium */
.theme-select {
  background: var(--bg-input-glass);
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 0.8rem;
  outline: none;
  cursor: pointer;
  transition: var(--transition-fast);
  width: 130px;
  font-family: 'Outfit', sans-serif;
}

.theme-select:hover {
  border-color: var(--accent-secondary);
}

.theme-select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px hsla(263, 90%, 65%, 0.25);
}

.theme-select option {
  background-color: var(--bg-deep-space);
  color: var(--text-primary);
  padding: 6px;
}
