/* ============================================ */
/* WC QUANTITY DISCOUNT - v1.3.5              */
/* Simple Right Column Layout                 */
/* Custom Quantity Option - Redesigned       */
/* FIXED: Tablet responsive + Badge overflow  */
/* Udviklet af: Sascha Marc Rahn              */
/* ============================================ */

:root {
    --qd-primary-color: #FFA500;
    --qd-button-bg: #FF8C00;
    --qd-button-text: #FFFFFF;
    --qd-box-width: 320px;
    --qd-spacing-right: 30px;
    --qd-spacing-top: 30px;
    --qd-spacing-between: 30px;
}

/* ============================================ */
/* CRITICAL: HIDE WOOCOMMERCE FORM.CART       */
/* ============================================ */

.single-product form.cart,
.single-product .product form.cart,
body.single-product form.cart,
.woocommerce .product form.cart,
.summary.entry-summary form.cart {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    position: absolute !important;
    left: -9999px !important;
    pointer-events: none !important;
}

.woocommerce div.product form.variations_form,
body.woocommerce div.product form.variations_form {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    left: auto !important;
    pointer-events: auto !important;
    height: auto !important;
}

/* ============================================ */
/* DISCOUNT BOX & BUTTONS - ABSOLUTE RIGHT   */
/* WITH PROPER WHITESPACE - DESKTOP ONLY      */
/* ============================================ */

.summary.entry-summary {
    overflow: visible !important;
    position: relative !important;
    min-height: 500px !important;
}

.wc-qd-inline-container {
    position: absolute !important;
    top: var(--qd-spacing-top) !important;
    right: var(--qd-spacing-right) !important;
    width: var(--qd-box-width) !important;
    max-width: var(--qd-box-width) !important;
    margin: 0 !important;
    z-index: 10 !important;
}

.wc-qd-action-buttons-container {
    position: absolute !important;
    top: auto;
    right: var(--qd-spacing-right) !important;
    width: var(--qd-box-width) !important;
    max-width: var(--qd-box-width) !important;
    margin: 0 !important;
    z-index: 10 !important;
}

/* ============================================ */
/* FIX: Move product info left to make room   */
/* ============================================ */

.summary.entry-summary > *:not(.wc-qd-inline-container):not(.wc-qd-action-buttons-container) {
    max-width: calc(100% - var(--qd-box-width) - var(--qd-spacing-right) - 20px) !important;
}

.summary.entry-summary .product_title,
.summary.entry-summary .price,
.summary.entry-summary .woocommerce-product-details__short-description,
.summary.entry-summary .product_meta,
.summary.entry-summary p,
.summary.entry-summary h1,
.summary.entry-summary h2,
.summary.entry-summary .woocommerce-product-rating,
.summary.entry-summary .varetitel-flere-linjer {
    max-width: calc(100% - var(--qd-box-width) - var(--qd-spacing-right) - 20px) !important;
    margin-right: 0 !important;
}

/* ============================================ */
/* DISCOUNT BOX - WHITE BACKGROUND            */
/* ============================================ */

.wc-qd-inline-container {
    display: block !important;
    visibility: visible !important;
    overflow: visible !important;
}

.wc-qd-discount-box {
    background: #ffffff !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 8px !important;
    padding: 20px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
    display: block !important;
    visibility: visible !important;
    overflow: visible !important;
}

/* ============================================ */
/* RADIO OPTIONS - SIMPLE ROWS                */
/* ============================================ */

.wc-qd-radio-options {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    margin-bottom: 20px !important;
}

.wc-qd-radio-row {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    cursor: default !important;
    transition: none !important;
    flex-wrap: nowrap !important;
    overflow: visible !important;
    width: 100% !important;
}

.wc-qd-radio-row input[type="radio"] {
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    margin: 0 !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
    pointer-events: auto !important;
    position: relative !important;
    z-index: 10 !important;
}

.wc-qd-radio-row input.wc-qd-quantity-input,
input.wc-qd-quantity-input {
    width: 50px !important;
    height: 36px !important;
    padding: 6px 8px !important;
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    text-align: center !important;
    font-size: 15px !important;
    background: white !important;
    flex-shrink: 0 !important;
    color: #333 !important;
    font-weight: 500 !important;
    cursor: text !important;
    pointer-events: auto !important;
    position: relative !important;
    z-index: 10 !important;
}

