/* === 阿翔電商折扣 加價購 widget === */
.pd-addon-section {
    --pd-addon-accent: var(--theme-button-background-initial-color, #2f7d64);
    --pd-addon-accent-soft: #eaf7f1;
    --pd-addon-border: var(--theme-section-border-color, #e2e8f0);
    --pd-addon-heading: var(--ys-text-heading, #172033);
    --pd-addon-text: var(--ys-text-primary, #334155);
    --pd-addon-muted: var(--ys-text-secondary, #64748b);
    background: var(--section-bg-color, #ffffff);
    border: 1px solid var(--pd-addon-border);
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
    color: var(--pd-addon-text);
    font-size: 14px;
    line-height: 1.5;
    margin: 22px 0;
    padding: 0;
    overflow: hidden;
}
.pd-addon-section,
.pd-addon-section * {
    box-sizing: border-box;
}
.pd-addon-section-head {
    align-items: flex-start;
    background: linear-gradient(180deg, #fbfefd 0%, #f8fafc 100%);
    border-bottom: 1px solid var(--pd-addon-border);
    display: flex;
    gap: 14px;
    justify-content: space-between;
    padding: 14px 16px;
}
.pd-addon-section-eyebrow {
    color: var(--pd-addon-accent);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 4px;
}
.pd-addon-section-title {
    border: 0;
    color: var(--pd-addon-heading);
    font-size: 16px;
    font-weight: 700;
    line-height: 1.25;
    margin: 0;
    padding: 0;
}
.pd-addon-section-count {
    align-items: center;
    background: #ffffff;
    border: 1px solid #dbe7e1;
    border-radius: 999px;
    color: var(--pd-addon-accent);
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    min-height: 26px;
    padding: 6px 10px;
    white-space: nowrap;
}
.pd-addon-list {
    display: grid;
    gap: 0;
}

.pd-addon-card {
    align-items: start;
    background: #ffffff;
    border: 0;
    border-bottom: 1px solid var(--pd-addon-border);
    cursor: pointer;
    display: grid;
    gap: 12px;
    grid-template-columns: 24px 78px minmax(0, 1fr);
    margin: 0;
    padding: 14px 16px;
    position: relative;
    transition: background 0.18s ease, box-shadow 0.18s ease;
}
.pd-addon-card:last-child {
    border-bottom: 0;
}
.pd-addon-card:hover {
    background: #fbfefd;
}
.pd-addon-card.is-selected,
.pd-addon-card:has(input:checked) {
    background: var(--pd-addon-accent-soft);
    box-shadow: inset 3px 0 0 var(--pd-addon-accent);
}
.pd-addon-card.is-disabled {
    cursor: not-allowed;
    opacity: 0.56;
}
.pd-addon-card.is-disabled:hover {
    background: #ffffff;
}
.pd-addon-check {
    align-self: center;
    cursor: inherit;
    display: inline-flex;
    height: 24px;
    line-height: 1;
    margin: 0;
    position: relative;
    width: 24px;
}
.pd-addon-card input[type="checkbox"] {
    height: 1px;
    margin: 0;
    opacity: 0;
    overflow: hidden;
    position: absolute;
    width: 1px;
}
.pd-addon-check__box {
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    border-radius: 999px;
    display: inline-flex;
    height: 22px;
    position: relative;
    transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
    width: 22px;
}
.pd-addon-check__box::before {
    border: solid #ffffff;
    border-width: 0 2px 2px 0;
    content: "";
    height: 8px;
    left: 7px;
    opacity: 0;
    position: absolute;
    top: 4px;
    transform: rotate(45deg) scale(0.75);
    transition: opacity 0.18s ease, transform 0.18s ease;
    width: 4px;
}
.pd-addon-card input[type="checkbox"]:focus-visible + .pd-addon-check__box {
    box-shadow: 0 0 0 3px rgba(47, 125, 100, 0.18);
}
.pd-addon-card input[type="checkbox"]:checked + .pd-addon-check__box {
    background: var(--pd-addon-accent);
    border-color: var(--pd-addon-accent);
}
.pd-addon-card input[type="checkbox"]:checked + .pd-addon-check__box::before {
    opacity: 1;
    transform: rotate(45deg) scale(1);
}
.pd-addon-card input[type="checkbox"]:disabled + .pd-addon-check__box {
    background: #f1f5f9;
    border-color: #dbe3ec;
}
.pd-addon-thumb {
    background: #f1f5f9;
    border-radius: 8px;
    height: 78px;
    overflow: hidden;
    position: relative;
    width: 78px;
}
.pd-addon-thumb img {
    display: block;
    height: 100%;
    object-fit: cover;
    width: 100%;
}
.pd-addon-thumb-badge {
    background: rgba(15, 23, 42, 0.78);
    border-radius: 999px;
    bottom: 6px;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    left: 6px;
    line-height: 1;
    padding: 4px 7px;
    position: absolute;
}
.pd-addon-info {
    min-width: 0;
}
.pd-addon-title {
    color: var(--pd-addon-heading);
    display: -webkit-box;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.45;
    margin: 0 0 7px;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}
.pd-addon-price {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 8px;
    margin: 0 0 8px;
}
.pd-addon-price-label {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 999px;
    color: #9a3412;
    display: inline-flex;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    padding: 4px 7px;
}
.pd-addon-price del {
    color: #94a3b8;
    font-size: 12px;
}
.pd-addon-special {
    color: #c2410c;
    font-size: 16px;
    font-variant-numeric: tabular-nums;
    font-weight: 800;
}
.pd-addon-saving {
    background: #ecfdf5;
    border: 1px solid #bbf7d0;
    border-radius: 999px;
    color: #047857;
    display: inline-flex;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    padding: 4px 7px;
}
.pd-addon-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 9px;
}
.pd-addon-meta span {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    color: var(--pd-addon-muted);
    display: inline-flex;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    padding: 4px 7px;
}
.pd-addon-controls {
    align-items: end;
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin: 9px 0 0;
}
.pd-addon-variation-field,
.pd-addon-quantity-field {
    color: var(--pd-addon-muted);
    display: flex;
    flex-direction: column;
    font-size: 12px;
    font-weight: 600;
    gap: 5px;
    line-height: 1.3;
    margin: 0;
}
.pd-addon-variation-field {
    flex: 1 1 210px;
}
.pd-addon-quantity-field {
    flex: 0 0 92px;
}
.pd-addon-variation-select,
.pd-addon-qty {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    color: #0f172a;
    font-size: 13px;
    min-height: 36px;
    outline: none;
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.pd-addon-variation-select {
    width: 100%;
}
.pd-addon-qty {
    padding: 4px 9px;
    width: 100%;
}
.pd-addon-variation-select:focus,
.pd-addon-qty:focus {
    border-color: var(--pd-addon-accent);
    box-shadow: 0 0 0 3px rgba(47, 125, 100, 0.12);
}
.pd-addon-variation-select:disabled,
.pd-addon-qty:disabled {
    background: #f8fafc;
    color: #94a3b8;
}
.pd-addon-details-btn {
    align-items: center;
    background: transparent;
    border: 0;
    color: var(--pd-addon-accent);
    cursor: pointer;
    display: inline-flex;
    font-size: 12px;
    font-weight: 700;
    gap: 5px;
    margin: 9px 0 0;
    padding: 0;
    text-decoration: none;
}
.pd-addon-details-btn::after {
    content: "›";
    font-size: 16px;
    line-height: 1;
}
.pd-addon-details-btn:hover {
    color: #16624d;
}

/* === Detail modal (<dialog>) === */
.pd-addon-modal {
    background: #ffffff;
    border: none;
    border-radius: 10px;
    box-shadow: 0 28px 72px rgba(15, 23, 42, 0.28);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    max-width: 680px;
    overflow: hidden;
    padding: 0;
    position: relative;
    width: calc(100% - 32px);
}
.pd-addon-modal::backdrop {
    background: rgba(15, 23, 42, 0.56);
    backdrop-filter: blur(2px);
}
.pd-addon-modal-close {
    align-items: center;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    color: #334155;
    cursor: pointer;
    display: inline-flex;
    font-size: 20px;
    font-weight: 400;
    height: 34px;
    justify-content: center;
    line-height: 1;
    padding: 0;
    position: absolute;
    right: 14px;
    top: 14px;
    width: 34px;
    z-index: 2;
}
.pd-addon-modal-close:hover {
    background: #f8fafc;
    color: #0f172a;
}
.pd-addon-modal-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 0;
}
.pd-addon-detail-header {
    border-bottom: 1px solid #edf2f7;
    display: grid;
    gap: 18px;
    grid-template-columns: 180px minmax(0, 1fr);
    padding: 24px;
}
.pd-addon-detail-header img {
    background: #f1f5f9;
    border-radius: 8px;
    display: block;
    height: 180px;
    object-fit: cover;
    width: 180px;
}
.pd-addon-detail-header h3 {
    color: #111827;
    font-size: 19px;
    font-weight: 700;
    line-height: 1.35;
    margin: 0 42px 9px 0;
}
.pd-addon-detail-price {
    align-items: baseline;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 10px;
}
.pd-addon-detail-price del {
    color: #94a3b8;
    font-size: 13px;
}
.pd-addon-detail-price strong {
    color: #c2410c;
    font-size: 18px;
    font-variant-numeric: tabular-nums;
    font-weight: 800;
}
.pd-addon-detail-excerpt {
    color: #475569;
    font-size: 13px;
    line-height: 1.65;
}
.pd-addon-detail-body {
    color: #334155;
    font-size: 14px;
    line-height: 1.72;
    padding: 20px 24px 24px;
}
.pd-addon-detail-body img {
    height: auto;
    max-width: 100%;
}
.pd-addon-modal-footer {
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    bottom: 0;
    flex-shrink: 0;
    padding: 14px 24px;
    position: sticky;
}
.pd-addon-modal-footer .pd-addon-confirm {
    background: var(--theme-button-background-initial-color, #2f7d64);
    border: 0;
    border-radius: 8px;
    color: #ffffff;
    font-size: 15px;
    font-weight: 700;
    min-height: 44px;
    padding: 12px 16px;
    width: 100%;
}
.pd-addon-modal-footer .pd-addon-confirm:hover {
    background: var(--theme-button-background-hover-color, #24644f);
}

/* Fallback for browsers without <dialog> */
.pd-addon-modal-fallback {
    left: 50%;
    position: fixed;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 99999;
}

.pd-addon-fixed-qty {
    background: #f1f5f9;
    border-radius: 8px;
    color: #64748b;
    display: inline-block;
    font-weight: 700;
    min-width: 36px;
    padding: 7px 12px;
    text-align: center;
}

@media (max-width: 600px) {
    .pd-addon-section-head {
        gap: 10px;
        padding: 13px 14px;
    }
    .pd-addon-card {
        gap: 10px;
        grid-template-columns: 24px 64px minmax(0, 1fr);
        padding: 13px 14px;
    }
    .pd-addon-thumb {
        height: 64px;
        width: 64px;
    }
    .pd-addon-controls {
        align-items: stretch;
    }
    .pd-addon-variation-field,
    .pd-addon-quantity-field {
        flex: 1 1 100%;
    }
    .pd-addon-detail-header {
        grid-template-columns: 1fr;
        padding: 20px;
        text-align: left;
    }
    .pd-addon-detail-header img {
        height: auto;
        max-height: 260px;
        width: 100%;
    }
    .pd-addon-detail-header h3 {
        margin-right: 42px;
    }
    .pd-addon-detail-body {
        padding: 18px 20px 22px;
    }
    .pd-addon-modal-footer {
        padding: 12px 20px;
    }
}
