/**
 * HHD Variant Selector Styles
 * 
 * Styles for the custom product selector for HHD synced products
 *
 * @package Naturholz
 * @version 1.6.0 - Unreachable tier styling
 * 
 * FIXES INCLUDED:
 * - v1.6.0: Added .unreachable-tier styling for tiers above available stock
 * - Issue #2: Single variant simplified styling
 * - Issue #5: Package-product linking display
 * - Issue #6: Improved price tier table
 */

/* ==========================================================================
   HHD PRICE DISPLAY
   ========================================================================== */

.hhd-price-from {
    display: flex;
    align-items: baseline;
    gap: 0.25em;
}

.hhd-price-from .price-prefix {
    font-size: var(--text-base);
    font-weight: 400;
    color: var(--color-warm-gray);
}

.hhd-price-from .price-amount {
    font-size: var(--text-2xl);
    font-weight: 600;
    color: var(--color-primary);
}

.hhd-price-from .price-unit {
    font-size: var(--text-sm);
    font-weight: 400;
    color: var(--color-warm-gray);
}

.hhd-price-per-lfm {
    display: block;
    font-size: var(--text-sm);
    color: var(--color-warm-gray);
    margin-top: var(--space-xs);
}

/* ==========================================================================
   HHD VARIANT SELECTOR CONTAINER
   On single product page - NO extra container styling (seamless integration)
   ========================================================================== */

.hhd-variant-selector {
    margin: 0;
    padding: 0;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
}

/* If used standalone (outside product page), add container styling */
.hhd-variant-selector--standalone {
    margin: var(--space-xl) 0;
    padding: var(--space-xl);
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.hhd-selector-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-charcoal);
    margin-bottom: var(--space-sm);
}

/* ==========================================================================
   HHD MESSAGE AREAS
   ========================================================================== */

.hhd-message {
    padding: var(--space-md);
    background: var(--color-cream);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    color: var(--color-charcoal);
}

.hhd-message--above {
    margin-bottom: var(--space-lg);
    border-left: 3px solid var(--color-primary);
}

.hhd-message--below {
    margin-top: var(--space-lg);
    border-left: 3px solid var(--color-secondary);
}

/* ==========================================================================
   LENGTH SELECTOR BUTTONS
   ========================================================================== */

.hhd-length-selector {
    margin-bottom: var(--space-xl);
}

.hhd-length-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.hhd-length-btn {
    position: relative;
    min-width: 80px;
    padding: var(--space-sm) var(--space-md);
    background: var(--color-cream);
    border: 2px solid var(--color-sand);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-charcoal);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.hhd-length-btn:hover:not(.out-of-stock):not(.active) {
    border-color: var(--color-primary-light);
    background: var(--color-cream-dark);
}

.hhd-length-btn.active {
    border-color: var(--color-primary);
    background: var(--color-primary);
    color: white;
}

.hhd-length-btn.out-of-stock {
    opacity: 0.5;
    cursor: not-allowed;
    text-decoration: line-through;
}

/* Stock tooltip on hover */
.length-stock-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    padding: var(--space-xs) var(--space-sm);
    background: var(--color-charcoal);
    color: white;
    font-size: var(--text-xs);
    font-weight: 400;
    white-space: nowrap;
    border-radius: var(--radius-sm);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
    pointer-events: none;
    z-index: var(--z-tooltip);
}

.length-stock-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--color-charcoal);
}

.hhd-length-btn:hover .length-stock-tooltip,
.length-stock-tooltip.visible {
    opacity: 1;
    visibility: visible;
}

/* ==========================================================================
   QUANTITY SELECTOR WITH SLIDER
   ========================================================================== */

.hhd-quantity-selector {
    margin-bottom: var(--space-xl);
}

