/* Kobizo Salon Chat Assistant: chat button and panel.

   A calm, neutral chat that sits on any salon theme (same look as kbz-restaurant-assistant): white surfaces, a
   warm grey background, dark text, and the salon's colour only where it means "act" (the button, the visitor's
   messages, Confirm). The colour follows the theme (--primary, --font-body of btd-salon-theme and its children);
   assistant.js darkens a light colour until white text on it is readable (4.5:1). */

.kbz-sa {
    --kbz-sa-accent: var(--primary, #8e6c4d);
    --kbz-sa-on-accent: #fff;
    --kbz-sa-accent-soft: color-mix(in srgb, var(--kbz-sa-accent) 10%, #fff);
    --kbz-sa-accent-ink: color-mix(in srgb, var(--kbz-sa-accent) 70%, #1f1a16);
    --kbz-sa-text: #1f1a16;
    --kbz-sa-muted: #625b54;
    --kbz-sa-bg: #fff;
    --kbz-sa-soft: #efebe6;
    --kbz-sa-border: #ddd7cf;
    --kbz-sa-error: #b3261e;
    --kbz-sa-ok: #2e7d32;
    --kbz-sa-radius: 20px;
    --kbz-sa-font: var(--font-body, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif);
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 9990;
    font-family: var(--kbz-sa-font);
    font-size: 14.5px;
    line-height: 1.5;
    color: var(--kbz-sa-text);
    -webkit-font-smoothing: antialiased;
}

/* Tones: the greys around the chat. Warm is the default above. */
.kbz-sa--neutral {
    --kbz-sa-text: #1b1d21;
    --kbz-sa-muted: #5a5f67;
    --kbz-sa-soft: #eef0f2;
    --kbz-sa-border: #d9dde2;
}

.kbz-sa--cool {
    --kbz-sa-text: #16202a;
    --kbz-sa-muted: #53606c;
    --kbz-sa-soft: #e9eff4;
    --kbz-sa-border: #d2dce5;
}

.kbz-sa *,
.kbz-sa *::before,
.kbz-sa *::after {
    box-sizing: border-box;
}

/* The theme's scroll-to-top button sits where the chat button is: lift it above. */
body.kbz-sa-on .scroll-to-top {
    bottom: 98px;
    right: 27px;
}

.kbz-sa-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;
}

.kbz-sa svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.kbz-sa button,
.kbz-sa a {
    -webkit-tap-highlight-color: transparent;
}

/* --- button ------------------------------------------------------------------------------------- */

.kbz-sa-toggle {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    margin-left: auto;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--kbz-sa-accent);
    color: var(--kbz-sa-on-accent);
    box-shadow: 0 8px 24px rgba(20, 14, 8, .28), 0 2px 6px rgba(20, 14, 8, .18);
    cursor: pointer;
    transition: transform .2s ease, box-shadow .2s ease;
}

.kbz-sa-toggle::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--kbz-sa-accent);
    opacity: 0;
    pointer-events: none;
}

.kbz-sa-toggle.is-new::before {
    animation: kbz-sa-pulse 1.8s ease-out .8s 3;
}

@keyframes kbz-sa-pulse {
    0% { transform: scale(1); opacity: .7; }
    100% { transform: scale(1.55); opacity: 0; }
}

.kbz-sa-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(20, 14, 8, .32), 0 3px 8px rgba(20, 14, 8, .2);
}

.kbz-sa-toggle:focus-visible,
.kbz-sa button:focus-visible,
.kbz-sa a:focus-visible,
.kbz-sa input:focus-visible,
.kbz-sa textarea:focus-visible,
.kbz-sa-log:focus-visible {
    outline: 2px solid var(--kbz-sa-accent);
    outline-offset: 2px;
}

.kbz-sa-toggle svg {
    width: 24px;
    height: 24px;
}

.kbz-sa .kbz-sa-assistant-icon {
    width: 30px;
    height: 30px;
    stroke: none;
    overflow: visible;
}

.kbz-sa-i-bubble {
    fill: currentColor;
}

.kbz-sa-i-spark {
    fill: var(--kbz-sa-accent);
}

.kbz-sa-i-star {
    fill: currentColor;
}

/* "Questions? We are happy to help" next to the button, until the chat has been opened. */
.kbz-sa-teaser {
    position: absolute;
    right: 72px;
    bottom: 12px;
    padding: 9px 14px;
    border: 1px solid var(--kbz-sa-border);
    border-radius: 999px;
    background: #fff;
    color: var(--kbz-sa-text);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    box-shadow: 0 6px 20px rgba(20, 14, 8, .14);
    cursor: pointer;
    animation: kbz-sa-teaser-in .4s ease-out 1.2s both;
}

