/* ==========================================================================
    PRODUCT DETAILS STYLESHEET
    - Refactored using a BEM-like methodology.
    - Classes are now more specific, readable, and modular.
    - Leverages variables from universal.css for consistency.
    ========================================================================== */

/* --------------------------------------------------------------------------
    #PRODUCT DETAILS LAYOUT
    -------------------------------------------------------------------------- */
.product-details {
    --spacing-section: 24px;
    --radius-section: 16px;
    --radius-element: 8px;
    --thumb-size: 80px;
}

.product-details__main-content {
    display: flex;
    justify-content: space-between;
    width: 100%;
    gap: var(--spacing-section);   
    margin-top: 1.5rem;
}

/* --------------------------------------------------------------------------
    #GALLERY COMPONENT
    -------------------------------------------------------------------------- */
.product-details__gallery {
    width: 60%;   
    display: flex;
    justify-content: center;   
}

.product-details__gallery-main-view {
    width: 80%;   
    display: flex;
    align-items: flex-start;   
    justify-content: center;   
    position: relative;   
}

.product-details__gallery-image {
    width: 100%;
    height: auto;   
    max-height: none;   
    object-fit: contain;   
    border-radius: var(--radius-section);
    display: block;   
}

#daeViewerContainer {
    width: 100%;
    aspect-ratio: 1 / 1;
    min-height: 300px;
    max-height: 75vh;
    border-radius: var(--radius-section);
    overflow: hidden;   
    position: relative;   
}
#daeViewerContainer canvas {
    display: block;   
    width: 100% !important;   
    height: 100% !important;   
}

.product-details__gallery-thumbs {
    width: 20%;
    display: flex;
    flex-direction: column;
    gap: calc(var(--spacing-section) / 2);   
    align-items: center;
    padding-top: 0;   
}

/* Gallery Thumb Element */
.gallery-thumb {
    width: var(--thumb-size);
    height: var(--thumb-size);
    overflow: hidden;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;  
    cursor: pointer;
    transition: border-color 0.2s ease;
}
.gallery-thumb:hover {
    box-shadow: 4px 4px 10px rgb(0 0 0 / 35%);   
}
.gallery-thumb--active {
    border: 3px solid transparent; box-shadow: 4px 4px 10px rgb(0 0 0 / 35%); outline: 1px solid var(--color-btn-modern-orange-bg);
}
.gallery-thumb__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.gallery-thumb--dae {
    background-color: #f0f0f0;   
    border: 1px solid var(--color-gray-light);
    flex-direction: column;   
    text-align: center;
    padding: 5px;
    font-size: 0.8em;
    line-height: 1.2;
}
.gallery-thumb--dae .dae-thumb-icon {
    width: 24px; /* Use width/height for SVG consistency */
    /* height: 16px; */
    margin-bottom: 4px;
}
.gallery-thumb--dae .dae-thumb-text {
    font-size: 0.9em;   
    color: var(--color-black);
}

/* --------------------------------------------------------------------------
    #PRODUCT INFO COMPONENT
    -------------------------------------------------------------------------- */
.product-details__info {
    width: 40%;   
    display: flex;
    flex-direction: column;
    gap: var(--spacing-unit); /* Standardized gap */
    padding-left: var(--spacing-section);   
    justify-content: space-between;
}
.product-details__title {
    font-weight: 200;   
    margin-bottom: var(--spacing-unit);
}
#customizeProductBtn {   
    margin-bottom: 1rem;   
}
      /* Fix for hover transform conflict */
      .viewer-controls.btn--modern:hover {
          transform: translateX(-50%) translateY(-1px);
      }
      /* Style for the new customize button in the combined view */
      #customizeFirstModuleBtn {
          position: absolute;
          bottom: 20px;
          left: 50%;
          transform: translateX(-50%);
          z-index: 10;
          max-width: 60%;
      }
.product-details__price-container {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem; /* NUEVO: Espacio entre elementos de precio */
    margin-bottom: 0;
    font-size: 1.8rem;
    min-height: 2.5rem; /* Evita que el layout salte durante la carga */
}
.product-details__price {
    font-size: 24px;
    margin: 0;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    color: var(--color-black);
    font-weight: 300;
}

