/**
 * Pack Selector - sell by piece, box or pallet
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License 3.0 (AFL-3.0)
 * that is bundled with this package in the file LICENSE.md.
 * It is also available through the world-wide-web at this URL:
 * https://opensource.org/licenses/AFL-3.0
 *
 * @author    VibeModules
 * @copyright 2026 VibeModules
 * @license   https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
 */

/* Driven by the CSS custom property --qd-accent, set from the module settings.
   Compatible with any PrestaShop 1.7 / 8 / 9 theme. */

.qd-block {
    --qd-accent: #D84A1B;
    --qd-accent-8: color-mix(in srgb, var(--qd-accent) 8%, transparent);
    --qd-accent-12: color-mix(in srgb, var(--qd-accent) 12%, transparent);
    --qd-border: #e5e7eb;
    --qd-disabled-bg: #f3f4f6;
    --qd-disabled-text: #9ca3af;
    --qd-savings-bg: #dcfce7;
    --qd-savings-text: #166534;
    --qd-oos-bg: #fee2e2;
    --qd-oos-text: #991b1b;
    --qd-radius: 8px;
    --qd-transition: 0.15s ease;

    margin: 0.75rem 0 1.25rem;
    font-family: inherit;
    box-sizing: border-box;
}

/* Fallback for browsers without color-mix (Safari < 16.2, Firefox < 113).
   These values match the default accent. When the merchant picked another accent,
   front.js overrides both properties with the matching rgba() on these browsers. */
@supports not (color: color-mix(in srgb, red 8%, transparent)) {
    .qd-block {
        --qd-accent-8: rgba(216, 74, 27, 0.08);
        --qd-accent-12: rgba(216, 74, 27, 0.12);
    }
}

/* Label */
.qd-label {
    margin: 0 0 8px;
    padding: 0;
    font-size: 13px;
    font-weight: 500;
    color: #6b7280;
    line-height: 1.4;
}

/* List */
.qd-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    padding: 0;
}

/* Option */
.qd-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid var(--qd-border);
    border-radius: var(--qd-radius);
    cursor: pointer;
    user-select: none;
    transition: border-color var(--qd-transition), background-color var(--qd-transition);
    position: relative;
    box-sizing: border-box;
}

.qd-option:hover:not(.qd-option--disabled) {
    border-color: var(--qd-accent);
    background-color: var(--qd-accent-8);
}

.qd-option:focus-visible {
    outline: 2px solid var(--qd-accent);
    outline-offset: 1px;
}

/* Selected */
.qd-option--selected {
    border: 1.5px solid var(--qd-accent) !important;
    background-color: var(--qd-accent-8) !important;
}

/* Unavailable, out of stock */
.qd-option--disabled {
    background: var(--qd-disabled-bg) !important;
    border-color: var(--qd-border) !important;
    cursor: not-allowed;
    opacity: 0.65;
}

/* Radio */
.qd-radio {
    width: 16px;
    height: 16px;
    min-width: 16px;
    border-radius: 50%;
    border: 1.5px solid var(--qd-border);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color var(--qd-transition);
    box-sizing: border-box;
    flex-shrink: 0;
}

.qd-option--selected .qd-radio {
    border-color: var(--qd-accent);
}

.qd-option--disabled .qd-radio {
    border-color: var(--qd-disabled-text);
}

.qd-radio__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--qd-accent);
    transform: scale(0);
    transition: transform var(--qd-transition);
    flex-shrink: 0;
}

.qd-option--selected .qd-radio__dot {
    transform: scale(1);
}

/* Name */
.qd-option__name {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    color: #111827;
    line-height: 1.3;
}

.qd-option--disabled .qd-option__name {
    color: var(--qd-disabled-text);
}

/* Price */
.qd-option__price {
    font-size: 13px;
    font-weight: 600;
    color: var(--qd-accent);
    white-space: nowrap;
    flex-shrink: 0;
}