.kbz-sa-teaser[hidden],
.kbz-sa.is-open .kbz-sa-teaser {
    display: none;
}

@keyframes kbz-sa-teaser-in {
    from { opacity: 0; transform: translateX(8px); }
    to { opacity: 1; transform: none; }
}

/* --- panel -------------------------------------------------------------------------------------- */

.kbz-sa-panel {
    display: flex;
    flex-direction: column;
    width: min(390px, calc(100vw - 40px));
    height: min(680px, calc(100vh - 110px));
    height: min(680px, calc(100dvh - 110px));
    margin-bottom: 14px;
    overflow: hidden;
    border: 1px solid rgba(20, 14, 8, .08);
    border-radius: var(--kbz-sa-radius);
    background: var(--kbz-sa-soft);
    box-shadow: 0 24px 60px rgba(20, 14, 8, .22), 0 4px 14px rgba(20, 14, 8, .08);
    animation: kbz-sa-open .18s ease-out;
}

@keyframes kbz-sa-open {
    from { opacity: 0; transform: translateY(8px) scale(.99); }
    to { opacity: 1; transform: none; }
}

.kbz-sa-panel[hidden] {
    display: none;
}

.kbz-sa-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 10px 12px 14px;
    border-bottom: 1px solid var(--kbz-sa-border);
    background: var(--kbz-sa-bg);
    color: var(--kbz-sa-text);
}

.kbz-sa-avatar {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--kbz-sa-accent);
    color: var(--kbz-sa-on-accent);
}

.kbz-sa .kbz-sa-avatar .kbz-sa-assistant-icon {
    width: 22px;
    height: 22px;
}

.kbz-sa-titles {
    flex: 1;
    min-width: 0;
}

.kbz-sa .kbz-sa-title {
    margin: 0;
    overflow: hidden;
    font-family: var(--kbz-sa-font);
    font-size: 15px;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: inherit;
}

.kbz-sa-subtitle {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 2px 0 0;
    overflow: hidden;
    font-size: 12.5px;
    line-height: 1.3;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--kbz-sa-muted);
}

/* A green dot: the assistant answers right away. */
.kbz-sa-subtitle::before {
    content: "";
    flex: none;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #3fa45b;
}

.kbz-sa-icon-btn {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--kbz-sa-muted);
    cursor: pointer;
}

.kbz-sa-icon-btn:hover {
    background: var(--kbz-sa-soft);
    color: var(--kbz-sa-text);
}

.kbz-sa-icon-btn[hidden] {
    display: none;
}

.kbz-sa-icon-btn svg {
    width: 18px;
    height: 18px;
}

.kbz-sa-log {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 14px;
    background: var(--kbz-sa-soft);
    overscroll-behavior: contain;
    scrollbar-width: thin;
}

/* --- messages ----------------------------------------------------------------------------------- */

.kbz-sa-msg {
    max-width: 86%;
    margin: 0 0 10px;
    padding: 10px 14px;
    border-radius: 18px;
    overflow-wrap: break-word;
}

.kbz-sa-msg p,
.kbz-sa-msg ul,
.kbz-sa-msg dl {
    margin: 0 0 8px;
}

.kbz-sa-msg > :last-child {
    margin-bottom: 0;
}

.kbz-sa-msg ul {
    padding-left: 18px;
}

.kbz-sa-msg li {
    margin: 2px 0;
}

.kbz-sa-msg--bot {
    align-self: flex-start;
    border-bottom-left-radius: 6px;
    border: 1px solid var(--kbz-sa-border);
    background: var(--kbz-sa-bg);
}

.kbz-sa-msg--user {
    align-self: flex-end;
    border-bottom-right-radius: 6px;
    background: var(--kbz-sa-accent);
    color: var(--kbz-sa-on-accent);
    white-space: pre-wrap;
}

.kbz-sa-msg--notice {
    border: 1px solid var(--kbz-sa-border);
    box-shadow: none;
}

