/* ==========================================================================
   PRODUCT DETAILS STYLESHEET
   - Unified version: Combines original styles + PHP inline styles.
   - Refactored for modularity and readability.
   ========================================================================== */

/* --------------------------------------------------------------------------
   #LAYOUT & VARIABLES
   -------------------------------------------------------------------------- */
.product-details {
    --spacing-section: 24px;
    --radius-section: 16px;
    --radius-element: 8px;
    --radius-large: 20px;
    --thumb-size: 80px;
    /* Button Styles */
    --btn-radius-desktop: 16px;
    --btn-radius-mobile: 12px;
    --btn-font-size-desktop: 13px;
    --btn-font-size-mobile: 12px;
}

.product-details__main-content {
    display: flex;
    justify-content: space-between;
    width: 100%;
    gap: 40px;    
    margin-top: 2rem;
    align-items: flex-start;
}

/* --------------------------------------------------------------------------
   #GALLERY SECTION
   -------------------------------------------------------------------------- */
.product-details__gallery {
    width: 60%;    
    display: flex;
    flex-direction: column; 
    align-items: center;    
}

/* Wrapper to center the viewer */
.gallery-view-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Main Viewer Container */
.product-details__gallery-main-view {
    position: relative;
    background-color: #fff;
    border-radius: var(--radius-large);
    overflow: hidden;
    
    /* Desktop: 80% of the column width, 1:1 Aspect Ratio */
    width: 75%; 
    aspect-ratio: 1 / 1;
    height: auto;
    
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 3D Mode Active State (Controlled by JS) */
.product-details__gallery-main-view.view-3d-active {
    /* No specific override needed here unless ratio changes */
}

.product-details__gallery-image {
    width: 100%;
    height: 100%;    
    object-fit: cover;    
    display: block;    
}

/* 3D Model Container */
#modelViewerContainer {
    width: 100%;
    height: 100%;
    overflow: hidden;    
    position: relative;    
}

#modelViewerContainer canvas {
    display: block;    
    width: 100% !important;    
    height: 100% !important;    
}

/* Helper Classes for Extracted Inline Styles */
.rotate-90 { transform: rotate(90deg); }
.rotate-minus-90 { transform: rotate(-90deg); }
.visibility-hidden { visibility: hidden; }
.display-none { display: none; }

/* --------------------------------------------------------------------------
   #GALLERY CONTROLS
   -------------------------------------------------------------------------- */

/* Side Navigation Buttons */
.gallery-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    z-index: 10;
    padding: 10px;
    opacity: 1;
    transition: opacity 0.3s;
}

.gallery-nav-btn:hover { opacity: 0.8; }
.gallery-nav-btn--prev { left: 10px; }
.gallery-nav-btn--next { right: 10px; }

.gallery-nav-btn img { 
    width: 20px; 
    height: 20px; 
}

/* 3D Toggle Button (Top Right) */
.gallery-mode-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    bottom: auto;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    z-index: 20;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    font-size: 12px;
    font-weight: 600;
    color: #000;
}
.gallery-mode-toggle img { width: 16px; height: 16px; }

/* Viewer Footer Info (Counter & Module Name) */
.viewer-footer-info {
    display: flex;
    justify-content: center; 
    align-items: center;
    width: 100%;
    margin-top: 15px;
    position: relative;
    max-width: 90%; 
}

.module-name-indicator {
    position: absolute;
    left: 0;
    font-size: 14px;
    font-weight: 400;
    color: #000;
    margin: 0 8.5%;
}

.viewer-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 500;
    color: #000;
}

.indicator-arrows {
    display: flex;
    gap: 8px;
}

.indicator-arrow {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
}
.indicator-arrow img { width: 8px; height: 8px; }

/* --------------------------------------------------------------------------
   #3D MEASURE CONTROLS (Compact Overlay)
   -------------------------------------------------------------------------- */
#viewerControlsCompact {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 15;
    width: auto;
    display: none; /* Toggled via JS */
    justify-content: center;
}

.custom-measure-bar {
    display: flex;
    align-items: center;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 8px 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    width: fit-content;
    pointer-events: auto;
}