/* INICIO: NUEVOS ESTILOS PARA PRECIO DE OFERTA */
.product-details__price--original {
    font-size: 18px;
    color: var(--color-gray-medium);
    text-decoration: line-through;
    font-weight: 300;
}

.product-details__price--promo {
    /* color: var(--color-primary); */ /* Un color que resalte la oferta */
    /* font-weight: 600; */
}

.product-details__offer-tag {
    background-color: #ff5304;
    color: var(--color-white);
    padding: 2px 10px;
    border-radius: 4PX;
    font-size: 11PX;
    font-weight: 500;
    text-transform: uppercase;
    /* line-height: 1; */
    /* display: inline-block; */
    /* vertical-align: baseline; */
    MIN-WIDTH: 80PX;
    /* TEXT-ALIGN: center; */
    MIN-HEIGHT: 22PX;
    DISPLAY: FLEX;
    ALIGN-ITEMS: center;
    JUSTIFY-CONTENT: center;
}
/* FIN: NUEVOS ESTILOS PARA PRECIO DE OFERTA */


/* --------------------------------------------------------------------------
    #LOADING STATE FOR PRICE OPTIMIZATION
    -------------------------------------------------------------------------- */
.product-details__price-container::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 1.75rem; /* TamaÃ±o del Ã­cono de carga */
    height: 1.75rem;
    border: 3px solid var(--color-gray-light);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spinner-border 0.75s linear infinite;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.product-details__info.is-loading .product-details__price-container::before {
    opacity: 1;
    visibility: visible;
}

.product-details__info.is-loading .product-details__price,
.product-details__info.is-loading .product-details__price--original,
.product-details__info.is-loading .product-details__price--promo,
.product-details__info.is-loading .product-details__offer-tag {
    opacity: 0;
    visibility: hidden;
}

.product-details__info.is-loading .purchase-form__actions {
    opacity: 0.6;
    pointer-events: none;
}

/* --------------------------------------------------------------------------
    #VIEWER FLOATING CONTROLS
    -------------------------------------------------------------------------- */
.viewer-controls {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;   
    box-sizing: border-box;
}
.viewer-controls--top {
    top: 15px;
    width: 90%;
    background-color: var(--color-white);
    padding: 10px 15px;
    border-radius: var(--radius-lg);
    box-shadow: 4px 4px 12px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
}
.viewer-controls__title {
    text-align: center;
}
.viewer-controls__measure-labels,  
.viewer-controls__measure-inputs {
    display: flex;
    justify-content: space-around;
    align-items: center;
    width: 100%;
}
.viewer-controls__measure-labels h6 {
    flex: 1;
    text-align: center;
    padding: 0 var(--spacing-unit);
}
.measure-input-group {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-unit);
    border-radius: var(--radius-sm);
    flex: 1;
    margin: 0 var(--spacing-unit);   
    gap: var(--spacing-unit);
    cursor: pointer;
}
.measure-input-group__input {
    border: none;
    outline: none;
    background-color: transparent;
    width: 50px;   
    text-align: right;
    font-family: var(--font-primary);
    font-size: 0.85rem;
    color: var(--color-black);
    font-weight: 300;
}
.measure-input-group__input::placeholder {
    color: var(--color-black);
    font-size: 0.85rem;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
}
.measure-input-group__unit {   
    font-size: 0.85rem;
    color: var(--color-gray-dark);
}
.measure-input-group__icon {
    width: 14px;
    height: 14px;
    opacity: 0.7;
    display: inline-block;
}


.viewer-controls--bottom {
    bottom: 36px;
    width: 60%;  
}

/* Module Floaters */
.viewer-module-floater-container {
    position: absolute; top: 50%; right: 1rem;
    transform: translateY(-50%); z-index: 10;
    display: none; flex-direction: column; gap: 1rem;
}