.kbz-sa-msg a {
    color: var(--kbz-sa-accent-ink);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.kbz-sa .kbz-sa-cta {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 999px;
    background: var(--kbz-sa-accent);
    color: var(--kbz-sa-on-accent);
    text-decoration: none;
}

.kbz-sa-note {
    font-size: 12px;
    line-height: 1.45;
    color: var(--kbz-sa-muted);
}

.kbz-sa-hours {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 16px;
    font-size: 14px;
}

.kbz-sa-hours dt {
    color: var(--kbz-sa-muted);
}

.kbz-sa-hours dd {
    margin: 0;
    font-weight: 600;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.kbz-sa-contact {
    list-style: none;
    padding: 0 !important;
}

.kbz-sa-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 12px 0 10px;
}

.kbz-sa .kbz-sa-chip {
    padding: 7px 13px;
    border: 1px solid var(--kbz-sa-border);
    border-radius: 999px;
    background: var(--kbz-sa-bg);
    color: var(--kbz-sa-text);
    font: inherit;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.25;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease;
}

.kbz-sa .kbz-sa-chip:first-child {
    border-color: var(--kbz-sa-accent);
    background: var(--kbz-sa-accent-soft);
}

.kbz-sa a.kbz-sa-chip--link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--kbz-sa-text);
    font-weight: 600;
    text-decoration: none;
}

.kbz-sa a.kbz-sa-chip--link::after {
    content: "↗";
    font-size: 12px;
    color: var(--kbz-sa-muted);
}

.kbz-sa .kbz-sa-chip:hover {
    color: var(--kbz-sa-text);
    border-color: var(--kbz-sa-accent);
    background: var(--kbz-sa-accent-soft);
}

.kbz-sa-typing {
    display: flex;
    gap: 5px;
    width: 62px;
}

.kbz-sa-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--kbz-sa-muted);
    animation: kbz-sa-dot 1.2s infinite ease-in-out;
}

.kbz-sa-typing span:nth-child(2) {
    animation-delay: .15s;
}

.kbz-sa-typing span:nth-child(3) {
    animation-delay: .3s;
}

