/* Ficha de producto: diseño móvil (≤767px). No afecta a tablet ni escritorio.
   Se carga después de producto-referencia.css. */

/* Elementos que solo existen en móvil: ocultos por defecto */
.pdp-m-entrega,
.pdp-m-dots,
.pdp-m-track,
.pdp-m-share,
.rating-empty-mobile,
.no-reviews-cta { display: none; }

/* "Ahorras S/ X por <etiqueta>": en escritorio va bajo el precio, pegado a él */
.product-details .pdp-m-ahorro { margin: -8px 0 0; font: 600 14px/1.3 'Outfit', sans-serif; color: #363993; }
.product-details .pdp-m-ahorro + .product-urgency-container { margin-top: -6px; }

/* Escritorio: el título ahora va dentro de un contenedor; se conserva su separación con la valoración */
.product-details .pdp-m-titlerow + .rating { margin-top: -5px; }

/* Aviso breve ("Enlace copiado") del botón de compartir */
.pdp-m-toast {
    position: fixed; left: 50%; bottom: 24px; z-index: 1200; transform: translateX(-50%);
    padding: 10px 16px; background: #1b1b1b; color: #fff; font: 600 13px 'Outfit', sans-serif; white-space: nowrap;
}

@media (max-width: 767px) {
    /* ---------- Estructura: el contenido se reordena según el diseño ---------- */
    .product-detail-container { width: calc(100% - 32px); padding: 0; }
    /* Se retira la ruta "Inicio › Categoría" que iba encima de la foto (el marcado se conserva para buscadores) */
    .product-detail-container .bread-links { display: none; }

    .product-info-grid { display: flex; flex-direction: column; align-items: stretch; gap: 0; margin: 0; }
    .product-info-grid .product-details,
    .product-info-grid .product-details .add-to-cart-form { display: contents; }
    .product-info-grid .product-details::before { display: none; }

    /* Orden de los bloques (hijos directos del contenedor al usar display: contents) */
    .product-info-grid .product-image-gallery { order: 1; }
    .product-info-grid .product-details .pdp-m-titlerow { order: 2; }
    .product-info-grid .product-details .rating { order: 3; }
    .product-info-grid .product-details .price { order: 4; }
    .product-info-grid .product-details .pdp-m-ahorro { order: 5; }
    .product-info-grid .product-details .product-urgency-container { order: 6; }
    .product-info-grid .product-details .product-variants { order: 7; }
    .product-info-grid .product-details .purchase-row { order: 8; }
    .product-info-grid .product-details .buy-now-btn { order: 9; }
    .product-info-grid .product-details .product-help-whatsapp { order: 10; }
    .product-info-grid .product-details .pdp-m-entrega { order: 11; }
    .product-info-grid .product-details .product-payment-methods { order: 12; }
    .product-info-grid .product-details .product-summary-benefits { display: none; }
    .product-info-grid .product-short-description { order: 13; }

    /* ---------- Galería ---------- */
    .product-info-grid .product-image-gallery { --pdp-dots-h: 18px; position: relative; gap: 0; align-items: stretch; }
    .product-info-grid .product-image-gallery .image-zoom-container {
        height: 279px; max-width: none; padding: 0; border: 0;
        border-top: 0; border-bottom: 1px solid #e6eaee; border-radius: 0;
    }
    .product-info-grid .product-image-gallery .image-wrapper { display: flex; align-items: center; justify-content: center; }

    /* Carrusel: las imágenes van en fila, una empuja a la otra y se ajustan solas al soltar el dedo */
    /* Área cuadrada: las fotos (casi todas cuadradas) llenan toda la diapositiva y quedan pegadas, sin espacio entre ellas */
    .product-info-grid .pdp-m-carousel .image-zoom-container { touch-action: auto; height: auto; aspect-ratio: 1 / 1; border-bottom: 0; }
    .product-info-grid .pdp-m-carousel .image-wrapper { display: none; }
    .pdp-m-track {
        position: absolute; inset: 0; display: flex; overflow-x: auto; overflow-y: hidden;
        scroll-snap-type: x mandatory; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; scrollbar-width: none;
    }
    .pdp-m-track::-webkit-scrollbar { display: none; }
    .pdp-m-slide {
        flex: 0 0 100%; min-width: 0; height: 100%; display: flex; align-items: center; justify-content: center;
        scroll-snap-align: center; scroll-snap-stop: always;
    }
    .pdp-m-slide img {
        display: block; width: 100%; height: 100%; object-fit: contain;
        user-select: none; -webkit-user-select: none; -webkit-user-drag: none;
    }
    .product-info-grid .product-image-gallery .zoomable-image { display: block; margin: 0 auto; max-height: 232px; }
    .product-info-grid .product-image-gallery .thumbnail-images { display: none; }
    /* La etiqueta sobre la foto se retira en móvil: su texto va junto a "Ahorras" */
    .product-info-grid .product-detail-badges { display: none; }
    /* Compartir: icono pequeño a la derecha del título, centrado en su línea */
    .product-info-grid .pdp-m-share {
        position: relative; flex: none; display: flex; align-items: center; justify-content: center;
        width: 28px; height: 28px; padding: 0; border: 0; border-radius: 0; background: #d9dee3; color: #1b1b1b; cursor: pointer; isolation: isolate;
        clip-path: polygon(0 0, calc(100% - 7px) 0, 100% 7px, 100% 100%, 7px 100%, 0 calc(100% - 7px));
    }
    /* Borde de 1px: capa interior blanca con el mismo recorte */
    .product-info-grid .pdp-m-share::before {
        content: ''; position: absolute; inset: 1px; z-index: -1; background: #fff;
        clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 6px 100%, 0 calc(100% - 6px));
    }
    .product-info-grid .pdp-m-share:focus-visible { outline: 2px solid #363993; outline-offset: 2px; }
    /* Indicadores: franja propia justo debajo de la foto (no se superponen); la imagen termina donde empiezan */
    .pdp-m-dots {
        box-sizing: border-box; height: var(--pdp-dots-h); border-bottom: 1px solid #e6eaee; flex: none;
        display: flex; align-items: center; justify-content: center; gap: 6px; pointer-events: none;
    }
    .pdp-m-dots span { width: 6px; height: 6px; border-radius: 3px; background: #c4cbd2; transition: width .2s ease, background-color .2s ease; }
    .pdp-m-dots span.is-active { width: 20px; background: #2ac1db; }

    /* ---------- Título, valoración y precio ---------- */
    .product-info-grid .product-details .pdp-m-titlerow { display: flex; align-items: center; gap: 10px; margin: 12px 0 0; }
    .product-info-grid .product-details .pdp-m-titlerow h1 { flex: 1; min-width: 0; margin: 0; font: 600 16px/1.25 'Outfit', sans-serif; color: #1b1b1b; }
    .product-info-grid .product-details .rating { margin: 1px 0 0; line-height: 1.2; font-size: 12px; color: #5a6270; }
    /* Las estrellas nunca se parten; si el texto no cabe, baja completo a la siguiente línea */
    .product-info-grid .product-details .rating-link { flex-wrap: wrap; gap: 2px 6px; font-size: 12px; }
    .product-info-grid .product-details .stars { flex: none; margin: 0; font-size: 14px; letter-spacing: 2px; white-space: nowrap; }
    .product-info-grid .product-details .rating-link > span:not(.stars) { white-space: nowrap; }
    .product-info-grid .product-details .rating-count,
    .product-info-grid .product-details .rating-average { font-size: 12px; color: #5a6270; }
    .product-info-grid .product-details .rating-count--zero { display: none; }
    .rating-empty-mobile { display: inline; font-size: clamp(11px, 3.3vw, 12px); color: #5a6270; }
    /* En pantallas angostas se deja solo "Aún sin reseñas" para que quepa en una línea con las estrellas */
    @media (max-width: 380px) { .rating-empty-cta { display: none; } }

    .product-info-grid .product-details .price { margin: 5px 0 0; gap: 10px; flex-wrap: nowrap; align-items: center; }
    .product-info-grid .product-details .price .current-price { order: 1; font: 600 32px/1 'Outfit', sans-serif; color: #1b1b1b; }
    .product-info-grid .product-details .price .discount {
        order: 2; align-self: center; padding: 4px 10px; font: 700 13px/1.2 'Outfit', sans-serif; background: #363993; color: #fff;
        clip-path: polygon(6px 0,100% 0,100% calc(100% - 6px),calc(100% - 6px) 100%,0 100%,0 6px);
    }
    .product-info-grid .product-details .price .old-price { order: 3; font: 400 14px 'Outfit', sans-serif; color: #5a6270; }
    .product-info-grid .product-details .pdp-m-ahorro { display: block; margin: 4px 0 0; font-size: 12px; line-height: 1.2; font-weight: 600; color: #363993; }
    .product-info-grid .product-details .product-urgency-container { margin: 1px 0 0; }

    /* ---------- Variantes y compra ---------- */
    .product-info-grid .product-details .product-variants { margin: 9px 0 0; }
    .product-info-grid .product-details .purchase-row { margin: 10px 0 0; gap: 10px; flex-wrap: nowrap; }
    .product-info-grid .product-details .quantity-selector {
        flex: 0 0 108px; width: 108px; height: 52px; padding: 0; background: #f3f6f8; border: 1px solid #dde3e8;
    }
    .product-info-grid .product-details .quantity-selector button { flex: 0 0 36px; width: 36px; height: 50px; }
    .product-info-grid .product-details .qty-input { height: 50px; font: 600 16px 'Outfit', sans-serif; }
    .product-info-grid .product-details .add-to-cart-btn { height: 52px; }
    .product-info-grid .product-details .add-to-cart-btn .btn-text { font-size: clamp(12px, 3.6vw, 14px); font-weight: 600; }
    .product-info-grid .product-details .buy-now-btn { margin: 10px 0 0; min-height: 48px; height: 48px; font: 600 15px 'Outfit', sans-serif; }
    .product-info-grid .product-details .product-help-whatsapp { margin: 14px 0 0; padding: 0; }

    /* ---------- Entrega y garantía ---------- */
    .product-info-grid .pdp-m-entrega { display: block; margin: 12px 0 0; border-top: 1px solid #e6eaee; }
    .pdp-m-entrega > div { display: flex; align-items: center; gap: 10px; min-height: 34px; border-bottom: 1px solid #e6eaee; font-size: 13px; color: #1b1b1b; }
    .pdp-m-entrega svg { flex: none; color: #363993; }
    .pdp-m-entrega b { font-weight: 600; }

    /* Medios de pago: se conserva el bloque actual, solo se separa del anterior */
    .product-info-grid .product-details .product-payment-methods { margin: 16px 0 0; }

    /* ---------- Descripción ---------- */
    #descripcion, #especificaciones, #reviews-section { scroll-margin-top: 72px; }
    .product-info-grid .product-short-description {
        height: auto; min-height: 0; gap: 0; padding: 24px 0 0; border: 0; border-radius: 0; background: none; clip-path: none;
    }
    .product-info-grid .product-short-description h2 { margin: 0; font: 700 18px/1.2 'Orbitron', sans-serif; letter-spacing: .02em; text-transform: uppercase; }
    .product-info-grid .product-short-description .product-description-content {
        margin: 12px 0 0 !important; font-size: 15px; line-height: 1.55 !important; color: #2b2f36 !important;
    }
    .product-info-grid .product-short-description .info-boxes { display: none; }

    /* ---------- Especificaciones ---------- */
    .product-detail-container .collapsible-section {
        margin: 28px 0 0; border: 0; border-radius: 0; background: none; clip-path: none; overflow: visible;
    }
    .product-detail-container .collapsible-header {
        padding: 0; background: none; cursor: default; pointer-events: none;
        font: 700 18px/1.2 'Orbitron', sans-serif; letter-spacing: .02em; text-transform: uppercase;
    }
    .product-detail-container .collapsible-header .arrow { display: none; }
    .product-detail-container .collapsible-content { padding: 12px 0 0; }
    .product-detail-container .collapsible-section.partially-visible .collapsible-content { max-height: 262px; padding-bottom: 70px; }
    .product-detail-container .specs-table { margin: 0; font-size: 14px; border-top: 1px solid #e6eaee; }
    .product-detail-container .specs-table tr { border-bottom: 0; background: none; }
    .product-detail-container .specs-table tr:nth-child(odd) { background: #f3f6f8; }
    .product-detail-container .specs-table tr:nth-child(even) { background: none; }
    .product-detail-container .specs-table tr:last-child { border-bottom: 1px solid #e6eaee; }
    .product-detail-container .specs-table td { height: auto; padding: 12px 8px; }
    .product-detail-container .specs-table td.spec-label { width: 132px; border-right: 0; font-weight: 600; color: #1b1b1b; }
    .product-detail-container .specs-table td.spec-value { color: #1b1b1b; }
    /* Botón estilo ByteBox: esquinas cortadas en diagonal; el borde de 1px se logra con un fondo interior */
    .product-detail-container .view-specs-toggle {
        height: 44px; min-height: 44px; padding: 0 28px; border: 0; background: #1b1b1b; color: #1b1b1b;
        font: 700 14px 'Outfit', sans-serif; letter-spacing: .04em; text-transform: uppercase; isolation: isolate;
        clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
    }
    .product-detail-container .view-specs-toggle::before {
        content: ''; position: absolute; inset: 1px; z-index: -1; background: #fff;
        clip-path: polygon(0 0, calc(100% - 11px) 0, 100% 11px, 100% 100%, 11px 100%, 0 calc(100% - 11px));
    }
    .product-detail-container .view-specs-toggle:hover { background: #1b1b1b; }
    .product-detail-container .view-specs-toggle:hover::before { background: #2ac1db; }
    .product-detail-container .view-specs-toggle:focus-visible { outline: 2px solid #363993; outline-offset: 3px; }

    /* ---------- Productos relacionados ---------- */
    .product-detail-container .related-products { margin-top: 32px; }
    .product-detail-container .related-products > h2,
    .product-detail-container .reviews-main-title { margin: 0 0 14px; font: 700 18px/1.2 'Orbitron', sans-serif; letter-spacing: .02em; }
    .product-detail-container .related-products > h2::before,
    .product-detail-container .reviews-main-title::before { display: none; }

    /* ---------- Opiniones ---------- */
    .product-detail-container .reviews-container { margin-top: 32px; padding: 0 0 40px; border: 0; }
    .product-detail-container .reviews-summary { padding: 0; gap: 20px; clip-path: none; }
    .product-detail-container .individual-reviews { grid-template-columns: 1fr; gap: 12px; }
    .product-detail-container .review-item { clip-path: none; padding: 16px; }
    .product-detail-container .review-item:hover { transform: none; box-shadow: none; }
    .no-reviews-box {
        display: flex; flex-direction: column; align-items: flex-start; gap: 12px;
        padding: 20px 16px; border: 1px solid #dde3e8; background: #f3f6f8;
    }
    .no-reviews-box .no-reviews-message { margin: 0; font-size: 15px; line-height: 1.4; color: #2b2f36; }
    .no-reviews-cta {
        display: inline-flex; align-items: center; height: 44px; padding: 0 20px; background: #1b1b1b; color: #fff;
        font: 600 14px 'Outfit', sans-serif; text-decoration: none;
        clip-path: polygon(8px 0,100% 0,100% calc(100% - 8px),calc(100% - 8px) 100%,0 100%,0 8px);
    }
}