.measure-axis-select {
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: #000;
    padding: 4px 8px;
    cursor: pointer;
    outline: none;
}

.measure-value-input {
    border: none;
    border-left: 1px solid #eee;
    background: transparent;
    font-family: inherit;
    font-size: 15px;
    width: 70px;
    text-align: center;
    outline: none;
    padding: 6px;
    color: #000;
}

.measure-submit-btn {
    background: #000;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-left: 8px;
    transition: transform 0.2s;
}
.measure-submit-btn:hover { transform: scale(1.1); }
.measure-submit-btn img { width: 12px; height: 12px; filter: invert(1); }

/* --------------------------------------------------------------------------
   #PRODUCT INFO SECTION
   -------------------------------------------------------------------------- */
.product-details__info {
    width: 40%;    
    display: flex;
    flex-direction: column;
    gap: var(--spacing-unit);
    padding-left: var(--spacing-section);    
}

.info-header {
    display: flex; 
    flex-direction: column; 
    gap: 4px;
}

.product-details__title {
    font-weight: 200;    
    margin-bottom: 1rem;
    font-size: 32px;
}

/* Price Display */
.product-details__price-container {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem; 
    margin-bottom: 0;
    font-size: 1.8rem;
    min-height: 2.5rem; 
}

.product-details__price {
    font-size: 18px;
    margin: 0;
    color: var(--color-black);
    font-weight: 300;
}

.product-details__price--original {
    font-size: 16px;
    color: #121212bf;
    text-decoration: line-through;
    font-weight: 300;
}