.wc-qd-quantity-input:focus {
    outline: 2px solid var(--qd-primary-color) !important;
    border-color: var(--qd-primary-color) !important;
}

.wc-qd-radio-row label.wc-qd-package-text,
label.wc-qd-package-text {
    font-size: 14px !important;
    color: #333 !important;
    flex: 0 0 110px !important;
    min-width: 110px !important;
    max-width: 110px !important;
    width: 110px !important;
    cursor: default !important;
    user-select: none !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    padding: 0 !important;
}

.wc-qd-inline-label {
    font-size: 12px !important;
    color: #666 !important;
    font-style: italic !important;
    margin-left: 4px !important;
}

.wc-qd-radio-row span.wc-qd-savings-badge,
span.wc-qd-savings-badge {
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #4CAF50 !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    margin-left: auto !important;
    width: 80px !important;
    min-width: 80px !important;
    max-width: 80px !important;
    text-align: right !important;
    display: inline-block !important;
    box-sizing: border-box !important;
    padding: 0 !important;
    overflow: visible !important;
}

/* ============================================ */
/* SEPARATOR LINE                             */
/* ============================================ */

.wc-qd-separator {
    position: relative !important;
    text-align: center !important;
    margin: 15px 0 !important;
    height: 1px !important;
    background: #e0e0e0 !important;
}

.wc-qd-separator span {
    position: relative !important;
    top: -10px !important;
    background: #fff !important;
    padding: 0 10px !important;
    font-size: 12px !important;
    color: #999 !important;
    text-transform: uppercase !important;
    font-weight: 600 !important;
}

/* ============================================ */
/* CUSTOM QUANTITY SECTION - REDESIGNED      */
/* ============================================ */

.wc-qd-custom-section {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
}

.wc-qd-custom-title {
    text-align: center !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #666 !important;
    margin-bottom: 5px !important;
}

.wc-qd-custom-row {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 12px !important;
    background: #f8f9fa !important;
    border: 2px dashed #ddd !important;
    border-radius: 6px !important;
    transition: all 0.3s ease !important;
    flex-wrap: wrap !important;
}

.wc-qd-custom-row:hover {
    border-color: var(--qd-primary-color) !important;
    background: #fff9f0 !important;
}

input.wc-qd-custom-input,
.wc-qd-custom-row input.wc-qd-custom-input {
    width: 100px !important;
    flex-shrink: 0 !important;
}

.wc-qd-custom-input::placeholder {
    color: #999 !important;
    font-size: 13px !important;
}

.wc-qd-custom-unit {
    font-size: 14px !important;
    color: #333 !important;
    font-weight: 500 !important;
    flex-shrink: 0 !important;
}

/* ============================================ */
/* CUSTOM FEEDBACK BADGE - FIXED OVERFLOW     */
/* ============================================ */

.wc-qd-custom-feedback {
    font-size: 12px !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
    padding: 3px 10px !important;
    border-radius: 10px !important;
    background: #f0f0f0 !important;
    color: #666 !important;
    flex-basis: 100% !important;
    text-align: center !important;
    margin-left: 0 !important;
    margin-top: 8px !important;
}

.wc-qd-custom-feedback.has-discount {
    background: #d4edda !important;
    color: #155724 !important;
    border: 1px solid #c3e6cb !important;
}

/* ============================================ */
/* PRICE SUMMARY                              */
/* ============================================ */

.wc-qd-price-summary {
    display: none;
    background: #f8f9fa !important;
    padding: 16px !important;
    border-radius: 6px !important;
    margin-bottom: 16px !important;
    border: 1px solid #e0e0e0 !important;
    opacity: 0 !important;
    transition: none !important;
}

.wc-qd-price-summary.visible {
    display: block !important;
    opacity: 1 !important;
}

.wc-qd-price-summary-title {
    font-size: 14px !important;
    color: #666 !important;
    margin-bottom: 8px !important;
}

.wc-qd-price-amount {
    font-size: 24px !important;
    font-weight: bold !important;
    color: #FF8C00 !important;
    margin-bottom: 8px !important;
}

.wc-qd-price-amount .woocommerce-Price-amount {
    font-size: inherit !important;
    color: #FF8C00 !important;
}

.wc-qd-price-amount .woocommerce-Price-amount bdi {
    color: #FF8C00 !important;
}

.wc-qd-price-amount * {
    color: #FF8C00 !important;
}