.qd-option--disabled .qd-option__price {
    color: var(--qd-disabled-text);
}

/* Savings badge */
.qd-badge {
    font-size: 11px;
    font-weight: 600;
    background: var(--qd-savings-bg);
    color: var(--qd-savings-text);
    border-radius: 20px;
    padding: 2px 8px;
    white-space: nowrap;
    flex-shrink: 0;
    line-height: 1.5;
}

/* Unavailable badge */
.qd-out-of-stock {
    font-size: 11px;
    font-weight: 500;
    background: var(--qd-oos-bg);
    color: var(--qd-oos-text);
    border-radius: 20px;
    padding: 2px 8px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Total price */
.qd-total {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px;
    margin: 10px 0 0;
    font-size: 13px;
    color: #6b7280;
    padding: 0;
    line-height: 1.5;
}

.qd-total__value {
    font-size: 17px;
    font-weight: 700;
    color: var(--qd-accent);
    transition: color 0.1s;
}

/* Responsive.
   Kept in this position on purpose: the .qd-option__cart base rule below follows
   it, exactly as in the previous release, so the rendering is unchanged. */
@media (max-width: 600px) {
    .qd-option {
        flex-wrap: wrap;
        padding: 10px 12px;
        gap: 6px;
    }
    .qd-radio {
        flex-shrink: 0;
    }
    .qd-option__name {
        font-size: 12px;
        flex: 1 1 calc(100% - 30px);
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    .qd-option__price {
        font-size: 12px;
        margin-left: 26px;
    }
    .qd-badge,
    .qd-out-of-stock {
        font-size: 10px;
        padding: 1px 6px;
    }
    .qd-option__cart {
        margin-left: auto;
        font-size: 11px;
        padding: 5px 10px;
    }
    .qd-total__value {
        font-size: 15px;
    }
}

/* Button inside a package row */
.qd-option__cart {
    margin-left: auto;
    flex-shrink: 0;
    padding: 5px 12px;
    background: var(--qd-accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: filter var(--qd-transition);
}

.qd-option__cart:hover {
    filter: brightness(1.12);
}

.qd-option--disabled .qd-option__cart {
    display: none;
}

/* ----------------------------------------------------------------------------
   Cart suggestion: the same quantity for less as a package
   ------------------------------------------------------------------------- */
.qd-swap {
    /* Declared here as well: the custom properties above live on .qd-block, and
       this box is not inside it. The template overrides the accent inline. */
    --qd-accent: #D84A1B;
    --qd-transition: 0.15s ease;

    margin: 18px 0;
    padding: 14px 16px;
    border: 1px solid var(--qd-accent);
    border-radius: 8px;
    background: #fff;
}

.qd-swap__title {
    margin: 0 0 10px;
    font-size: 15px;
    font-weight: 700;
    color: var(--qd-accent);
}

.qd-swap__item {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding: 8px 0;
    border-top: 1px solid #eee;
}

.qd-swap__item:first-of-type {
    border-top: none;
}

.qd-swap__body {
    flex: 1 1 260px;
    min-width: 0;
}

.qd-swap__name {
    font-weight: 600;
    font-size: 14px;
}

.qd-swap__text,
.qd-swap__totals {
    font-size: 13px;
    color: #555;
}

.qd-swap__saving {
    display: inline-block;
    margin-top: 4px;
    font-size: 13px;
    font-weight: 700;
    color: #2e7d32;
}

.qd-swap__badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 10px;
    background: #2e7d32;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

.qd-swap__button {
    flex-shrink: 0;
    padding: 8px 16px;
    background: var(--qd-accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: filter var(--qd-transition);
}

.qd-swap__button:hover {
    filter: brightness(1.12);
}

.qd-swap__button[disabled] {
    opacity: .6;
    cursor: default;
}

.qd-swap__error {
    margin-top: 8px;
    font-size: 13px;
    color: #c62828;
}
