/* ===== Elementor / WooCommerce Integration ===== */

.elementor-product-ah_sets_builder form.cart,
form.cart:has(.ah-oil-builder-wrapper) {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0 !important;
    width: 100% !important;
}

.elementor-product-ah_sets_builder form.cart .quantity,
form.cart:has(.ah-oil-builder-wrapper) .quantity {
    display: none !important;
}

.elementor-product-ah_sets_builder form.cart .single_add_to_cart_button,
form.cart:has(.ah-oil-builder-wrapper) .single_add_to_cart_button {
    width: 100% !important;
    max-width: 100% !important;
    margin: 14px 0 0 0 !important;
    padding: 13px 24px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    border-radius: 6px !important;
    background: #111 !important;
    color: #fff !important;
    border: none !important;
    transition: opacity 0.2s !important;
    letter-spacing: 0.02em !important;
    box-sizing: border-box !important;
    float: none !important;
    display: block !important;
}

.elementor-product-ah_sets_builder form.cart .single_add_to_cart_button:hover,
form.cart:has(.ah-oil-builder-wrapper) .single_add_to_cart_button:hover {
    opacity: 0.85 !important;
}

.elementor-add-to-cart.elementor-product-ah_sets_builder,
.elementor-widget-woocommerce-product-add-to-cart:has(.ah-oil-builder-wrapper) {
    width: 100% !important;
    padding: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

form.cart:has(.ah-oil-builder-wrapper) > * {
    max-width: 100% !important;
}

/* Hide default WooCommerce price — builder shows its own */
.product-type-ah_sets_builder .elementor-widget-woocommerce-product-price .price,
.product-type-ah_sets_builder p.price {
    display: none !important;
}

.single_add_to_cart_button.disabled,
.single_add_to_cart_button:disabled {
    opacity: 0.35 !important;
    cursor: not-allowed !important;
    pointer-events: none;
}

/* ===== Builder Wrapper ===== */
.ah-oil-builder-wrapper {
    margin: 8px 0;
    padding: 0;
    width: 100%;
}

.ah-builder-title {
    font-size: 16px;
    font-weight: 600;
    color: #111;
    margin-bottom: 2px;
    letter-spacing: -0.01em;
}

.ah-builder-description {
    font-size: 12px;
    color: #888;
    margin-bottom: 12px !important;
    line-height: 1.4;
}

.ah-builder-min-note {
    color: #c0392b;
    font-weight: 600;
}

/* ===== Default Product Tile ===== */
.ah-default-product {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 10px;
    background: #f0fdf4;
    border: 1.5px solid #86efac;
    border-radius: 6px;
}

.ah-default-product-image {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

.ah-default-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    border: 1.5px solid #86efac;
}

.ah-default-product-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.ah-default-product-name {
    font-size: 12px;
    font-weight: 600;
    color: #111;
    line-height: 1.3;
}

.ah-default-product-price {
    font-size: 11px;
    color: #555;
    font-weight: 500;
}

.ah-default-product-badge {
    font-size: 10px;
    font-weight: 600;
    color: #065f46;
    background: #d1fae5;
    padding: 3px 8px;
    border-radius: 10px;
    white-space: nowrap;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .ah-default-product {
        gap: 8px;
        padding: 8px 10px;
    }

    .ah-default-product-image {
        width: 40px;
        height: 40px;
    }

    .ah-default-product-name {
        font-size: 11px;
    }

    .ah-default-product-badge {
        font-size: 9px;
        padding: 2px 6px;
    }
}

/* ===== Product Grid ===== */
.ah-oils-grid-wrapper {
    position: relative;
    margin-bottom: 14px;
}

.ah-oils-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 6px;
    max-height: 360px;
    overflow-y: auto;
    padding: 2px;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

.ah-oils-grid::-webkit-scrollbar {
    width: 3px;
}

.ah-oils-grid::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.ah-scroll-fade {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 44px;
    background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255,0.95));
    pointer-events: none;
    transition: opacity 0.3s ease;
    border-radius: 0 0 6px 6px;
}

.ah-scroll-fade.ah-hidden {
    opacity: 0;
}

/* ===== Product Item ===== */
.ah-oil-item {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    transition: all 0.15s ease !important;
    padding: 6px 4px 5px !important;
    border-radius: 6px !important;
    background: transparent !important;
    border: 1.5px solid #eee !important;
    cursor: pointer !important;
    position: relative !important;
    box-sizing: border-box !important;
    gap: 0 !important;
    overflow: visible !important;
}

.ah-oil-item:hover {
    border-color: #ccc;
    background: #fafafa;
}

.ah-oil-item.has-quantity {
    border-color: #111;
    background: #f7f7f7;
}