.viewer-module-floater {
    width: clamp(56px, 6vw, 64px); height: clamp(56px, 6vw, 64px);
    background-color: var(--color-white); border-radius: 0.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15); display: flex;
    flex-direction: column; align-items: center; justify-content: center;
    padding: 0.25rem; gap: 0.25rem; box-sizing: border-box;
    transition: transform 0.2s ease; cursor: pointer;
    color: var(--color-primary);

}
.viewer-module-floater--combined {
      color: var(--color-black);
}
.viewer-module-floater:hover { transform: scale(1.05); }
.viewer-module-floater.active { border: 1px solid var(--color-primary); }
.viewer-module-floater__icon {
    width: 45%; height: 45%;
    mask-repeat: no-repeat; mask-position: center; mask-size: contain;
    -webkit-mask-repeat: no-repeat; -webkit-mask-position: center; -webkit-mask-size: contain;
}
.viewer-module-floater__text {
 font-size: clamp(0.6rem, 1.5vw, 0.75rem);
line-height: 1.1; text-align: center; margin: 0;
}


/* --------------------------------------------------------------------------
    #CREATOR & PURCHASE COMPONENTS
    -------------------------------------------------------------------------- */
.creator-card { margin-bottom: 12px; gap: 0.5rem; flex-direction: column; display: flex; }
.creator-card__info { display: flex; align-items: center; gap: 0.5rem; }
.creator-card__image { width: 70px; height: 70px; border-radius: 50%; object-fit: cover; }
.creator-card__header { display: flex; align-items: center; gap: 8px; }
.creator-card__badge { width:16px; height:16px; vertical-align:middle; }

.purchase-form { display: flex; flex-direction: column; gap: 0.75rem; }
.purchase-form__quantity { display: flex; flex-direction: column; gap: 12px; }
.purchase-form__actions { display: flex; flex-direction: column; gap: 0.5rem; transition: opacity 0.3s ease; }
.purchase-form__actions .btn { min-height: 3rem; font-size: 14px; font-weight: 300;}
.purchase-form__meta { display: flex; align-items: center; gap: 0.5rem; }
.purchase-form__meta-icon { max-width: 20px; }

.quantity-selector {
      max-width: 240px; padding: 0.5rem; min-height: 3rem;
      display: flex; align-items: center; justify-content: space-between;
      border: 1px solid black; border-radius: 0.5rem;
}
.quantity-selector__button {
      border: none; cursor: pointer; height: 100%; width: 30px;
      background-color: transparent; font-size: 1.2rem; color: var(--color-black);
}
.quantity-selector__input {
      text-align: center; border: none; outline: none; width: 50px;
      font-size: 1rem; font-family: var(--font-primary);
}

/* --------------------------------------------------------------------------
    #TABS COMPONENT
    -------------------------------------------------------------------------- */
.tabs-component { width: 100%; margin: 20px 0; }
.tabs-component__nav { display: flex; justify-content: center; gap: 10px; border-bottom: 1px solid var(--color-gray-light); margin-bottom: 15px; }

.tabs-component__btn {
      background-color: transparent;
      border: none;
      border-bottom: 2px solid transparent;
      cursor: pointer;
      padding: 10px 15px;
      position: relative;
      color: var(--color-black);
      font-family: var(--font-primary);
      font-weight: 400;
      transition: color var(--transition-base), border-color var(--transition-base);
      margin-bottom: -1px;
}
.tabs-component__btn:hover { color: var(--color-primary); }
.tabs-component__btn--active { color: var(--color-primary); border-bottom-color: var(--color-primary); font-weight: 500; }

.tabs-component__panel { display: none; padding: 20px 64px; opacity: 0; transition: opacity var(--transition-base); text-align: justify; }
.tabs-component__panel p {font-size: 14px;text-align: justify;}
.tabs-component__panel--active { display: block; opacity: 1; }

/* --------------------------------------------------------------------------
    #CONTENT WITHIN TABS & DYNAMIC STYLES
    -------------------------------------------------------------------------- */