@keyframes kbz-sa-dot {
    0%, 80%, 100% { opacity: .3; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}

/* --- booking card -------------------------------------------------------------------------------- */

.kbz-sa .kbz-sa-card {
    align-self: stretch;
    max-width: none;
    padding: 14px;
    border-radius: 16px;
    border-bottom-left-radius: 16px;
    box-shadow: inset 0 3px 0 var(--kbz-sa-accent);
}

.kbz-sa-card-title {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
}

.kbz-sa-card-details {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 16px;
    font-size: 14px;
}

.kbz-sa-card-details dt {
    color: var(--kbz-sa-muted);
}

.kbz-sa-card-details dd {
    margin: 0;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.kbz-sa-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.kbz-sa-card-actions .kbz-sa-submit {
    width: auto;
    margin: 0;
    padding: 9px 20px;
}

.kbz-sa-card-state {
    font-weight: 600;
}

.kbz-sa-card.is-booked,
.kbz-sa-card.is-requested {
    box-shadow: inset 0 3px 0 var(--kbz-sa-ok);
}

.kbz-sa-card.is-booked .kbz-sa-card-state,
.kbz-sa-card.is-requested .kbz-sa-card-state {
    color: var(--kbz-sa-ok);
}

.kbz-sa-card.is-dismissed,
.kbz-sa-card.is-expired,
.kbz-sa-card.is-replaced {
    opacity: .7;
    box-shadow: none;
}

.kbz-sa-code label {
    display: block;
    margin-bottom: 6px;
    font-size: 13.5px;
    color: var(--kbz-sa-muted);
}

.kbz-sa-code-row {
    display: flex;
    gap: 8px;
}

.kbz-sa .kbz-sa-code-row input {
    flex: 1;
    min-width: 0;
    font-size: 20px;
    letter-spacing: .3em;
    text-align: center;
}

.kbz-sa-code-row .kbz-sa-submit {
    width: auto;
    margin: 0;
    padding: 9px 18px;
}

/* --- footer: start form, composer ------------------------------------------------------------------ */

.kbz-sa-footer {
    flex: none;
    padding: 10px 12px 12px;
    border-top: 1px solid var(--kbz-sa-border);
    background: var(--kbz-sa-bg);
}

.kbz-sa-footer[hidden] {
    display: none;
}

/* The start form: a card in the conversation. */
.kbz-sa-start {
    margin: 0;
    padding: 16px;
    border: 1px solid var(--kbz-sa-border);
    border-radius: 16px;
    background: var(--kbz-sa-bg);
}

.kbz-sa-intro {
    margin: 0 0 14px;
    font-size: 14.5px;
    line-height: 1.45;
}

.kbz-sa-field {
    margin-bottom: 12px;
}

.kbz-sa-field label {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 5px;
    font-size: 13px;
    line-height: 1.3;
}

.kbz-sa-label {
    font-weight: 600;
    color: var(--kbz-sa-text);
}

.kbz-sa-optional {
    font-size: 12px;
    font-weight: 400;
    color: var(--kbz-sa-muted);
    white-space: nowrap;
}

.kbz-sa input[type=text],
.kbz-sa input[type=email],
.kbz-sa input[type=tel],
.kbz-sa textarea {
    display: block;
    width: 100%;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid var(--kbz-sa-border);
    border-radius: 10px;
    background: #fff;
    color: var(--kbz-sa-text);
    font: inherit;
    font-size: 16px; /* no zoom on iOS */
    line-height: 1.4;
    box-shadow: none;
    transition: border-color .15s ease;
}

.kbz-sa input[type=text]:focus,
.kbz-sa input[type=email]:focus,
.kbz-sa input[type=tel]:focus,
.kbz-sa textarea:focus {
    border-color: var(--kbz-sa-accent);
    outline: none;
    box-shadow: 0 0 0 3px var(--kbz-sa-accent-soft);
}

.kbz-sa input[aria-invalid=true] {
    border-color: var(--kbz-sa-error);
}

.kbz-sa-hint {
    margin: 0 0 8px;
    font-size: 12.5px;
    color: var(--kbz-sa-muted);
}

.kbz-sa-hint[hidden] {
    display: none;
}

.kbz-sa-hint.is-error {
    color: var(--kbz-sa-error);
}

.kbz-sa-error {
    margin: 4px 0 0;
    font-size: 12.5px;
    color: var(--kbz-sa-error);
}

.kbz-sa-error[hidden] {
    display: none;
}

.kbz-sa-consent {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin: 16px 0 0;
    padding-top: 14px;
    border-top: 1px solid var(--kbz-sa-border);
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--kbz-sa-muted);
}

.kbz-sa-consent label {
    cursor: pointer;
}

.kbz-sa-consent input {
    flex: none;
    width: 18px;
    height: 18px;
    margin: 1px 0 0;
    accent-color: var(--kbz-sa-accent);
}

.kbz-sa-consent a {
    color: var(--kbz-sa-text);
    text-decoration: underline;
}

.kbz-sa-submit {
    display: block;
    width: 100%;
    margin-top: 16px;
    padding: 12px 16px;
    border: 0;
    border-radius: 999px;
    background: var(--kbz-sa-accent);
    color: var(--kbz-sa-on-accent);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: filter .15s ease;
}

.kbz-sa-submit:hover {
    filter: brightness(.94);
}

.kbz-sa-submit:disabled {
    opacity: .6;
    cursor: wait;
}

.kbz-sa-composer {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.kbz-sa .kbz-sa-composer textarea {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    padding: 11px 16px;
    border-radius: 22px;
    background: var(--kbz-sa-soft);
    resize: none;
}

.kbz-sa .kbz-sa-composer textarea:focus {
    background: #fff;
}

.kbz-sa-send {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--kbz-sa-accent);
    color: var(--kbz-sa-on-accent);
    cursor: pointer;
}

.kbz-sa-send:disabled {
    opacity: .5;
    cursor: wait;
}

.kbz-sa-send svg {
    width: 19px;
    height: 19px;
}

.kbz-sa-ended p {
    margin: 0;
    text-align: center;
}

/* --- phones: the panel takes the screen ------------------------------------------------------------ */

@media (max-width: 480px) {
    .kbz-sa {
        right: 14px;
        bottom: 14px;
    }

    .kbz-sa.is-open .kbz-sa-panel {
        position: fixed;
        inset: 0;
        width: auto;
        height: auto;
        margin: 0;
        border: 0;
        border-radius: 0;
        animation: none;
    }

    .kbz-sa.is-open .kbz-sa-toggle {
        display: none;
    }

    .kbz-sa-teaser {
        display: none;
    }

    .kbz-sa-toggle {
        width: 56px;
        height: 56px;
    }

    .kbz-sa-msg {
        max-width: 90%;
    }

    body.kbz-sa-on .scroll-to-top {
        bottom: 84px;
        right: 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .kbz-sa-toggle,
    .kbz-sa-toggle::before,
    .kbz-sa-teaser,
    .kbz-sa-panel,
    .kbz-sa-typing span {
        transition: none;
        animation: none;
    }
}