/* ===== Image ===== */
.ah-oil-image-wrapper {
    position: relative;
    width: 46px;
    height: 46px;
    margin-bottom: 3px;
    cursor: pointer;
    flex-shrink: 0;
}

.ah-oil-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    border: 1.5px solid #e0e0e0;
    transition: border-color 0.15s ease;
}

.ah-oil-item.has-quantity .ah-oil-image {
    border-color: #111;
}

.ah-oil-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #222;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    font-weight: 700;
}

/* ===== Name & Price ===== */
.ah-oil-name {
    font-size: 9.5px;
    font-weight: 600;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.25;
    min-height: 24px;
    max-width: 100%;
    word-break: break-word;
}

.ah-oil-price {
    font-size: 9px;
    color: #999;
    margin-bottom: 3px;
    font-weight: 500;
}

/* ===== Quantity Controls ===== */
.ah-oil-quantity-wrapper {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    background: #fff !important;
    border: 1.5px solid #ddd !important;
    border-radius: 20px !important;
    padding: 0 2px !important;
    margin-top: auto !important;
    gap: 0 !important;
    width: auto !important;
    min-width: 56px !important;
    height: 22px !important;
    box-sizing: border-box !important;
    overflow: visible !important;
}

.ah-oil-item.has-quantity .ah-oil-quantity-wrapper {
    border-color: #111 !important;
    background: #f5f5f5 !important;
}

.ah-qty-btn {
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    min-height: 20px !important;
    max-width: 20px !important;
    max-height: 20px !important;
    border: none !important;
    background: transparent !important;
    color: #888 !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
    transition: color 0.15s, background 0.15s !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 1 !important;
    box-shadow: none !important;
    outline: none !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
}

.ah-qty-btn:hover {
    color: #111 !important;
    background: rgba(0,0,0,0.06) !important;
}

.ah-qty-btn:focus {
    outline: none !important;
    box-shadow: none !important;
}

.ah-oil-quantity {
    width: 18px !important;
    min-width: 18px !important;
    max-width: 18px !important;
    height: 20px !important;
    text-align: center !important;
    border: none !important;
    background: transparent !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    color: #111 !important;
    margin: 0 !important;
    padding: 0 !important;
    min-height: 0 !important;
    line-height: 20px !important;
    -moz-appearance: textfield !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    box-shadow: none !important;
    outline: none !important;
    border-radius: 0 !important;
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
}

.ah-oil-quantity:focus {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
}

.ah-oil-quantity::-webkit-inner-spin-button,
.ah-oil-quantity::-webkit-outer-spin-button {
    -webkit-appearance: none !important;
    appearance: none !important;
    margin: 0 !important;
    display: none !important;
    height: 0 !important;
    width: 0 !important;
    opacity: 0 !important;
}

input[type="number"].ah-oil-quantity {
    -moz-appearance: textfield !important;
    -webkit-appearance: textfield !important;
    appearance: textfield !important;
}

/* ===== Requirement Notice ===== */
.ah-builder-requirement {
    padding: 7px 10px;
    margin-bottom: 10px;
    background: #fff5f5;
    border: 1px solid #fed7d7;
    color: #c0392b;
    border-radius: 4px;
    font-weight: 500;
    font-size: 11px;
    text-align: center;
}

/* ===== Discount Progress Bar ===== */
.ah-discount-progress {
    margin-bottom: 12px;
    padding: 10px 12px;
    background: #fafafa;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
}

.ah-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    gap: 8px;
}

.ah-progress-text {
    font-size: 11px;
    color: #555;
    line-height: 1.3;
    flex: 1;
}

.ah-progress-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
    flex-shrink: 0;
}

.ah-badge-next {
    background: #fef3c7;
    color: #92400e;
}

.ah-badge-max {
    background: #d1fae5;
    color: #065f46;
}

.ah-progress-bar-track {
    position: relative;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: visible;
    margin-bottom: 16px;
}

.ah-progress-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.4s ease, background 0.4s ease;
    width: 0;
}

.ah-progress-tiers {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.ah-tier-marker {
    position: absolute;
    top: -2px;
    width: 2px;
    height: 12px;
    background: #9ca3af;
    transform: translateX(-50%);
    border-radius: 1px;
    transition: background 0.3s;
}

.ah-tier-marker.reached {
    background: #065f46;
}

.ah-tier-label {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 9px;
    font-weight: 600;
    color: #9ca3af;
    white-space: nowrap;
}

.ah-tier-marker.reached .ah-tier-label {
    color: #065f46;
}

/* ===== Summary Box ===== */
.ah-builder-summary-box {
    background: #fafafa;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    padding: 10px 12px;
}

.ah-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
}