.wc-qd-price-details {
    font-size: 12px !important;
    color: #666 !important;
    line-height: 1.5 !important;
}

/* ============================================ */
/* ACTION BUTTONS CONTAINER                   */
/* ============================================ */

.wc-qd-action-buttons {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    width: 100% !important;
}

.wc-qd-action-buttons-container .wc-qd-btn,
.wc-qd-discount-box .wc-qd-btn,
button.wc-qd-btn-add,
button.wc-qd-btn-checkout,
button.wc-qd-btn-continue {
    width: 100% !important;
    padding: 14px 20px !important;
    background: var(--qd-button-bg) !important;
    color: var(--qd-button-text) !important;
    border: none !important;
    border-radius: 6px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    text-decoration: none !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    line-height: normal !important;
    font-family: inherit !important;
    margin: 0 !important;
    text-align: center !important;
}

.wc-qd-action-buttons-container .wc-qd-btn:hover,
button.wc-qd-btn-add:hover,
button.wc-qd-btn-checkout:hover,
button.wc-qd-btn-continue:hover {
    filter: brightness(0.9) !important;
    transform: translateY(-1px) !important;
}

.wc-qd-btn:active {
    transform: translateY(0) !important;
}

.wc-qd-btn.loading {
    opacity: 0.7 !important;
    pointer-events: none !important;
}

.wc-qd-btn.loading::after {
    content: " ⏳" !important;
}

.wc-qd-btn.success {
    animation: successPulse 0.6s ease !important;
}

@keyframes successPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* ============================================ */
/* NOTICES                                    */
/* ============================================ */

