/* ==========================================================================
   Codes et avantages — promo code and gift card rows in the payment summary.
   State classes come from booking-campaign-promotion.js and booking-gift-card.js:
   .has-error on a row, .is-invalid on its input, .is-loading on its button.
   Tokens follow the boutique redesign; a salon site frame remaps the accent.
   ========================================================================== */
.booking-codes {
    --codes-accent: var(--bk2-pink, #E50050);
    --codes-accent-dark: var(--bk2-pink-dark, #C10045);
    --codes-on-accent: var(--site-on-primary, #fff);
    --codes-soft: #FFF0F4;
    --codes-soft-line: #F8C9D8;
    --codes-ring: rgba(229, 0, 80, 0.14);
    --codes-line: #e6e8ec;
    --codes-text: #464646;
    --codes-muted: #6b6b6b;
    --codes-placeholder: #939393;
    --codes-error: #B3261E;
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid var(--codes-line);
}

.booking-codes [hidden] { display: none !important; }

.booking-codes__title {
    margin: 4px 0 0;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--codes-muted);
}

.booking-code {
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.booking-code + .booking-code { border-top: 1px solid var(--codes-line); }

/* Disclosure toggle */
.booking-code__toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 44px;
    padding: 8px 0;
    border: 0;
    background: none;
    color: var(--codes-text);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.booking-code__toggle:hover .booking-code__toggle-label { color: var(--codes-accent-dark); }

.booking-code__toggle:focus-visible,
.booking-code__remove:focus-visible,
.booking-code__reset:focus-visible,
.booking-code__apply:focus-visible,
.booking-code__skip:focus-visible {
    outline: 2px solid var(--codes-accent);
    outline-offset: 2px;
}

.booking-code__toggle:focus-visible { border-radius: 8px; }

.booking-code__icon,
.booking-code__chevron {
    flex: none;
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.booking-code__icon { color: var(--codes-accent); }

.booking-code__chevron {
    margin-left: auto;
    color: var(--codes-placeholder);
    stroke-width: 2;
    transition: transform 0.2s ease;
}

.booking-code__toggle[aria-expanded="true"] .booking-code__chevron { transform: rotate(180deg); }

/* Input group: input and its one primary action */
.booking-code__panel { padding: 0 0 10px; }

.booking-code__group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    padding: 4px;
    background: #fff;
    border: 1px solid var(--codes-line);
    border-radius: 12px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.booking-code__group:focus-within {
    border-color: var(--codes-accent);
    box-shadow: 0 0 0 3px var(--codes-ring);
}

.booking-code.has-error .booking-code__group { border-color: var(--codes-error); }
.booking-code.has-error .booking-code__group:focus-within { box-shadow: 0 0 0 3px rgba(179, 38, 30, 0.14); }

.booking-code__input {
    /* Grows far faster than the button, so the button only wraps below when
       the row is too narrow for both, then fills that second line. */
    flex: 999 1 140px;
    min-width: 0;
    height: 40px;
    padding: 0 10px;
    border: 0;
    background: transparent;
    color: #1a1a1a;
    font: inherit;
    font-size: 16px; /* 16px keeps iOS from zooming on focus */
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    outline: none;
    box-shadow: none;
}

.booking-code__input::placeholder {
    color: var(--codes-placeholder);
    font-weight: 400;
    letter-spacing: normal;
    text-transform: none;
}

.booking-code__apply {
    flex: 1 0 auto;
    position: relative;
    min-width: 104px;
    height: 40px;
    padding: 0 16px;
    border: 0;
    border-radius: 10px;
    background: var(--codes-accent);
    color: var(--codes-on-accent);
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.booking-code__apply:hover:not(:disabled) { background: var(--codes-accent-dark); }

.booking-code__apply:disabled { cursor: progress; }

.booking-code__apply.is-loading { color: transparent; }

.booking-code__apply.is-loading::after {
    content: "";
    position: absolute;
    inset: 0;
    width: 18px;
    height: 18px;
    margin: auto;
    border: 2px solid var(--codes-on-accent);
    border-right-color: transparent;
    border-radius: 50%;
    animation: booking-code-spin 0.7s linear infinite;
}

@keyframes booking-code-spin { to { transform: rotate(360deg); } }

.booking-code__reset,
.booking-code__remove {
    flex: none;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--codes-placeholder);
    font: inherit;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.booking-code__reset:hover { color: var(--codes-text); background: #f3f4f6; }

/* Applied chip */
.booking-code__chip {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 100%;
    min-height: 44px;
    margin: 6px 0 10px;
    padding: 2px 4px 2px 12px;
    background: var(--codes-soft);
    border: 1px solid var(--codes-soft-line);
    border-radius: 12px;
    color: var(--codes-accent-dark);
    font-size: 14px;
    font-weight: 700;
}

.booking-code__chip-text {
    min-width: 0;
    overflow-wrap: anywhere;
    letter-spacing: 0.02em;
}

.booking-code__chip-amount:not(:empty)::before {
    content: " · ";
    white-space: pre;
}

.booking-code__remove { color: inherit; }
.booking-code__remove:hover { background: rgba(193, 0, 69, 0.08); }

/* Status, per-service lines and the unavailable-service escape */
.booking-code__status {
    margin: 0 0 10px;
    font-size: 13px;
    line-height: 1.4;
    color: var(--codes-text);
}

.booking-code__status.is-error { color: var(--codes-error); }

.booking-code__lines {
    margin: -4px 0 10px;
    font-size: 12px;
    color: var(--codes-muted);
}

.booking-code__status:empty,
.booking-code__lines:empty { display: none; }

.booking-code__skip {
    align-self: flex-start;
    min-height: 32px;
    margin: -6px 0 8px;
    padding: 4px 0;
    border: 0;
    background: none;
    color: var(--codes-accent-dark);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

.booking-code__sr,
.booking-code__status--sr {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (prefers-reduced-motion: reduce) {
    .booking-code__chevron,
    .booking-code__group,
    .booking-code__apply { transition: none; }
    .booking-code__apply.is-loading::after { animation-duration: 1.6s; }
}
