/* =============================================================================
 * send-completion.css — the inline "before you send" popover.
 * Paired with assets/js/components/send-completion.js. Keepr is light-only, so
 * there's no dark theme here; every colour comes from the base.css tokens.
 *
 * It's a POPOVER anchored (by JS) to the button that fired the send, with a tail
 * pointing at it — not a dimming modal. The backdrop is a transparent catcher for
 * outside-clicks and Escape; the page stays visible behind.
 * ========================================================================== */

.ksc-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10600;                 /* above the fixed Metronic header (10001) */
    background: transparent;        /* contextual popover, not a modal wall */
}

.ksc-pop {
    position: absolute;
    width: 360px;
    max-width: calc(100vw - 24px);
    background: var(--color-bg-card);
    border-radius: 15px;
    box-shadow: 0 18px 46px rgba(21, 28, 46, 0.26);
    opacity: 0;
    transform: translateY(8px) scale(0.94);
    transition: opacity 0.2s ease, transform 0.3s cubic-bezier(0.2, 0.9, 0.25, 1.08);
}
.ksc-backdrop.is-in .ksc-pop { opacity: 1; transform: none; }

/* the little diamond that points at the trigger button */
.ksc-tail {
    position: absolute;
    width: 16px; height: 16px;
    background: var(--color-bg-card);
    transform: rotate(45deg);
}
.ksc-pop:not(.below) .ksc-tail { bottom: -8px; box-shadow: 5px 5px 12px rgba(21, 28, 46, 0.07); }
.ksc-pop.below .ksc-tail { top: -8px; box-shadow: -4px -4px 10px rgba(21, 28, 46, 0.05); }

.ksc-inner { padding: 19px 21px 0; }

.ksc-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.ksc-plane {
    flex: none; width: 29px; height: 29px;
    border-radius: 8px; background: #eaf3fa; color: var(--color-primary);
    display: grid; place-items: center;
}
.ksc-title { font-family: Rubik, sans-serif; font-weight: 500; font-size: 14px; color: var(--color-text); line-height: 1.1; }
.ksc-close {
    margin-left: auto; border: 0; background: transparent; color: var(--color-text-light);
    font-size: 22px; line-height: 16px; cursor: pointer; padding: 0 2px;
}
.ksc-close:hover { color: var(--color-text); }

.ksc-progress { display: flex; gap: 6px; margin-bottom: 15px; }
.ksc-dot { width: 20px; height: 5px; border-radius: var(--radius-pill); background: var(--color-border); transition: background 0.25s ease; }
.ksc-dot.is-active { background: var(--color-primary); }
.ksc-dot.is-done { background: var(--color-primary); opacity: 0.5; }

/* the region whose height morphs between steps */
.ksc-morph { overflow: hidden; }
.ksc-step.ksc-anim { animation: kscStepIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes kscStepIn { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: none; } }

.ksc-q {
    font-family: Rubik, sans-serif; font-weight: 400; font-size: 19px; line-height: 1.3;
    color: var(--color-text); margin: 0 0 7px; text-wrap: balance;
}
.ksc-help { font-size: 13px; line-height: 1.45; color: var(--color-text-muted); margin: 0 0 15px; }

.ksc-field { display: block; margin: 0 0 12px; }
.ksc-label { display: block; font-size: 11.5px; font-weight: 500; color: var(--color-text-light); margin-bottom: 6px; }
.ksc-input {
    width: 100%;
    background: var(--color-bg-page);
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--color-text);
    padding: 11px 13px; line-height: 22px; font-size: 14px;
    font-family: Poppins, sans-serif;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.ksc-input::placeholder { color: var(--color-text-light); }
.ksc-input:focus { outline: none; background: var(--color-bg-card); border-color: var(--color-primary); }
.ksc-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* the structured address fields, tucked away until a suggestion is picked or
   the user enters it manually; grows from 0 so the popover glides open. */
.ksc-addr-more { height: 0; overflow: hidden; opacity: 0; transition: height 0.32s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.3s ease; }
.ksc-addr-more.is-in { opacity: 1; }
.ksc-manual-link {
    display: inline-block; background: none; border: 0; padding: 0; margin: -4px 0 4px;
    color: var(--color-primary); font-family: Poppins, sans-serif; font-size: 12.5px; cursor: pointer;
}
.ksc-manual-link:hover { color: var(--color-primary-hover); text-decoration: underline; }