.specs-list h5 { margin: 1rem 0; }
.specs-list__item { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.specs-list__item--sub { padding-left: 20px; font-size: 0.8rem; color: #6c757d; }
.specs-list__divider { border: none; border-top: 1px solid #e9ecef; margin: 8px 0; }
.specs-list__divider--bold { border: none; border-top: 2px solid #495057; margin: 10px 0; }
.specs-list__item--total { font-size: 1.1rem; color: #212529; }
.coordinate { font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 0.8rem; white-space: pre; }

.shipping-info__option { display: flex; gap: 0.5rem; margin-bottom: 12px; }

.components-table { width: 100%; border-collapse: collapse; margin-top: 20px; background: #fff; border-radius: 6px; overflow-x: auto; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.components-table th { background: #e9ecef; padding: 12px 15px; text-align: left; font-weight: 500; white-space: nowrap; color: #495057; font-size: 0.9rem; }
.components-table td { padding: 10px 15px; border-bottom: 1px solid #eaeaea; font-size: 0.85rem; vertical-align: middle; white-space: nowrap; }
.components-table tr:last-child td { border-bottom: none; }
.components-table tr:hover { background: #f8f9fa; }

/* CORRECCIÃ“N: Estilos para #quoteStatus */
#quoteStatus {
      margin: 10px 0;
      display: flex;
      align-items: center;
      justify-content: center;
      min-height: 20px;
      height: auto;
      transition: opacity 0.3s;
      color: var(--color-primary);
      CONTAIN-INTRINSIC-BLOCK-SIZE: AUTO 100PX;
      gap: .5rem;
}
#quoteStatus:empty {
    margin: 0;
    min-height: 0;
}

.spinner-icon { display: inline-block; width: 1em; height: 1em; vertical-align: -0.125em; border: 0.15em solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spinner-border .75s linear infinite; }
@keyframes spinner-border { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------
    #RELATED PRODUCTS SLIDER
    -------------------------------------------------------------------------- */
.related-products-slider { margin: 40px 0; }
.related-products-slider__header { margin-left: 64px; margin-bottom: 24px; }
.related-products-slider__wrapper { position: relative; }

.related-products-slider__container {
    overflow: hidden;
    margin: 0 60px;
    padding: 10px 0; /* CORRECCIÃ“N: AÃ±ade espacio vertical para evitar que se recorte la animaciÃ³n de hover. */
}

.related-products-slider__track { display: flex; transition: transform 0.4s ease-in-out; }

.related-products-slider__nav {
    position: absolute; top: 40%; transform: translateY(-50%);
    width: 40px; height: 40px; background: var(--color-white);
    border: 1px solid var(--color-black); border-radius: 50%;
    cursor: pointer; z-index: 1; display: grid; place-items: center;
    transition: all var(--transition-base);
}
.related-products-slider__nav:disabled { opacity: 0.3; cursor: not-allowed; }
.related-products-slider__nav:hover:not(:disabled) { background: var(--color-gray-light); }
.related-products-slider__nav--prev { left: 0; }
.related-products-slider__nav--next { right: 0; }

.slider-card {
    flex: 0 0 calc(25% - 24px); margin: 0 12px;
    background: var(--color-white);
    overflow: hidden;
    transition: transform var(--transition-base);
    isolation: isolate;
}
.slider-card:hover {  
    transform: translateY(-5px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    position: relative; /* CORRECCIÃ“N: Necesario para que z-index funcione. */
    z-index: 2; /* CORRECCIÃ“N: Asegura que la tarjeta y su sombra se muestren sobre las demÃ¡s. */
}
.slider-card__image-container { width: 100%; aspect-ratio: 1 / 1; overflow: hidden; }
.slider-card__image { width: 100%; height: 100%; object-fit: cover; display: block;  border-radius: var(--radius-sm);}
.slider-card__content { padding: 16px; }
.slider-card__title { margin-bottom: 8px; font-size: var(--font-size-base); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* INICIO: Estilos de precio para el slider (copiados de index.css) */
.slider-card .price-container {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 24px;
}

.slider-card .price {
    margin: 0;
    font-size: var(--font-size-base);
}



.slider-card .original-price {
    font-size: 0.9rem;
    color: var(--color-gray-medium);
    font-weight: var(--font-weight-regular);
}

.slider-card .original-price del {
    text-decoration: line-through;
}
/* FIN: Estilos de precio para el slider */

/* --------------------------------------------------------------------------
    #UTILITY & MESSAGE STYLES
    -------------------------------------------------------------------------- */
.flash-message { padding: 15px; margin-bottom: 20px; text-align: left; border-radius: var(--radius-sm); }
.flash-message--error { color: #a94442; background-color: #f2dede; border: 1px solid #ebccd1; }
.flash-message--success { color: #3c763d; background-color: #dff0d8; border: 1px solid #d6e9c6; }

.product-not-available {
      padding: 40px 20px; text-align: center; min-height: 40vh;
      display: flex; flex-direction: column; justify-content: center; align-items: center;
}
.product-not-available p { max-width: 600px; margin-bottom: 20px; }


/* --------------------------------------------------------------------------
    #MEDIA QUERIES
    -------------------------------------------------------------------------- */
@media screen and (max-width: 1019px) {
    .product-details__main-content { flex-direction: column; align-items: center; }
    .product-details__gallery, .product-details__info { width: 100%; }
    .product-details__gallery { flex-direction: column-reverse; gap: 1rem; }
    .product-details__gallery-main-view { width: 100%; }
    .product-details__gallery-thumbs { flex-direction: row; width: 100%; justify-content: center; gap: 10px; padding-top: 4px; overflow-x: auto; padding-bottom: 5px; }
    .gallery-thumb { width: 60px; height: 60px; flex-shrink: 0; }
    .gallery-thumb--dae { width: 60px; height: 60px; }
    .gallery-thumb--dae .dae-thumb-icon {font-size: 14px;}
    .gallery-thumb--dae .dae-thumb-text { font-size: 0.8em; }
    .product-details__info { padding: 0; }
    .product-details__title {font-weight: 300;font-size: 24px;}
    .viewer-controls--top { width: 95%; padding: 8px 10px; gap: 6px; border-radius: 0.5rem; }
    #customizeProductBtn { min-height: 3rem}
    .viewer-controls__title { margin-bottom: 0; }
    .viewer-controls__measure-labels h6 { font-size: 0.75rem; }
    .measure-input-group { padding: 0; margin: 0 3px; gap: 3px; }
    .measure-input-group__input { width: 40px; font-size: 0.8rem; }
    .measure-input-group__unit { font-size: 0.75rem;}
    .measure-input-group__icon { width: 12px; height: 12px; }
    .tabs-component__panel { padding: 12px; }
    .tabs-component__nav { gap: 5px; overflow-x: auto; justify-content: flex-start; padding-bottom: 5px; }
    .tabs-component__btn { padding: 8px 10px; white-space: nowrap; }
    
    .related-products-slider__header { margin-left: 12px; }
    .related-products-slider__container { margin: 0; }
    .related-products-slider__nav { display: none; }
    .related-products-slider__track {
      overflow-x: auto; scroll-snap-type: x mandatory;
      -webkit-overflow-scrolling: touch; scrollbar-width: none;
    }
    .related-products-slider__track::-webkit-scrollbar { display: none; }
    .slider-card {
      flex: 0 0 80%; margin: 0 10px; scroll-snap-align: start;
    }
}

@media screen and (max-width: 767px) {   
    .product-details__gallery-main-view, #daeViewerContainer { min-height: 300px; }
    .viewer-controls--top { gap: 5px; padding: 8px; border-radius: 0.75rem; }
    .viewer-controls__title { font-size: 0.8rem; }
    .viewer-controls__measure-labels { flex-wrap: wrap; }
    .viewer-controls__measure-labels h6 { padding: 0 3px; font-size: 0.7rem;}
    .viewer-controls__measure-inputs { flex-wrap: wrap; gap: 5px; }
    .measure-input-group { flex-basis: calc(33.33% - 8px); min-width: 80px; margin: 0 2px; }
    
    .slider-card { flex: 0 0 90%; }
    .tabs-component__panel { padding: 12px 5px; }
    .related-products-slider__header { margin-left: 5px; }

    .floating-icon-btn { height: 2.5rem; border-radius: 1.25rem; }
    .floating-icon-btn__icon { height: 2.5rem; width: 2.5rem; }
    .floating-icon-btn__icon img,
    .floating-icon-btn__icon svg { height: 1.25rem; width: 1.25rem; }

    .viewer-module-floater-container { right: 0.5rem; gap: 0.5rem; }
}