.wc-qd-notice,
.wc-qd-button-notice {
    margin-top: 12px !important;
    padding: 10px 12px !important;
    border-radius: 6px !important;
    font-size: 13px !important;
    text-align: center !important;
    animation: slideDown 0.3s ease !important;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wc-qd-notice.success,
.wc-qd-button-notice.success {
    background: #d4edda !important;
    color: #155724 !important;
    border: 1px solid #c3e6cb !important;
}

.wc-qd-notice.error,
.wc-qd-button-notice.error {
    background: #f8d7da !important;
    color: #721c24 !important;
    border: 1px solid #f5c6cb !important;
}

/* ============================================ */
/* SIMPLE QUANTITY INPUT (No Discount)        */
/* ============================================ */

.wc-qd-simple-quantity-wrapper {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 15px !important;
    background: #f8f9fa !important;
    border: 2px solid #e0e0e0 !important;
    border-radius: 6px !important;
    margin-bottom: 15px !important;
}

.wc-qd-simple-qty-label {
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #333 !important;
    margin: 0 !important;
}

.wc-qd-simple-quantity-input {
    width: 80px !important;
    height: 40px !important;
    padding: 8px !important;
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    text-align: center !important;
    font-size: 16px !important;
    background: white !important;
    color: #333 !important;
    font-weight: 500 !important;
}

.wc-qd-simple-quantity-input:focus {
    outline: 2px solid var(--qd-primary-color) !important;
    border-color: var(--qd-primary-color) !important;
}

.wc-qd-simple-qty-unit {
    font-size: 14px !important;
    color: #666 !important;
    font-weight: 500 !important;
}

/* ============================================ */
/* RESPONSIVE - MOBILE & TABLET               */
/* CRITICAL FIX: EXTENDED TO 1200PX           */
/* ============================================ */

@media (max-width: 1200px) {
    /* Reset summary container */
    .summary.entry-summary,
    body.single-product .summary.entry-summary,
    body.woocommerce div.product div.summary.entry-summary {
        min-height: 0 !important;
        overflow: visible !important;
    }
    
    /* FORCE: Both containers to relative positioning */
    .wc-qd-inline-container,
    .wc-qd-action-buttons-container,
    body.single-product .wc-qd-inline-container,
    body.single-product .wc-qd-action-buttons-container,
    body.woocommerce .wc-qd-inline-container,
    body.woocommerce .wc-qd-action-buttons-container,
    .summary.entry-summary .wc-qd-inline-container,
    .summary.entry-summary .wc-qd-action-buttons-container,
    body.single-product .summary.entry-summary .wc-qd-inline-container,
    body.single-product .summary.entry-summary .wc-qd-action-buttons-container {
        position: relative !important;
        top: 0 !important;
        right: 0 !important;
        left: 0 !important;
        bottom: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 0 20px 0 !important;
        float: none !important;
        transform: none !important;
    }
    
    /* Ensure discount box appears ABOVE buttons */
    .wc-qd-inline-container,
    body.single-product .wc-qd-inline-container {
        display: block !important;
        visibility: visible !important;
        z-index: 1 !important;
        order: 1 !important;
    }
    
    /* Ensure action buttons appear BELOW discount box */
    .wc-qd-action-buttons-container,
    body.single-product .wc-qd-action-buttons-container {
        display: block !important;
        visibility: visible !important;
        z-index: 1 !important;
        order: 2 !important;
        margin-top: 20px !important;
    }
    
    /* FIX: Badge overflow on mobile/tablet */
    .wc-qd-radio-row {
        flex-wrap: wrap !important;
        position: relative !important;
    }
    
    .wc-qd-radio-row span.wc-qd-savings-badge,
    span.wc-qd-savings-badge {
        width: auto !important;
        min-width: auto !important;
        max-width: none !important;
        margin-left: 0 !important;
        flex-basis: 100% !important;
        text-align: center !important;
        margin-top: 8px !important;
        padding: 4px 8px !important;
        background: #e8f5e9 !important;
        border-radius: 4px !important;
    }
    
    /* Adjust label width on mobile */
    .wc-qd-radio-row label.wc-qd-package-text,
    label.wc-qd-package-text {
        flex: 1 1 auto !important;
        min-width: 80px !important;
        max-width: none !important;
    }
    
    /* Reset all product info to full width */
    .summary.entry-summary > *:not(.wc-qd-inline-container):not(.wc-qd-action-buttons-container),
    .summary.entry-summary .product_title,
    .summary.entry-summary .price,
    .summary.entry-summary .woocommerce-product-details__short-description,
    .summary.entry-summary .product_meta,
    .summary.entry-summary p,
    .summary.entry-summary h1,
    .summary.entry-summary h2,
    .summary.entry-summary .varetitel-flere-linjer,
    body.single-product .summary.entry-summary > *:not(.wc-qd-inline-container):not(.wc-qd-action-buttons-container),
    body.single-product .summary.entry-summary .product_title,
    body.single-product .summary.entry-summary .price {
        max-width: 100% !important;
        width: 100% !important;
    }
    
    /* Smaller custom input on tablet/mobile */
    input.wc-qd-custom-input,
    .wc-qd-custom-row input.wc-qd-custom-input {
        width: 80px !important;
    }
    
    /* Smaller simple quantity input on tablet/mobile */
    .wc-qd-simple-quantity-input {
        width: 70px !important;
        height: 38px !important;
        font-size: 15px !important;
    }
}

/* ============================================ */
/* PRINT                                      */
/* ============================================ */

@media print {
    .wc-qd-inline-container,
    .wc-qd-action-buttons-container {
        display: none !important;
    }
}

/* ============================================ */
/* ACCESSIBILITY                              */
/* ============================================ */

.wc-qd-radio-row input[type="radio"]:focus {
    outline: 3px solid var(--qd-primary-color) !important;
    outline-offset: 2px !important;
}

.wc-qd-quantity-input:focus {
    outline: 2px solid var(--qd-primary-color) !important;
}

.wc-qd-btn:focus {
    outline: 3px solid rgba(255, 165, 0, 0.5) !important;
    outline-offset: 2px !important;
}

/* ============================================ */
/* BOX SIZING                                 */
/* ============================================ */

.wc-qd-inline-container *,
.wc-qd-action-buttons-container * {
    box-sizing: border-box !important;
}

/* ============================================ */
/* THEME COMPATIBILITY                        */
/* ============================================ */

body.woocommerce div.product .wc-qd-inline-container,
body.woocommerce div.product .wc-qd-action-buttons-container {
    /* Keep absolute positioning from main rules on desktop */
}

body.single-product .summary.entry-summary {
    display: block !important;
}

body.single-product .wc-qd-inline-container,
body.single-product .wc-qd-action-buttons-container {
    position: absolute !important;
    display: block !important;
}

/* OVERRIDE for tablet/mobile - must come after desktop rules */
@media (max-width: 1200px) {
    body.single-product .wc-qd-inline-container,
    body.single-product .wc-qd-action-buttons-container {
        position: relative !important;
    }
}