/* ====== MODAL PRODUCTO FULL HEIGHT + PADDING VERTICAL ====== */
#productModal .modal-dialog {
    width: 80vw;              /* 80% del ancho de la ventana */
    max-width: 900px;
    margin: 0 auto;           /* centrado horizontal */
    height: 100vh;            /* ocupa todo el alto de la pantalla */
    display: flex;
    align-items: center;      /* necesario para que funcione el padding interno */
    padding-top: 24px;        /* padding superior */
    padding-bottom: 24px;     /* padding inferior */
    box-sizing: border-box;   /* incluye padding en el alto total */
}

/* centrado vertical del contenido */
#productModal .modal-dialog.modal-dialog-centered {
    min-height: 100vh;
    display: flex;
    align-items: center;
}

#productModal .modal-content {
    width: 100%;
    height: 100%;
    border-radius: 15px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* HEADER / BODY / FOOTER */

#productModal .modal-header {
    background-color: #7339FF;
    color: #fff;
    padding: 12px 16px;
    border-bottom: none;
}

#productModal .modal-body {
    padding: 12px;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow-y: auto;
    gap: 12px;
}

#productModal .modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    gap: 10px;
}

#productModal .modal-footer button {
    flex: 1;
}

/* IMAGEN + DESCRIPCIÓN (CARAS DEL CUBO) */

.imagen-producto-descripcion {
    position: relative; /* necesario para posicionar el pseudo-elemento */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 8px;
    cursor: zoom-in;
}

.imagen-producto-descripcion img {
    max-width: 200px;
    width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
    transition: transform 220ms ease, filter 220ms ease;
    will-change: transform;
}

/* icono circular oculto por defecto */
.imagen-producto-descripcion::after {
    content: "+"; /* símbolo de zoom positivo */
    position: absolute;
    top: 10px;
    right: 10px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(90deg, #7339FF, #4C6FAF);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 6px 16px rgba(0,0,0,0.35);
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 180ms ease, transform 180ms ease;
    pointer-events: none; /* no bloquea clicks sobre la imagen */
    z-index: 30;
}

/* al pasar el mouse mostrar icono y hacer un ligero zoom a la imagen */
.imagen-producto-descripcion:hover::after {
    opacity: 1;
    transform: scale(1);
}

.imagen-producto-descripcion:hover img {
    transform: scale(1.03);
    filter: saturate(1.05);
}
#productModal tr {
    border-bottom: 2px solid #000 !important;
    padding: 10px;
}


/* Contenedor del cubo: usa la mayor parte del alto disponible */
#cubeContainer.cube-container {
    width: 100%;
    max-width: 600px;
    height: 60vh;
    max-height: 60vh;
    margin: 0 auto;
}

/* CUBO 3D */

.cube {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transform: rotateY(0deg);
    transition: transform 0.25s ease-in-out;
}

.cube-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.cube-face.front {
    display: none; /* FRONT oculto al inicio, se mostrará por JS */
    backface-visibility: hidden;
    background: #fff;
}
.cube-face.front {
    position: relative;    /* necesario para posicionar el pseudo-elemento */
    overflow: hidden;
    cursor: zoom-out;      /* indica acción de "zoom negativo" */
}

/* Asegurar que la imagen no desborde y mantenga proporción */
.cube-face.front img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    transition: transform 200ms ease, filter 200ms ease;
}

/* Icono circular oculto por defecto: signo "−" dentro de un círculo (lupa simbólica) */
.cube-face.front::after {
    content: "−";
    position: absolute;
    top: 10px;
    right: 10px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(90deg, rgba(0,0,0,0.7), rgba(0,0,0,0.45));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 6px 16px rgba(0,0,0,0.35);
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 180ms ease, transform 180ms ease;
    pointer-events: none; /* no bloquea clicks sobre la imagen */
    z-index: 40;
}

/* Al pasar el mouse mostrar el icono y aplicar leve efecto visual a la imagen */
.cube-face.front:hover::after {
    opacity: 1;
    transform: scale(1);
}
.cube-face.front:hover img {
    transform: scale(0.99);
    filter: saturate(0.98);
}

/* En dispositivos táctiles (sin hover) mostrar siempre el icono para indicar acción */
@media (hover: none) {
    .cube-face.front::after {
        opacity: 1;
        transform: scale(1);
    }

    .imagen-producto-descripcion::after {
        opacity: 1;
        transform: scale(1);
    }
}

.cube-face.back {
    background: #f8f9fa;
    color: black;
    padding: 20px;
    box-sizing: border-box;
    display: block;               /* permitir que .description use flex sizing */
    flex-direction: column;
    backface-visibility: hidden;
    overflow: hidden;            /* el scroll debe ocurrir dentro de .description */
    width: 100%;
    height: 100%;
    position: relative;
    overflow: auto;              /* scroll interno si el contenido excede */
}

/* Organización vertical: imagen (fila 1) + descripción (fila 2) */
.cube-face.back .description {
    width: 100%;
    box-sizing: border-box;
    /* dejar que el flex container determine el alto */
    flex: 1 1 auto;              /* ocupa el espacio disponible */
    min-height: 0;               /* CRUCIAL: permite que overflow funcione dentro de flex */
    overflow: auto;              /* scroll interno si el contenido excede */
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0;                  /* el padding ya está en .cube-face.back */
    padding-right: 10px;
}

.cube-face.back .description p{
    width: 100%;
    text-align: justify;
}
.cube-face.back .description table {
    width: 100%;
}

.cube-face.back .description table tr{
    padding-bottom: 2px;
}
.cube-face.back .description table td{
    padding-left: 2px;
}

.cube-face.front img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 10px;
}

/* ====== RESPONSIVE ====== */
@media (max-width: 768px) {
    #productModal .modal-dialog {
        width: 95vw;
        padding-top: 16px;
        padding-bottom: 16px;
    }

    #productModal .modal-content {
        border-radius: 0.75rem;
        height: auto; /* Permitir que el contenido determine la altura */
    }

    #cubeContainer.cube-container {
        max-width: 100%;
        height: 55vh;
    }

    #productModal .modal-footer {
        flex-direction: column;
    }

    #productModal .modal-footer button {
        width: 100%;
    }
}