.ah-summary-row:not(:last-child) {
    border-bottom: 1px solid #eee;
}

.ah-summary-label {
    font-size: 12px;
    color: #777;
}

.ah-summary-value {
    font-size: 12px;
    color: #111;
    font-weight: 600;
}

.ah-discount-row {
    color: #059669;
}

.ah-discount-row .ah-summary-label {
    color: #059669;
    font-weight: 700;
}

.ah-discount-value {
    font-weight: 700;
    color: #059669;
}

.ah-total-row {
    padding-top: 8px;
    margin-top: 2px;
    border-top: 1.5px solid #111 !important;
}

.ah-total-row .ah-summary-label strong {
    font-size: 13px;
    color: #111;
}

.ah-total-row .ah-summary-value strong {
    font-size: 16px;
    color: #111;
}

/* ===== Animations ===== */
@keyframes pulse-select {
    0% { transform: scale(1); }
    50% { transform: scale(1.06); }
    100% { transform: scale(1); }
}

.ah-oil-item.added .ah-oil-image {
    animation: pulse-select 0.2s ease;
}

.ah-limit-message {
    z-index: 10000 !important;
    font-size: 13px;
}

/* ===== Mobile ===== */
@media (max-width: 768px) {
    .ah-oils-grid {
        grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
        gap: 4px;
        max-height: 300px;
    }

    .ah-oil-image-wrapper {
        width: 38px;
        height: 38px;
    }

    .ah-oil-name {
        font-size: 8.5px;
        min-height: 21px;
    }

    .ah-oil-price {
        font-size: 8px;
    }

    .ah-builder-title {
        font-size: 14px;
    }

    .ah-builder-description {
        font-size: 11px;
        margin-bottom: 8px !important;
    }

    .ah-summary-label,
    .ah-summary-value {
        font-size: 11px;
    }

    .ah-total-row .ah-summary-value strong {
        font-size: 14px;
    }

}

/* ===== Empty Notice ===== */
.ah-builder-notice {
    padding: 14px;
    background: #fafafa;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    color: #666;
    text-align: center;
    font-weight: 500;
    font-size: 12px;
}

/* Archive/loop discount text */
.ah-sets-loop-discount {
    color: #059669;
    font-size: 13px;
    font-weight: 600;
}

/* ── Packaging Section ─────────────────────────────────────────── */
.ah-packaging-section {
    margin: 16px 0;
    position: relative;
}

.ah-packaging-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: #374151;
}

.ah-packaging-cards {
    display: flex;
    flex-direction: row;
    gap: 10px;
}

.ah-packaging-card {
    flex: 1;
    min-width: 0;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, opacity 0.2s;
    position: relative;
    background: #fff;
    user-select: none;
}

.ah-packaging-card input[type="radio"] {
    display: none !important;
    position: absolute !important;
    width: 0 !important;
    height: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.ah-packaging-card.selected {
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.ah-packaging-card.ah-pkg-disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.ah-pkg-card-inner {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ah-pkg-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 4px;
}

.ah-pkg-card-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #111827;
    flex: 1;
    min-width: 0;
}

.ah-pkg-info-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.3rem;
    color: #6b7280;
    padding: 0;
    line-height: 1;
    transition: color 0.15s;
    flex-shrink: 0;
    pointer-events: auto;
}

.ah-pkg-info-btn:hover {
    color: #10b981;
}

.ah-pkg-card-price {
    font-size: 0.85rem;
    color: #10b981;
    font-weight: 600;
}

.ah-pkg-card-note {
    font-size: 0.75rem;
    color: #9ca3af;
    line-height: 1.3;
}

/* ── Pipette Info ──────────────────────────────────────────────── */
.ah-pipette-info {
    margin-top: 10px;
    padding: 8px 12px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    font-size: 0.88rem;
    color: #15803d;
}

/* ── Packaging Popover ─────────────────────────────────────────── */
.ah-pkg-popover {
    position: absolute;
    z-index: 999;
    top: 0;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
    padding: 16px;
    max-width: 320px;
}

.ah-pkg-popover-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #6b7280;
    line-height: 1;
    padding: 2px 6px;
}

.ah-pkg-popover-close:hover {
    color: #111;
}

.ah-pkg-popover-img {
    text-align: center;
    margin-bottom: 10px;
}

.ah-pkg-popover-img img {
    max-width: 100%;
    max-height: 180px;
    border-radius: 8px;
    object-fit: contain;
}

.ah-pkg-popover-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0 0 6px;
    color: #111827;
}

.ah-pkg-popover-desc {
    font-size: 0.85rem;
    color: #4b5563;
    margin: 0;
    line-height: 1.5;
}