.hhd-quantity-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.hhd-qty-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--color-cream);
    border: 1px solid var(--color-sand);
    border-radius: var(--radius-md);
    font-size: var(--text-lg);
    font-weight: 500;
    color: var(--color-charcoal);
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.hhd-qty-btn:hover {
    background: var(--color-beige);
    border-color: var(--color-primary-light);
}

.hhd-qty-btn:active {
    transform: scale(0.95);
}

/* Range Slider Styling */
.hhd-quantity-slider {
    flex: 1;
    min-width: 100px;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--color-beige);
    border-radius: var(--radius-full);
    outline: none;
    cursor: pointer;
}

.hhd-quantity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--color-primary);
    border: 2px solid white;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
}

.hhd-quantity-slider::-webkit-slider-thumb:hover {
    background: var(--color-primary-dark);
    transform: scale(1.1);
}

.hhd-quantity-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--color-primary);
    border: 2px solid white;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

/* Number Input */
.hhd-quantity-input {
    width: 60px;
    height: 40px;
    padding: var(--space-xs);
    text-align: center;
    font-size: var(--text-base);
    font-weight: 600;
    border: 1px solid var(--color-sand);
    border-radius: var(--radius-md);
    background: white;
}

.hhd-quantity-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(139, 94, 52, 0.1);
}

/* Hide number input spinners */
.hhd-quantity-input::-webkit-outer-spin-button,
.hhd-quantity-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.hhd-quantity-input[type=number] {
    -moz-appearance: textfield;
}

.hhd-quantity-unit {
    font-size: var(--text-sm);
    color: var(--color-warm-gray);
    flex-shrink: 0;
}

/* Stock Info */
.hhd-stock-info {
    margin-top: var(--space-sm);
    font-size: var(--text-sm);
    color: var(--color-warm-gray);
}

.hhd-stock-available .stock-count {
    font-weight: 600;
    color: var(--color-secondary);
}

/* ==========================================================================
   PRICE CALCULATION DISPLAY
   ========================================================================== */

.hhd-price-calculation {
    padding: var(--space-lg);
    background: var(--color-cream);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
}

.hhd-calc-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) 0;
}

.hhd-calc-row:not(:last-child) {
    border-bottom: 1px solid var(--color-beige);
}

.hhd-calc-row .calc-label {
    font-size: var(--text-sm);
    color: var(--color-warm-gray);
}

.hhd-calc-row .calc-value {
    font-size: var(--text-base);
    font-weight: 500;
    color: var(--color-charcoal);
}

.hhd-calc-total {
    padding-top: var(--space-md) !important;
    margin-top: var(--space-xs);
    border-top: 2px solid var(--color-beige) !important;
    border-bottom: none !important;
}

.hhd-calc-total .calc-label {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--color-charcoal);
}

.hhd-calc-total .calc-value {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--color-primary);
}

/* ==========================================================================
   QUANTITY DISCOUNT INFO / PRICE TIERS
   FIXED: Issue #6 - Better table formatting
   ========================================================================== */

.hhd-discount-info {
    margin-top: var(--space-md);
}

.hhd-price-tiers-section {
    margin-top: var(--space-lg);
    padding-top: var(--space-md);
    border-top: 1px dashed var(--color-beige);
}

.hhd-price-tiers-title {
    margin: 0 0 var(--space-md);
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--color-charcoal);
}

.hhd-price-tiers-details {
    font-size: var(--text-sm);
}

.hhd-price-tiers-details summary {
    cursor: pointer;
    color: var(--color-primary);
    font-weight: 500;
    padding: var(--space-sm) 0;
    list-style: none;
}

.hhd-price-tiers-details summary::-webkit-details-marker {
    display: none;
}

.hhd-price-tiers-details summary::before {
    content: '▶ ';
    font-size: 10px;
    margin-right: var(--space-xs);
}

.hhd-price-tiers-details[open] summary::before {
    content: '▼ ';
}

.hhd-price-tiers-details summary:hover {
    color: var(--color-primary-dark);
}