.product-details__offer-tag {
    background-color: #87f1ad;
    color: #0a0b09;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

/* Loading State for Price Optimization */
.product-details__price-container::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 1.75rem; 
    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,
.product-details__info.is-loading .purchase-row {
    opacity: 0.6;
    pointer-events: none;
}

/* --------------------------------------------------------------------------
   #PURCHASE FORM & ACTIONS
   -------------------------------------------------------------------------- */
.purchase-form { display: flex; flex-direction: column; gap: 0.5rem; }

/* NEW LAYOUT: Quantity + Add to Cart Row */
.purchase-row {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    margin-top: 1rem;
    width: 100%;
}

.purchase-form__quantity { 
    display: flex; 
    flex-direction: column; 
    gap: 8px;
    width: 45%; /* 45% Width Relation */
    flex: 0 0 45%;
}

/* Quantity Selector Styling */
.quantity-selector {
     width: 100%; /* Fill container */
     padding: 0;
     min-height: 48px; /* Match button height */
     display: flex;
     align-items: center;
     justify-content: space-between;
     border-radius: var(--btn-radius-desktop);
     background-color: #fff;
     padding-right: 24px;
}

.quantity-selector__button {
     border: none; 
     cursor: pointer; 
     height: 100%; 
     width: 30%;
     background-color: transparent; 
     font-size: 1.5rem; 
     color: var(--color-black);
     padding: 0;
     line-height: 1;
     display: flex;
     align-items: center;
     justify-content: center;
}

.quantity-selector__input {
     text-align: center; 
     border: none; 
     outline: none; 
     width: 40%;
     font-size: 1rem; 
     font-family: var(--font-primary);
     background: transparent;
     font-weight: 500;
}

/* Actions Container (For Buy Now) */
.purchase-form__actions { 
    display: flex; 
    flex-direction: column; 
    width: 100%;
}

/* BUTTON STYLES */
.btn { 
    min-height: 48px; 
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

/* Customize Button */
.btn-personalizar {
    background-color: #EFEDA9; /* Yellow */
    color: #000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-radius: var(--btn-radius-desktop);
    margin-bottom: 12px;
    font-size: var(--btn-font-size-desktop);
    width: 100%;
}
.btn-personalizar .btn--modern__text {
    color: #000; 
    font-weight: 400; 
    text-align: center; 
    padding-left: 0;
}
.btn-personalizar:hover {
    background-color: #FFFB8F;
}

/* Add to Cart Button (New Style) */
.btn-add-cart {
    background-color: #000;
    color: #FFF;
    border-color: #000;
    border-radius: var(--btn-radius-desktop);
    font-size: var(--btn-font-size-desktop);
    width: 55%; /* 55% Width Relation */
    flex: 0 0 55%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-add-cart:hover {
    background-color: #333;
    border-color: #333;
}
.btn-add-cart img {
    width: 18px;
    height: 18px;
}

/* Buy Now Button */
.btn-comprar-ahora {
    background-color: #000;
    color: #FFF;
    border-color: #000;
    border-radius: var(--btn-radius-desktop);
    font-size: var(--btn-font-size-desktop);
    width: 100%;
}
.btn-comprar-ahora:hover {
    background-color: #333;
    border-color: #333;
}

/* General Icons */
.purchase-form__meta { display: flex; align-items: center; gap: 0.5rem; margin-top: 15px; }
.purchase-form__meta-icon { max-width: 20px; }
.btn-icon-right { width: 18px; height: 18px; margin-left: 8px; }

/* --------------------------------------------------------------------------
   #CUSTOM SELECT (Assembly Method)
   -------------------------------------------------------------------------- */
.purchase-form__assembly-method {
    margin-bottom: 10px;
}

.custom-select-container {
    position: relative;
    width: 100%;
    border: none;
}

.custom-select-trigger {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #000;
    cursor: pointer;
    padding: 5px 0;
}

.custom-select-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 50;
    display: none;
    overflow: hidden;
}

.custom-select-options.open { display: block; }

.custom-option {
    padding: 10px 12px;
    font-size: 12px;
    color: #333;
    cursor: pointer;
    transition: background 0.2s;
}

.custom-option:hover { background: #f9f9f9; }
.custom-option.selected { font-weight: 600; background: #f0f0f0; }

/* --------------------------------------------------------------------------
   #SELECTORS (Finish)
   -------------------------------------------------------------------------- */
.finish-selector { margin-bottom: 1rem; }

/* Unified label class */
.product-input-label {
    color: rgba(0,0,0,0.5);
    font-size: 12px;
    margin-bottom: 8px;
    font-weight: 400;
}

.finish-options { display: flex; gap: 12px; }
.finish-dot { width: 24px; height: 24px; border-radius: 50%; border: 1px solid transparent; cursor: pointer; padding: 2px; }
.finish-dot--active { border-color: #000; }
.finish-dot__inner { width: 100%; height: 100%; border-radius: 50%; }

/* Mockup colors extracted from inline styles */
.bg-e5e5e5 { background: #E5E5E5; }
.bg-333 { background: #333; }
.bg-f8f8f8-border { background: #F8F8F8; border: 1px solid #ddd; }

/* --------------------------------------------------------------------------
   #META INFO (Production Time, Protected Purchase)
   -------------------------------------------------------------------------- */
.purchase-form__meta h6 {
    font-size: 12px;
    margin: 0;
    font-weight: 500;
    color: #333;
}

/* --------------------------------------------------------------------------
   #TABS COMPONENT
   -------------------------------------------------------------------------- */
.tabs-component { width: 100%; margin: 40px 0; }
.tabs-component__nav { display: flex; justify-content: center; gap: 40px; border-bottom: 1px solid #eee; margin-bottom: 24px; }

.tabs-component__btn {
     background-color: transparent;
     border: none;
     border-bottom: 2px solid transparent;
     cursor: pointer;
     padding: 10px 0;
     position: relative;
     color: #999;
     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: #333; }
.tabs-component__btn--active { color: var(--color-black); border-bottom-color: var(--color-black); font-weight: 500; }

.tabs-component__panel { 
    display: none; 
    padding: 10px 0; 
    opacity: 0; 
    transition: opacity var(--transition-base); 
    text-align: justify; 
    font-size: 14px;
    line-height: 1.6;
}
.tabs-component__panel p {
    font-size: inherit; 
    text-align: justify; 
    line-height: 1.6;
}
.tabs-component__panel--active { display: block; opacity: 1; }

.specs-list h5 { margin: 1rem 0; }
.specs-list__item { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 14px; }
.specs-list__divider--bold { border: none; border-top: 2px solid #495057; margin: 10px 0; }
.specs-list__item--total { font-size: 1.1rem; color: #212529; font-weight: 600; }

/* Breakdown Container (Hidden by default) */
#priceBreakdownContainer {
    display: none; 
    margin-top: 20px;
}

/* Quote Status */
#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);
     gap: .5rem;
}
#quoteStatus:empty {
    margin: 0;
    min-height: 0;
    display: none;
}

.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: 60px 0; }
.related-products-slider__header { margin-bottom: 24px; font-size: 24px; font-weight: 500; }
.related-products-slider__wrapper { position: relative; }

.related-products-slider__container {
    overflow: hidden;
    margin: 0 0;
}

.related-products-slider__track { display: flex; transition: transform 0.4s ease-in-out; gap: 24px; }

.related-products-slider__nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    width: 40px; height: 40px; 
    background: transparent;
    border: none;
    border-radius: 0;
    cursor: pointer; z-index: 10; display: grid; place-items: center;
    transition: opacity 0.3s;
    box-shadow: none;
}
.related-products-slider__nav img { width: 30px; height: 30px; }
.related-products-slider__nav:disabled { opacity: 0.3; cursor: not-allowed; }
.related-products-slider__nav:hover:not(:disabled) { opacity: 0.7; background: transparent; }
.related-products-slider__nav--prev { left: -40px; }
.related-products-slider__nav--next { right: -40px; }

.slider-card {
    flex: 0 0 calc(25% - 18px); /* 4 cards */
    background: var(--color-white);
    overflow: hidden;
    transition: transform var(--transition-base);
}
.slider-card:hover { transform: translateY(-5px); }
.slider-card__image-container { width: 100%; aspect-ratio: 1 / 1; overflow: hidden; border-radius: 12px; }
.slider-card__image { width: 100%; height: 100%; object-fit: cover; display: block; }
.slider-card__content { padding: 12px 0; }
.slider-card__title { margin-bottom: 4px; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 400; }
.slider-card .price-container { display: flex; align-items: center; gap: 10px; min-height: 24px; }
.slider-card .price { margin: 0; font-size: 14px; color: #666; }

/* --------------------------------------------------------------------------
   #RESPONSIVE DESIGN
   -------------------------------------------------------------------------- */
@media screen and (max-width: 1024px) {
    .product-details__main-content { 
        flex-direction: column; 
        align-items: center; 
        gap: 30px; 
    }
    .product-details__gallery, .product-details__info { 
        width: 100%; 
        padding-left: 0; 
    }
    
    /* Mobile/Tablet Gallery Logic */
    .product-details__gallery-main-view { 
        /* Ensure it uses full available width */
        width: 100%; 
        max-width: 100%; 
        height: auto; 
        
        /* Default: Square (1:1) for Images */
        aspect-ratio: 1 / 1; 
        
        margin-bottom: 20px;
    }
    
    /* Specific override for 3D Mode on Mobile */
    .product-details__gallery-main-view.view-3d-active {
        aspect-ratio: 4 / 5;
    }
    
    .viewer-footer-info {
        max-width: 100%;
    }
    .module-name-indicator {
        margin: 0;
    }
    .slider-card { flex: 0 0 calc(50% - 12px); } /* 2 cards */
    .related-products-slider__nav { display: none; }
    .related-products-slider__track { overflow-x: auto; scrollbar-width: none; }

    /* Button Border Radius Adjustment for Mobile */
    .btn-personalizar,
    .btn-add-cart,
    .btn-comprar-ahora,
    .quantity-selector {
        border-radius: var(--btn-radius-mobile);
        font-size: var(--btn-font-size-mobile);
    }
}

@media screen and (max-width: 767px) {    
    .product-details__main-content { margin-top: 1rem; }
    .slider-card { flex: 0 0 100%; } /* 1 card */
    
    .product-details__title { font-size: 24px; }
    
    /* Description smaller on mobile */
    .tabs-component__panel { font-size: 13px; }
    
    /* Meta info smaller on mobile */
    .purchase-form__meta h6 { font-size: 11px; }
    
    /* Ensure gallery controls don't overlap too much on small screens */
    .gallery-mode-toggle { top: 10px; right: 10px; padding: 6px 10px; }
}