/* ./fichas-modal.css */

/* =================================================================
   NIVEL 2: VISTA DE DETALLE (MODAL)
   ================================================================= */

/* CRÍTICO: Asegura Box-Sizing correcto para toda la estructura de la modal */
#modalContentArea.ficha-detalle-modal * {
    box-sizing: border-box; 
}


/* Contenedor principal de la modal (Fondo oscurecido) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7); 
    display: flex;
    justify-content: center; 
    
    /* Mantenemos flex-start solo para alinear el bloque de la modal arriba */
    align-items: flex-start; 
    
    /* 💥 CRÍTICO: Eliminamos el scroll del overlay. Ahora el scroll es interno. */
    overflow-y: hidden; 
    z-index: 1000;
}

/* ---------------------------------------------------- */
/* MODAL DE DETALLE (La "Tarjeta" B-M-F-f-G) */
/* ---------------------------------------------------- */

#modalContentArea.ficha-detalle-modal {
    background-color: transparent; 
    max-width: 95%; 
    width: 600px; 
    padding: 0; 
    display: block; 
}

/* 💥 NUEVO CONTENEDOR PARA MANEJAR SCROLL Y MARGEN SUPERIOR */
.ficha-scroll-wrapper {
    width: 100%;
    
    /* 💥 CRÍTICO: Altura máxima para que quepa en la mayoría de las pantallas */
    max-height: 95vh; 
    
    /* 💥 CRÍTICO: Aisla el scroll a este contenedor (la ficha) */
    overflow-y: auto;
    
    /* CRÍTICO: Margen que asegura que la ficha tiene espacio arriba y abajo */
    margin: 20px 0; 
}

/* Contenedor Final que agrupa Imágenes y Textos */
.ficha-modal-contenedor-principal {
    width: 100%;
    height: auto; /* Debe ser auto para que el scroll wrapper lo mida */
    overflow: visible; 
    
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    
    /* 💥 CRÍTICO: Eliminamos el margen superior/inferior ya que está en .ficha-scroll-wrapper */
    margin: 0 0 0 0; 
    
    display: flex;
    flex-direction: column; 
}


/* ---------------------------------------------------- */
/* CONTENEDOR DE IMÁGENES (1) - Se mantiene igual */
/* ---------------------------------------------------- */
.ficha-contenedor-imagenes {
    width: 96%;
    padding-bottom: 5px; 
    margin: 0.25rem; 
}

.ficha-media-principal {
    width: 100%;
    height: 300px; 
    position: relative;
    overflow: hidden;
    background-color: #f8f8f8;
    cursor: pointer;
    display: flex; 
    justify-content: center;
    align-items: center;
    padding: 0; 
    margin: 0; 
}

.ficha-media-principal img,
.ficha-media-principal video {
    max-width: 100%; 
    max-height: 100%; 
    object-fit: contain; 
    width: auto;
    height: auto;
    position: static; 
}


/* ---------------------------------------------------- */
/* MINIATURAS (2 y 3) - Se mantiene igual */
/* ---------------------------------------------------- */
.ficha-miniaturas-wrapper {
    width: 100%;
    padding: 5px 0 0 0; 
}

.ficha-miniaturas-container {
    display: flex;
    flex-wrap: nowrap; 
    overflow-x: auto; 
    gap: 5px; 
    padding: 0 5px 0 5px; 
}
/* ... (resto de estilos de miniaturas) ... */
.ficha-miniatura {
    flex-shrink: 0; 
    width: 100px; 
    height: 100px; 
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    background-color: #f8f8f8;
    
    display: flex;
    justify-content: center;
    align-items: center;
}

.ficha-miniatura img,
.ficha-miniatura video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; 
}

.ficha-miniatura.active {
    border: 2px solid #3498db; 
}


/* ---------------------------------------------------- */
/* CONTENEDOR DE TEXTOS (2) - Se mantiene igual */
/* ---------------------------------------------------- */
.ficha-contenedor-textos {
    width: 100%;
    padding: 10px 15px 15px 15px; 
    flex-grow: 0; 
    flex-shrink: 0;
    overflow-wrap: break-word; 
    word-break: break-word; 
}

/* ... (resto de estilos de texto y botones) ... */
.ficha-nombre {
    display: block;
    text-align: center; 
    font-size: 1.4rem;
    font-weight: bold;
    margin-bottom: 5px;
    color: #333;
}
.ficha-codigo {
    display: block;
    text-align: center; 
    font-size: 0.9rem; 
    color: #888;
    margin-bottom: 10px;
}
.ficha-precio {
    display: block;
    text-align: center; 
    font-size: 1.6rem;
    font-weight: bold;
    color: var(--color-primary); 
    margin-bottom: 20px;
}
.ficha-descripcion-area p {
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 10px; 
    text-align: left; 
    color: #555;
}
.ficha-contacto-area {
    display: flex;
    flex-direction: row; 
    justify-content: center; 
    gap: 15px; 
    margin-top: 25px;
}
.ficha-contacto-button {
    display: flex; 
    justify-content: center; 
    align-items: center; 
    width: 48px; 
    height: 48px;
    padding: 0; 
    border-radius: 50%; 
    font-size: 1.5rem; 
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); 
    transition: transform 0.2s, box-shadow 0.2s;
}
.whatsapp-button {
    background-color: #25d366;
    color: white;
}
.email-button {
    background-color: #3498db;
    color: white;
}

/* =================================================================
   NIVEL 3: VISOR DE ADJUNTOS
   ================================================================= */
/* ... (estilos de visor de adjuntos) ... */
#modalContentArea.visor-adjunto .visor-flipbook {
    background-color: rgba(0, 0, 0, 0.7); 
    border-radius: 0; 
    width: 98vw;
    height: 98vh;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}
.visualizador-content {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}
.visualizador-content img, .visualizador-content video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

#modalContentArea.visor-flipbook {
    background-color: rgba(0, 0, 0, 0.7); 
    border-radius: 0; 
	width: 95vw;
    height: 95vh;
    max-width: 100%;
    max-height: 100%;
    /* Eliminar padding si es necesario para que el flipbook use el 100% real */
    padding: 0;}

/* Contenedor principal del flipbook */
#flipbook {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: stretch;
  gap: 10px;
  padding: 5px;
  background-color: rgba(245, 245, 245, 0.5); 
/*  background-color: #f0f0f0; */
  min-height: 100vh;
  box-sizing: border-box;
}

/* Cada página del flipbook */
.page {
  width: 100%;
  height: 100%;
  background: white;
  padding: 0;
  box-sizing: border-box;
  overflow-y: auto;
}

/* Estilo para la tapa y contratapa */
.page:first-child,
.page:last-child {
  background-color: teal;
  color: white;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Estilo para imágenes dentro de artículos */
.page img {
  max-width: 100%;
  height: auto;
  margin: 10px 0;
}

/* Estilo para títulos */
.page h1, .page h2, .page h3 {
  margin: 0.5rem 0;
}

/* Estilo para índice */
.indice ul {
  list-style: none;
  padding: 0;
}
.indice li {
  margin: 5px 0;
  font-weight: bold;
}

/* Responsive para pantallas pequeñas */
@media screen and (max-width: 768px) {
  #flipbook {
    flex-direction: column;
    align-items: center;
  }
  .page {
    width: 90vw;
    height: auto;
  }
}

.visualizador-content button {
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border: none;
  font-size: 2em;
  padding: 0.2em 0.5em;
  cursor: pointer;
  border-radius: 5px;
}
.visualizador-content button:hover {
  background: rgba(0, 0, 0, 0.8);
}
