/*
 * Base styles for advertised-coupon badges: a compact pill (icon + saving) that fits
 * pling-theme's badge block. Uses pling-theme variables with fallbacks; themes override
 * colours/placement (e.g. wildcat21 squares it and positions it below its tile flag).
 */
.pling-coupon-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    box-sizing: border-box;
    max-width: 100%;
    padding: 0.3em 0.8em 0.3em 0.65em;
    border-radius: 999px;
    background-color: var(--color-danger, #f90029);
    color: var(--text-color-on-danger, #fff);
    font-size: var(--font-size-xxs, 0.8rem);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    white-space: nowrap;
}

.pling-coupon-badge[hidden] {
    display: none;
}

.pling-coupon-badge__icon {
    flex: 0 0 auto;
    width: 1.1em;
    height: 1.1em;
}

.pling-coupon-badge__icon svg {
    display: block;
    width: 100%;
    height: 100%;
}

/*
 * PWI tooltip (`pling-tooltip` filter) inside the badge: keep the badge layout, drop PWI's
 * hover lift, and open the tooltip below the badge, left-aligned (the badge sits at the
 * top-left of the tile, so above/centred would be clipped or cover the other flags).
 */
.pling-coupon-badge .tooltip-box {
    display: inline-flex;
    align-items: center;
    gap: inherit;
    font-size: inherit;
    line-height: inherit;
    border-radius: 0;
}

.pling-coupon-badge .tooltip-box:hover {
    transform: none;
    box-shadow: none;
}

.pling-coupon-badge .tooltip-box[title]:hover::after {
    top: 100%;
    bottom: auto;
    left: 0;
    transform: none;
    margin: 8px 0 0 calc(-1 * var(--spacing-02, 8px));
    font-family: inherit;
    font-weight: normal;
    letter-spacing: normal;
    text-transform: none;
}

.pling-coupon-badge .tooltip-box[title]:hover::before {
    top: 100%;
    bottom: auto;
    left: 4px;
    transform: none;
    border-top-color: transparent;
    border-bottom-color: rgba(0, 0, 0, 0.7);
}

/*
 * pling-theme: the badge sits in the tile's bottom badge block next to PWI's savings label
 * (.sale-label, "Save 31%") and looks exactly like it. The block spaces its items apart; the
 * auto margin keeps savings + coupon together on the left and the volume-pricing label right.
 */
.badge-block-bottom .pling-coupon-badge {
    gap: 0.35em;
    margin-right: auto;
    padding: var(--spacing-01, 4px) var(--spacing-03, 12px);
    border-radius: 8px;
    background-color: transparent;
    background-image: linear-gradient(135deg, #B71C1C, #E53935); /* = PWI saving-label.scss */
    color: #fff;
    font-size: var(--font-size-xxs, 0.714rem);
    font-weight: inherit;
    /* .sale-label is an inline span: its box is the font's content area (~1.2em), not its
       line-height, so the same line-height here would come out 1px lower. */
    line-height: 1.2;
    letter-spacing: normal;
    text-transform: none;
}

/* Near the bottom of the image: open the tooltip upwards. */
.badge-block-bottom .pling-coupon-badge .tooltip-box[title]:hover::after {
    top: auto;
    bottom: 100%;
    margin: 0 0 8px calc(-1 * var(--spacing-03, 12px));
}

.badge-block-bottom .pling-coupon-badge .tooltip-box[title]:hover::before {
    top: auto;
    bottom: 100%;
    border-bottom-color: transparent;
    border-top-color: rgba(0, 0, 0, 0.7);
}

/*
 * PDP box: two columns. Left: "Save -20% with code X" (may wrap) + small meta line
 * (urgency, minimum order). Right: "Apply" link or state, vertically centred, never wraps below.
 */
.pling-advertised-coupon {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: var(--spacing-03, 12px);
    box-sizing: border-box;
    max-width: 100%;
    margin: var(--spacing-03, 12px) 0;
    padding: var(--spacing-02, 8px) var(--spacing-03, 12px);
    border: 1px dashed var(--color-border, #ccc);
    border-radius: var(--border-radius-width, 5px);
    background: transparent;
    font-size: var(--font-size-s, 0.75rem); /* same size as the payment-method (Klarna) box */
    line-height: 1.35;
}

.pling-advertised-coupon__body {
    min-width: 0;
}

.pling-advertised-coupon__text {
    margin: 0;
    font-size: inherit; /* themes size <p> globally */
    line-height: inherit;
}

/* Code and saving never split (PNG-BLACK must not break at the hyphen); one meta fact per line. */
.pling-advertised-coupon__meta-part {
    display: block;
}

.pling-advertised-coupon__code,
.pling-advertised-coupon__saving,
.pling-advertised-coupon__meta-part {
    white-space: nowrap;
}

.pling-advertised-coupon__saving {
    color: var(--color-danger, #f90029);
}

.pling-advertised-coupon__meta {
    display: block;
    margin-top: 1px;
    font-size: 0.9em;
    line-height: 1.35;
    color: var(--text-color-on-bright-lighten, #717171);
}

.pling-advertised-coupon__action {
    justify-self: end;
    white-space: nowrap;
}

.pling-advertised-coupon__apply,
.pling-advertised-coupon__apply:hover,
.pling-advertised-coupon__apply:focus {
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
    color: inherit;
    font: inherit;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

.pling-advertised-coupon__apply:disabled {
    opacity: 0.5;
    cursor: progress;
}

.pling-advertised-coupon__state {
    font-weight: 700;
    color: var(--color-success, #51bb19);
}

.pling-advertised-coupon__message {
    grid-column: 1 / -1;
    margin-top: 4px;
    font-size: 0.85em;
    color: var(--color-danger, #f90029);
}

.pling-advertised-coupon[hidden],
.pling-advertised-coupon [hidden],
.pling-advertised-coupon__message:empty {
    display: none;
}

/* Mini cart (pling-checkout sidecart): claimed coupon that is not discounting yet. */
.pling-sidecart-cart__applied-coupon--pending .coupon-code {
    opacity: 0.7;
}

.pling-sidecart-cart__applied-coupon--pending .coupon-note {
    margin-left: 0.4em;
    font-size: 0.85em;
    color: var(--text-color-on-bright-lighten, #717171);
}