.hhd-price-tiers-details[open] summary {
    margin-bottom: var(--space-sm);
}

.hhd-price-tiers-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
    background: white;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.hhd-price-tiers-table th,
.hhd-price-tiers-table td {
    padding: var(--space-sm) var(--space-md);
    text-align: left;
    border-bottom: 1px solid var(--color-beige);
}

.hhd-price-tiers-table th {
    font-weight: 600;
    color: var(--color-charcoal);
    background: var(--color-cream-dark);
    border-bottom: 2px solid var(--color-beige);
}

.hhd-price-tiers-table tbody tr:last-child td {
    border-bottom: none;
}

.hhd-price-tiers-table tr.active {
    background: rgba(139, 94, 52, 0.08);
}

.hhd-price-tiers-table tr.active td {
    color: var(--color-primary);
    font-weight: 600;
}

.hhd-price-tiers-table tbody tr:hover:not(.active) {
    background: var(--color-cream);
}

/* Highlight effect when tier changes */
.hhd-price-tiers-table tbody tr.tier-highlight {
    animation: tierHighlight 0.5s ease;
}

@keyframes tierHighlight {
    0% { background: rgba(139, 94, 52, 0.3); }
    100% { background: rgba(139, 94, 52, 0.08); }
}

/* FIX #5: Contact tier styling - faded appearance for "auf Anfrage" tiers */
.hhd-price-tiers-table tr.contact-tier {
    opacity: 0.6;
    background: var(--color-cream-dark);
}

.hhd-price-tiers-table tr.contact-tier td {
    color: var(--color-charcoal);
    font-style: italic;
}

.hhd-price-tiers-table tr.contact-tier td.contact-price {
    font-size: var(--text-xs);
    white-space: nowrap;
}

.hhd-price-tiers-table tr.contact-tier:hover {
    opacity: 0.8;
}

/* v2.3.0 FIX: Unreachable tier styling - for tiers ABOVE available stock */
/* These tiers cannot be reached with current stock, show "auf Anfrage" */
.hhd-price-tiers-table tr.unreachable-tier {
    opacity: 0.5;
    background: var(--color-cream-dark);
}

.hhd-price-tiers-table tr.unreachable-tier td {
    color: var(--color-warm-gray);
    font-style: italic;
}

.hhd-price-tiers-table tr.unreachable-tier td.contact-price {
    font-size: var(--text-xs);
    white-space: nowrap;
}

.hhd-price-tiers-table tr.unreachable-tier td.contact-price a.tier-contact-link {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
    font-style: normal;
}

.hhd-price-tiers-table tr.unreachable-tier td.contact-price a.tier-contact-link:hover {
    text-decoration: underline;
    color: var(--color-primary-dark);
}

.hhd-price-tiers-table tr.unreachable-tier:hover {
    opacity: 0.7;
}

/* ==========================================================================
   ADD TO CART BUTTON (HHD)
   ========================================================================== */

.hhd-add-to-cart-wrapper {
    margin-top: var(--space-lg);
}

