
:root {
  --color-texto: #212529;
  --color-texto-secundario: #6c757d;
  --color-tarjeta-fondo: #FFFFFF;
  --color-borde: #dee2e6;
  --color-borde-claro: #eee;
  --color-sutil: rgba(0, 0, 0, 0.04);
  --color-sombra: rgba(0,0,0,0.1);
}

[data-theme="dark"] {
  --color-texto: #E0E0E0;
  --color-texto-secundario: #adb5bd;
  --color-tarjeta-fondo: #1E1E1E;
  --color-borde: #444444;
  --color-borde-claro: #333333;
  --color-sutil: rgba(255, 255, 255, 0.05);
}

.modal-product-detail .modal-content {
    background-color: var(--color-tarjeta-fondo);
    border: 1px solid var(--color-borde);
    border-radius: 12px;
    overflow: hidden;
}
.modal-product-detail .modal-body { padding: 0 0 0 2rem; }
.modal-product-detail .modal-body > .row { margin-top: 0; }

.modal-navigation-header {
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: none;
    gap: 0.75rem;
}
.modal-navigation-header .breadcrumb { margin-bottom: 0; padding-left: 0; background-color: transparent; font-size: clamp(0.7rem, 2.8vw, 0.95rem); }
.modal-header-actions { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.btn-share { background-color: #e8f5ee; color: #249F5F; border: none; border-radius: 20px; padding: 0.4rem 1rem; font-size: 0.9rem; font-weight: 500; display: flex; align-items: center; gap: 0.5rem; transition: background 0.2s; }
.btn-share:hover { background-color: #c8ebd8; color: #1a7a46; }

#productDetailModal .breadcrumb-item a { color: #249F5F !important; text-decoration: none; }
#productDetailModal .breadcrumb-item a:hover { color: rgb(38, 184, 121) !important; }
#productDetailModal .breadcrumb-item + .breadcrumb-item::before { content: ">" !important; color: #249F5F !important; }

.image-gallery-wrapper {
    background-color: var(--color-sutil);
    padding: 2rem;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    height: 580px;
    border-right: 1px solid var(--color-borde-claro);
    position: relative;
    overflow: hidden;
}
.modal-thumbnails-vertical {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex-shrink: 0;
    padding-top: 0.5rem;
    max-height: 100%;
    overflow-y: auto;
    padding-right: 8px;
    position: relative;
    z-index: 2;
}
.modal-thumbnails-vertical img { width: 80px; height: 80px; object-fit: contain; border: 1px solid var(--color-borde-claro); border-radius: 8px; cursor: pointer; background-color: var(--color-tarjeta-fondo); transition: transform 0.2s ease-in-out; }
.modal-thumbnails-vertical img:hover { border-color: var(--color-borde); transform: scale(1.08); }
.modal-thumbnails-vertical img.active { border-color: var(--color-borde); transform: scale(1.1); }

.main-image-container-modal {
    position: relative;
    overflow: hidden;
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-width: 0;
}
#modalMainImage {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.2s ease, object-fit 0.1s step-end;
    transform-origin: center center;
}
.main-image-container-modal.zoomed #modalMainImage { transform: scale(4); }
.image-gallery-wrapper.gallery-zoomed .main-image-container-modal {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1;
}

.custom-cursor {
    position: absolute;
    width: 80px; height: 80px;
    background-image: url("../../img/lupa-mas.19c3163d84b7.svg");
    background-size: contain; background-repeat: no-repeat;
    pointer-events: none;
    display: none;
    z-index: 9999;
    transform: translate(-50%, -50%);
}
.main-image-container-modal.zoomed .custom-cursor {
    background-image: url("../../img/lupa-menos.162ea522cd69.svg");
}
.no-touch-device .main-image-container-modal { cursor: none; }
.no-touch-device .main-image-container-modal:hover .custom-cursor { display: block; }

.modal-product-detail .col-lg-5 {
    min-width: 0;
}
.product-info-column {
    padding: 2rem 2rem 2rem 2.5rem;
    min-width: 0;
}

.review-icon {
    font-size: clamp(0.95rem, 3.6vw, 1.35rem);
    cursor: pointer;
    color: var(--color-texto-secundario);
    transition: color 0.2s ease-in-out;
    position: static;
    box-shadow: none;
    background-color: transparent;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .35rem .25rem;
    border-radius: 8px;
    font-weight: 600;
}
.review-icon:hover { color: #ffc107; }
.review-icon.reviewed i::before {
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    content: "\f005";
    color: #ffc107;
}

#modalProductName {
    font-size: clamp(0.95rem, 3.8vw, 1.3rem);
    font-weight: 600;
    margin-bottom: 0.5rem;
    word-break: break-word;
    overflow-wrap: break-word;
}
#modalProductDetails {
    font-size: clamp(0.76rem, 3vw, 0.9rem);
    color: var(--color-texto-secundario);
    margin-bottom: 1.5rem;
    word-break: break-word;
    overflow-wrap: break-word;
}

#modalPriceContainer { font-weight: 700; text-align: left; }
#modalPriceContainer #modalOriginalPrice { font-size: clamp(0.82rem, 3.2vw, 1.1rem); font-weight: 400; }
#modalPriceContainer #modalCurrentPrice  { font-size: clamp(1.05rem, 4.6vw, 1.5rem); font-weight: 700; }

#modal-button-container { border-top: 1px solid var(--color-sutil); border-bottom: 1px solid var(--color-sutil); padding: 1.5rem 0; margin: 1.5rem 0; }

.guardar-en-lista-btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: none;
    border: none;
    cursor: pointer;
    color: #6b7280;
    font-size: .85rem;
    font-weight: 600;
    padding: .35rem .6rem;
    border-radius: 8px;
    transition: color .2s;
}
.guardar-en-lista-btn:hover { color: #16a34a; background: none; }
.guardar-en-lista-btn.en-lista { color: #16a34a; }
.guardar-en-lista-btn i {
    font-size: clamp(0.95rem, 3.6vw, 1.35rem);
    -webkit-text-stroke: 0.35px currentColor;
}

.btn-add-to-cart-modal {
    background-color: #F7C044;
    color: #333;
    border: none;
    border-radius: 25px;
    font-size: clamp(0.85rem, 3.2vw, 1rem);
    font-weight: 600;
    padding: 12px 15px;
    width: 100%;
    transition: all 0.3s ease;
}
.btn-add-to-cart-modal:hover { background-color: rgba(247, 192, 68, 0.85); transform: translateY(-1px); box-shadow: 0 4px 8px rgba(247, 192, 68, 0.3); }
.btn-add-to-cart-modal:active { transform: translateY(0); background-color: rgba(247, 192, 68, 0.95); }

#modalProductRating { padding: 0; margin: 0; }
#modalProductRating .star-rating-display { letter-spacing: -1px; font-size: clamp(0.68rem, 2.8vw, 0.9rem); }
#modalProductRating .star-rating-display .fas.fa-star { color: #ffc107; }
#modalProductRating .star-rating-display .far.fa-star { color: #dee2e6; }
#modalProductRating .rating-count { font-size: clamp(0.68rem, 2.8vw, 0.9rem); color: #333; font-weight: 600; }

#modalQuantityControls .controls-row { display: flex; justify-content: space-between; align-items: center; width: 100%; }
#modalQuantityControls .in-cart-text { font-size: clamp(0.68rem, 2.6vw, 0.8rem); font-weight: 500; color: var(--color-texto-secundario); margin-bottom: 4px; }
#modalQuantityControls .quantity-display { font-size: clamp(1.05rem, 4.6vw, 1.6rem); font-weight: 700; color: #8B572A; line-height: 1; }
#modalQuantityControls .button-group { display: flex; align-items: center; gap: 0.75rem; }
#modalQuantityControls .btn-quantity { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: clamp(0.95rem, 3.6vw, 1.2rem); font-weight: bold; transition: all 0.2s ease; border: none; }
#modalQuantityControls #modalIncrementButton { background-color: #F7C044; color: #333; }
#modalQuantityControls #modalIncrementButton:hover { opacity: 0.9; }
#modalQuantityControls #modalDecrementButton { background-color: transparent; color: #8B572A; border: 1.5px solid #F7C044; }
#modalQuantityControls #modalDecrementButton:hover { background-color: rgba(247,192,68,0.1); }

.related-products h4 { font-size: clamp(0.85rem, 3.4vw, 1.1rem); font-weight: 600; }
.related-products-carousel-outer-wrapper { background-color: transparent; padding: 20px; border-radius: 8px; }
.related-products-carousel-container { position: relative; }
.carousel-track-wrapper { overflow: hidden; }
.carousel-track { display: flex; flex-wrap: nowrap; gap: 1rem; transition: transform 0.4s ease-in-out; }
.carousel-track > .col { flex: 0 0 calc(20% - 0.8rem); width: calc(20% - 0.8rem); padding: 0; }
.carousel-control { position: absolute; top: 50%; transform: translateY(-50%); z-index: 10; cursor: pointer; display: flex; align-items: center; justify-content: center; background-color: #ffffff; border-radius: 50%; width: 40px; height: 40px; border: 1px solid #dee2e6; box-shadow: 0 1px 3px rgba(0,0,0,0.1); transition: all 0.2s ease; }
.carousel-control.prev { left: -20px; }
.carousel-control.next { right: -20px; }
.carousel-control:hover { background-color: #e9ecef; }
.carousel-control:disabled { opacity: 0.4; cursor: not-allowed; }

.modal-thumbnails-vertical::-webkit-scrollbar { width: 6px; height: 6px; }
.modal-thumbnails-vertical::-webkit-scrollbar-track { background: transparent; }
.modal-thumbnails-vertical::-webkit-scrollbar-thumb { background-color: var(--color-borde); border-radius: 10px; }

#modalGuardarEnLista   { z-index: 1065 !important; }
#modalCrearListaGlobal { z-index: 1075 !important; }
.modal-stack { z-index: 1065 !important; }

.rating-stars { display: inline-flex; flex-direction: row-reverse; justify-content: center; }
.rating-stars input[type="radio"] { display: none; }
.rating-stars label { font-size: 2.5rem; color: #ddd; cursor: pointer; transition: color 0.2s; }
.rating-stars label:hover,
.rating-stars label:hover ~ label { color: #ffc107; }
.rating-stars input[type="radio"]:checked ~ label { color: #ffc107; }

.cert-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.8rem;
    border-radius: 20px;
    font-size: clamp(0.72rem, 2.8vw, 0.82rem);
    font-weight: 600;
}
.cert-badge--verificacion { background: rgba(22, 163, 74, 0.1); color: #16a34a; }
.cert-badge--verificacion.tipo-agroecologico { background: rgba(101, 163, 13, 0.1); color: #65a30d; }
.cert-badge--verificacion.tipo-afc { background: rgba(8, 145, 178, 0.1); color: #0891b2; }
[data-theme="dark"] .cert-badge--verificacion { background: rgba(22, 163, 74, 0.18); }
[data-theme="dark"] .cert-badge--verificacion.tipo-agroecologico { background: rgba(101, 163, 13, 0.18); }
[data-theme="dark"] .cert-badge--verificacion.tipo-afc { background: rgba(8, 145, 178, 0.18); }

.cert-docs-triggers { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 1rem; }
.cert-docs-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.9rem;
    border-radius: 10px;
    border: 1px solid var(--color-borde);
    background: var(--color-tarjeta-fondo);
    color: var(--color-texto);
    font-size: clamp(0.76rem, 2.8vw, 0.85rem);
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.cert-docs-trigger i { color: #dc2626; }
.cert-docs-trigger:hover { border-color: #2563eb; color: #2563eb; background: rgba(37, 99, 235, 0.06); }
.cert-docs-count {
    background: var(--color-sutil);
    color: var(--color-texto-secundario);
    border-radius: 10px;
    padding: 0.05rem 0.55rem;
    font-size: 0.72rem;
    font-weight: 700;
}

.doc-cert-modal-body { max-height: 60vh; overflow-y: auto; }

.docs-list-full { display: flex; flex-direction: column; }
.doc-row-full {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.9rem 0.25rem;
    border-bottom: 1px solid var(--color-borde-claro);
    text-decoration: none;
    color: inherit;
    transition: background 0.15s ease;
}
.doc-row-full:last-child { border-bottom: none; }
.doc-row-full:hover { background: var(--color-sutil); }
.doc-row-full .doc-row-icon { font-size: 1.3rem; width: 1.6rem; text-align: center; flex-shrink: 0; }
.doc-row-full .doc-row-label { font-weight: 500; color: #2563eb; }
.doc-row-full.sin-archivo { cursor: default; }
.doc-row-full.sin-archivo:hover { background: transparent; }
.doc-row-full.sin-archivo .doc-row-label { color: var(--color-texto-secundario); }

.cert-grid-full { display: flex; flex-wrap: wrap; gap: 1.1rem; }
.cert-grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    width: 88px;
    text-decoration: none;
    color: inherit;
}
.cert-grid-thumb {
    width: 72px;
    height: 72px;
    border-radius: 12px;
    background: var(--color-sutil);
    border: 1px solid var(--color-borde-claro);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.7rem;
    color: #16a34a;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.cert-grid-item:hover .cert-grid-thumb { transform: translateY(-2px); box-shadow: 0 4px 10px var(--color-sombra); }
.cert-grid-item.sin-archivo:hover .cert-grid-thumb { transform: none; box-shadow: none; }
.cert-grid-label {
    font-size: 0.72rem;
    text-align: center;
    color: var(--color-texto-secundario);
    word-break: break-word;
    line-height: 1.2;
}

#modalProductOrigin { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.5rem; margin-bottom: 1rem; }
#modalProductOriginLink {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #1d4ed8;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    border: 1.5px solid transparent;
    background: transparent;
    transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}
#modalProductOriginLink:hover { background: #eff6ff; border-color: #bfdbfe; color: #3b82f6; }
#modalProductOriginLink .fa-external-link-alt { font-size: 0.72rem; opacity: 0.8; }

@keyframes pinBounce {
    0%   { transform: translateY(0);    }
    40%  { transform: translateY(-4px); }
    60%  { transform: translateY(0);    }
    100% { transform: translateY(0);    }
}

#modalProductOriginLink .fa-map-marker-alt {
    font-size: 1rem;
    display: inline-block;
    animation: pinBounce 0.9s ease-in-out infinite;
    animation-play-state: paused;
}

#modalProductOriginLink:hover .fa-map-marker-alt {
    animation-play-state: running;
}



@media (max-width: 991.98px) {
    .modal-product-detail .row { flex-direction: column; }
    .modal-product-detail .col-lg-7,
    .modal-product-detail .col-lg-5 { width: 100%; max-width: 100%; flex: 0 0 100%; min-width: 0; }

    .image-gallery-wrapper {
        flex-direction: column;
        height: auto;
        padding: 0.85rem;
        gap: 0.65rem;
        border-right: none;
        border-bottom: 1px solid var(--color-borde-claro);
    }
    .modal-thumbnails-vertical {
        flex-direction: row;
        width: 100%;
        max-height: none;
        overflow-x: auto;
        overflow-y: hidden;
        padding-right: 0;
        padding-top: 0;
        padding-bottom: 4px;
        gap: 0.5rem;
    }
    .modal-thumbnails-vertical img { width: 56px; height: 56px; flex-shrink: 0; }
    .main-image-container-modal {
        width: 100%;
        height: 260px;
        flex-grow: 0;
        flex-shrink: 0;
    }

    .product-info-column { padding: 1rem 1.25rem; }
    .modal-product-detail { margin: 0.5rem; }
    .modal-product-detail .modal-content { border-radius: 12px; }
    #modal-button-container { padding: 0.75rem 0 !important; margin: 0.75rem 0 0.5rem !important; }
    .modal-product-detail .modal-body,
    #productDetailModal .modal-body { padding: 0 0.75rem !important; }
}

@media (max-width: 575.98px) {
    .modal-navigation-header { padding: 0.6rem 0.85rem; align-items: center; }

    .modal-navigation-header .breadcrumb {
        flex-wrap: nowrap;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        max-width: 62vw;
    }
    .modal-navigation-header .breadcrumb::-webkit-scrollbar { display: none; }
    .modal-navigation-header .breadcrumb-item { white-space: nowrap; }

    .btn-share { font-size: 0.9rem; padding: 0.4rem; width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
    .btn-share .share-text { display: none; }

    .image-gallery-wrapper { padding: 0.65rem; gap: 0.5rem; }
    .main-image-container-modal { height: 210px; }
    .modal-thumbnails-vertical img { width: 44px; height: 44px; }
    #modalQuantityControls .btn-quantity { width: 36px; height: 36px; }

    .modal-product-detail .modal-body,
    #productDetailModal .modal-body { padding: 0 0.5rem !important; }

    .product-info-column { padding: 0.75rem 1rem; }

    .cert-docs-trigger { padding: 0.4rem 0.7rem; }
    .cert-grid-item { width: 76px; }
    .cert-grid-thumb { width: 64px; height: 64px; }

    .related-products-carousel-outer-wrapper { padding: 1rem 0; }
    .carousel-track > .col { flex: 0 0 45%; width: 45%; }
    .carousel-control { width: 35px; height: 35px; }
    .carousel-control.prev { left: 5px; }
    .carousel-control.next { right: 5px; }
}

@media (max-width: 991.98px) {
    .related-products.mt-5 { margin-top: 0.5rem !important; }
    .related-products h4 { margin-bottom: 0.75rem !important; }
}

.modal-product-detail {
    max-width: 1100px !important;
    width: 95vw !important;
    margin-top: 5vh !important;
}