.ksc-error { display: none; font-size: 12.5px; color: var(--color-danger); margin: -2px 0 10px; }
.ksc-note-warn {
    font-size: 12.5px; line-height: 1.4; color: #856404;
    background: var(--color-alert-warning-bg, #fef8e7);
    border-radius: var(--radius); padding: 10px 12px; margin-top: 2px;
}
.ksc-note-quiet { color: var(--color-text-muted); background: var(--color-bg-page); }

/* footer: reassurance / Back on the left, action on the right, divider above */
.ksc-foot {
    display: flex; align-items: center; gap: 12px;
    margin-top: 16px; padding: 13px 21px;
    border-top: 1px solid var(--color-border-subtle);
}
.ksc-reassure {
    display: flex; align-items: center; gap: 6px;
    font-size: 11.5px; line-height: 1.35; color: var(--color-text-light); max-width: 64%;
}
.ksc-reassure svg { flex: none; color: var(--color-success); }

.ksc-btn { font-family: Poppins, sans-serif; font-size: 14px; border: 0; border-radius: var(--radius); padding: 9px 16px; cursor: pointer; transition: background 0.15s ease, opacity 0.15s ease; }
.ksc-btn-primary { margin-left: auto; background: var(--color-primary); color: #fff; }
.ksc-btn-primary:hover { background: var(--color-primary-hover); }
.ksc-btn-primary:disabled { opacity: 0.6; cursor: default; }
.ksc-btn-ghost { background: var(--color-btn-default, #e1e5ec); color: var(--color-text); }
.ksc-btn-ghost:hover { background: var(--color-btn-default-hover, #c9ced8); }
.ksc-btn-link { background: transparent; color: var(--color-text-light); padding-left: 2px; padding-right: 6px; }
.ksc-btn-link:hover { color: var(--color-text); }

/* the terminal (verification) step stacks its two fallback actions full-width,
   so the labels never wrap in the narrow popover. */
.ksc-foot.ksc-foot-stack { flex-direction: column; align-items: stretch; gap: 9px; }
.ksc-foot-stack .ksc-btn-primary { margin-left: 0; width: 100%; }
.ksc-resend-link {
    width: 100%; background: none; border: 0; padding: 2px; cursor: pointer;
    color: var(--color-text-light); font-family: Poppins, sans-serif; font-size: 13px; text-align: center;
}
.ksc-resend-link:hover { color: var(--color-primary); text-decoration: underline; }
.ksc-resend-link:disabled { cursor: default; }
.ksc-resend-link:disabled:hover { color: var(--color-text-light); text-decoration: none; }
.ksc-resend-link.is-sent, .ksc-resend-link.is-sent:hover { color: var(--color-success); text-decoration: none; }
/* the label crossfades between states; the success tick draws itself in */
.ksc-resend-label { display: inline-block; transition: opacity 0.15s ease; }
.ksc-resend-label.is-fading { opacity: 0; }
.ksc-tick { display: inline-block; vertical-align: -2px; margin-left: 3px; transform-origin: center; }
.ksc-tick path { fill: none; stroke: var(--color-success); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 24; stroke-dashoffset: 24; }
.ksc-tick.draw { animation: kscTickPop 0.4s cubic-bezier(0.2, 0.8, 0.3, 1.3); }
.ksc-tick.draw path { animation: kscTickDraw 0.42s cubic-bezier(0.55, 0, 0.3, 1) forwards; }
@keyframes kscTickDraw { to { stroke-dashoffset: 0; } }
@keyframes kscTickPop { 0% { transform: scale(0.55); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }

/* "not yet confirmed" note gives a small shake to draw the eye */
.ksc-shake { animation: kscShake 0.42s ease; }
@keyframes kscShake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-4px); } 40% { transform: translateX(4px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }

/* the confirmed success beat shown just before the send fires */
.ksc-confirmed { text-align: center; padding: 10px 0 6px; }
.ksc-confirmed-tick { display: inline-flex; margin-bottom: 2px; }
.ksc-confirmed-tick .ksc-tick { width: 44px; height: 44px; margin: 0; }
.ksc-confirmed .ksc-q { margin: 4px 0 6px; }
.ksc-confirmed .ksc-help { margin: 0; }

/* loading spinner on the primary button while saving */
.ksc-btn-primary.is-loading { position: relative; color: transparent; }
.ksc-btn-primary.is-loading::after {
    content: ""; position: absolute; top: 50%; left: 50%;
    width: 15px; height: 15px; margin: -8px 0 0 -8px;
    border: 2px solid rgba(255, 255, 255, 0.5); border-top-color: #fff;
    border-radius: 50%; animation: kscSpin 0.6s linear infinite;
}
@keyframes kscSpin { to { transform: rotate(360deg); } }

/* While the popover is open, tuck away the floating chat / assistant launchers.
   The free-user chat launcher (.kchat-launcher) sits at z-index 99990 — above
   this popover — so it would otherwise float over the popover's corner. Mirrors
   the existing body.ptn-open convention that hides them behind the post-trial
   modal. Keyed off body.ksc-open, set by send-completion.js. */
body.ksc-open .kchat-launcher,
body.ksc-open .kchat-panel,
body.ksc-open .kai-launcher,
body.ksc-open .kai-panel { display: none !important; }

@media (prefers-reduced-motion: reduce) {
    .ksc-pop, .ksc-backdrop.is-in .ksc-pop { transition: opacity 0.12s ease !important; transform: none !important; }
    .ksc-step.ksc-anim { animation: none !important; }
    .ksc-morph, .ksc-addr-more { transition: none !important; }
    .ksc-btn-primary.is-loading::after { animation: none !important; }
    .ksc-resend-label { transition: none !important; }
    .ksc-tick, .ksc-tick.draw { animation: none !important; }
    .ksc-tick path { stroke-dashoffset: 0 !important; animation: none !important; }
    .ksc-shake { animation: none !important; }
}