.hhd-add-to-cart-btn {
    width: 100%;
    padding: var(--space-md) var(--space-2xl) !important;
    font-size: var(--text-base) !important;
    font-weight: 600 !important;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ==========================================================================
   HHD CART FORM - Override WooCommerce defaults
   ========================================================================== */

.hhd-cart-form {
    margin: 0;
    padding: 0;
    /* CRITICAL: Override the flex layout from .product-single__cart form.cart */
    display: block !important;
    flex-wrap: unset !important;
}

/* Ensure the variant selector inside the form is also block layout */
.hhd-cart-form .hhd-variant-selector {
    display: block;
    width: 100%;
}

/* Fix the add to cart wrapper layout */
.hhd-cart-form .hhd-add-to-cart-wrapper {
    display: block;
    width: 100%;
}

/* ==========================================================================
   FIX Issue #2: SINGLE VARIANT PRODUCT STYLES
   Simplified interface when only one length is available
   ========================================================================== */

.hhd-variant-selector.hhd-single-variant .hhd-length-selector {
    display: none;
}

.hhd-variant-selector.hhd-single-variant .hhd-quantity-simple {
    margin-bottom: var(--space-lg);
}

.hhd-quantity-simple .hhd-quantity-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.hhd-quantity-simple .hhd-quantity-input {
    width: 120px;
    height: 48px;
    padding: var(--space-sm) var(--space-md);
    font-size: var(--text-lg);
    font-weight: 600;
    text-align: center;
    border: 2px solid var(--color-sand);
    border-radius: var(--radius-md);
}

.hhd-quantity-simple .hhd-quantity-input:focus {
    border-color: var(--color-primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(139, 94, 52, 0.1);
}

.hhd-quantity-simple .hhd-quantity-unit {
    font-size: var(--text-base);
    font-weight: 500;
    color: var(--color-warm-gray);
}

/* ==========================================================================
   FIX Issue #5: PACKAGE-PRODUCT LINKING STYLES
   ========================================================================== */

/* Available packages section on parent product */
.hhd-available-packages {
    margin: var(--space-2xl) 0;
    padding: var(--space-xl);
    background: var(--color-cream);
    border-radius: var(--radius-lg);
    border-left: 4px solid var(--color-secondary);
}

.hhd-available-packages h3 {
    margin: 0 0 var(--space-sm);
    font-size: var(--text-xl);
    color: var(--color-charcoal);
}

.hhd-available-packages .packages-intro {
    margin: 0 0 var(--space-lg);
    color: var(--color-warm-gray);
    font-size: var(--text-sm);
}

.packages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-md);
}

.package-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    padding: var(--space-md);
    background: white;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-beige);
    text-decoration: none;
    color: inherit;
    transition: all var(--transition-fast);
}

.package-card:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.package-card .package-name {
    font-weight: 600;
    color: var(--color-charcoal);
    font-size: var(--text-sm);
    line-height: 1.3;
}

.package-card .package-details {
    font-size: var(--text-xs);
    color: var(--color-warm-gray);
}

.package-card .package-price {
    font-weight: 700;
    color: var(--color-primary);
    font-size: var(--text-lg);
    margin-top: auto;
}

/* Parent product link on package pages */
.hhd-parent-product-link {
    margin: var(--space-md) 0;
    padding: var(--space-md);
    background: var(--color-cream);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
}

.hhd-parent-product-link p {
    margin: 0;
}

.hhd-parent-product-link a {
    color: var(--color-primary);
    font-weight: 600;
    text-decoration: underline;
}

.hhd-parent-product-link a:hover {
    color: var(--color-primary-dark);
}

.hhd-parent-product-link .small-note {
    font-size: var(--text-xs);
    color: var(--color-warm-gray);
    margin-top: var(--space-xs) !important;
}

/* ==========================================================================
   RESPONSIVE ADJUSTMENTS
   ========================================================================== */

@media (max-width: 768px) {
    .hhd-length-buttons {
        gap: var(--space-xs);
    }
    
    .hhd-length-btn {
        min-width: 70px;
        padding: var(--space-xs) var(--space-sm);
        font-size: var(--text-xs);
    }
    
    .hhd-quantity-wrapper {
        flex-wrap: wrap;
    }
    
    .hhd-quantity-slider {
        order: 3;
        flex-basis: 100%;
        margin-top: var(--space-sm);
    }
    
    .hhd-qty-btn {
        width: 36px;
        height: 36px;
    }
    
    .hhd-quantity-input {
        width: 50px;
        height: 36px;
    }
    
    /* FIX Issue #5: Package grid responsive */
    .hhd-available-packages {
        padding: var(--space-lg);
    }
    
    .packages-grid {
        grid-template-columns: 1fr;
    }
    
    .package-card {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
    }
    
    .package-card .package-name {
        flex: 1 0 100%;
        margin-bottom: var(--space-xs);
    }
    
    .package-card .package-price {
        margin-top: 0;
    }
    
    /* FIX Issue #2: Simple quantity responsive */
    .hhd-quantity-simple .hhd-quantity-input {
        width: 100px;
        height: 44px;
    }
}

@media (max-width: 480px) {
    .hhd-length-btn {
        min-width: 60px;
        padding: var(--space-xs);
    }
    
    .length-stock-tooltip {
        font-size: 10px;
        padding: 4px 8px;
    }
    
    /* FIX Issue #6: Price tier table responsive */
    .hhd-price-tiers-table th,
    .hhd-price-tiers-table td {
        padding: var(--space-xs) var(--space-sm);
        font-size: var(--text-xs);
    }
}

/* ==========================================================================
   PRODUCT CARD PRICE (ARCHIVE PAGES)
   ========================================================================== */

.product-card .hhd-price-from {
    font-size: var(--text-sm);
}

.product-card .hhd-price-from .price-amount {
    font-size: var(--text-lg);
}

.product-card .hhd-price-from .price-prefix,
.product-card .hhd-price-from .price-unit {
    font-size: var(--text-xs);
}

/* ==========================================================================
   PACKAGE PRODUCT STYLES
   ========================================================================== */

.hhd-package-info {
    margin: var(--space-lg) 0;
    padding: var(--space-lg);
    background: var(--color-cream);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--color-secondary);
}

.hhd-package-title {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--color-charcoal);
    margin-bottom: var(--space-sm);
}

.hhd-package-details {
    font-size: var(--text-sm);
    color: var(--color-warm-gray);
}

.hhd-package-details table {
    width: 100%;
    margin-top: var(--space-md);
}

.hhd-package-details td {
    padding: var(--space-xs) 0;
}

.hhd-package-details td:first-child {
    font-weight: 500;
    color: var(--color-charcoal);
}

/* ==========================================================================
   HHD EIGENSCHAFTEN TAB STYLES
   ========================================================================== */

.hhd-eigenschaften {
    margin: var(--space-lg) 0;
}

.hhd-eigenschaften-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.hhd-eigenschaften-table th,
.hhd-eigenschaften-table td {
    padding: var(--space-md);
    text-align: left;
    border-bottom: 1px solid var(--color-beige);
}

.hhd-eigenschaften-table th {
    font-weight: 600;
    color: var(--color-charcoal);
    width: 40%;
    background: var(--color-cream);
}

.hhd-eigenschaften-table td {
    color: var(--color-warm-gray);
}

.hhd-eigenschaften-table tr:hover {
    background: var(--color-cream-light);
}

.hhd-eigenschaften-table tr:last-child th,
.hhd-eigenschaften-table tr:last-child td {
    border-bottom: none;
}

@media (max-width: 768px) {
    .hhd-eigenschaften-table th,
    .hhd-eigenschaften-table td {
        padding: var(--space-sm);
        font-size: var(--text-xs);
    }
    
    .hhd-eigenschaften-table th {
        width: 45%;
    }
}


/* ==========================================================================
   FIX Issue #5: UNREACHABLE TIER STYLES (auf Anfrage)
   ========================================================================== */

.hhd-tier-unavailable {
    opacity: 0.5;
    background: var(--color-cream) !important;
}

.hhd-tier-unavailable .tier-price {
    display: none;
}

.hhd-tier-anfrage {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--color-primary);
    font-size: var(--text-sm);
    font-weight: 500;
    text-decoration: none;
}

.hhd-tier-anfrage:hover {
    text-decoration: underline;
    color: var(--color-primary-dark);
}

.hhd-tier-anfrage svg {
    width: 14px;
    height: 14px;
}

/* Tooltip for unavailable tiers */
.hhd-tier-unavailable[title] {
    cursor: help;
}