/* ===== HOME HERO: LIVE BOOKING FLOW =====
   A WhatsApp booking and an AI phone call play in turn and land in a dispatch
   board (front-page.php, main.js initBookingFlow). The stage is a fixed-size
   scene (580x600 desktop, 343x616 phone) that main.js scales to its column.
   Without JavaScript the finished WhatsApp state is shown. */

.bf-stage {
    position: relative;
    width: 100%;
    height: 600px;
}

.bf {
    --bf-w: 580px;
    --bf-h: 600px;
    position: absolute;
    top: 0;
    left: 50%;
    width: var(--bf-w);
    height: var(--bf-h);
    margin-left: calc(var(--bf-w) / -2);
    transform-origin: top center;
    text-align: left;
    color: var(--white);
    font-size: 11.5px;
    line-height: 1.38;
}

/* Visibility driven by data-step (main.js adds .is-live). */
.bf.is-live .bf-off,
.bf:not(.is-live) [data-only],
.bf:not(.is-live) [data-to] {
    display: none !important;
}

.bf[data-channel="wa"] .bf-call,
.bf[data-channel="voice"] .bf-wa {
    display: none;
}

.bf.is-live .bf-msg,
.bf.is-live .bf-toast {
    animation: bfPop 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes bfPop {
    from { opacity: 0; transform: translateY(10px) scale(0.96); }
    to { opacity: 1; transform: none; }
}

/* Channel switcher */
.bf-switch {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.16);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    white-space: nowrap;
    z-index: 6;
}

.bf-switch-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px 0 12px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.75);
}

.bf-tab {
    height: 36px;
    padding: 0 14px;
    border: 0;
    border-radius: var(--radius-full);
    background: transparent;
    color: rgba(255, 255, 255, 0.85);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background var(--duration-normal) ease, color var(--duration-normal) ease;
}

.bf-tab:hover {
    color: var(--white);
    background: rgba(255, 255, 255, 0.1);
}

.bf-tab[aria-pressed="true"] {
    background: var(--white);
    color: var(--navy);
}

.bf-tab:focus-visible {
    outline: 2px solid var(--primary-300);
    outline-offset: 2px;
}

.bf-live {
    position: relative;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    flex-shrink: 0;
}

.bf-live::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: var(--success);
    animation: bfRing 1.8s ease-out infinite;
}

/* Night chip */
.bf-night {
    position: absolute;
    left: 318px;
    top: 92px;
    width: 262px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.16);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.bf-night div {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.bf-night strong {
    font-size: 13px;
}

.bf-night span:not(.bf-clock) {
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.7);
}

/* Phone */
.bf-phone {
    position: absolute;
    left: 0;
    top: 64px;
    width: 270px;
    height: 530px;
    box-sizing: border-box;
    padding: 10px;
    border-radius: 40px;
    background: var(--gray-900);
    box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1);
    z-index: 2;
}

.bf-phone::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 380px;
    height: 380px;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(37, 99, 235, 0.25) 0%, rgba(102, 126, 234, 0.1) 40%, transparent 70%);
    filter: blur(40px);
    z-index: -1;
    pointer-events: none;
}

.bf-notch {
    position: absolute;
    top: 16px;
    left: 50%;
    width: 84px;
    height: 22px;
    margin-left: -42px;
    border-radius: 20px;
    background: var(--gray-900);
    z-index: 3;
}

.bf-screen {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 31px;
    overflow: hidden;
}

/* WhatsApp screen */
.bf-wa {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #e5ddd5;
    color: #111b21;
}

.bf-wa-head {
    flex-shrink: 0;
    height: 88px;
    box-sizing: border-box;
    padding: 40px 12px 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #075e54;
    color: var(--white);
}

.bf-wa-head div {
    display: flex;
    flex-direction: column;
}

.bf-wa-head strong {
    font-size: 14px;
    font-weight: 600;
}

.bf-wa-status {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
}

.bf-avatar {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
}

.bf-avatar img,
.bf-call-logo img {
    display: block;
    width: 24px;
    height: 24px;
}

.bf-msgs {
    flex-grow: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 6px;
    padding: 10px;
}

.bf-day {
    align-self: center;
    font-size: 10.5px;
    color: #54656f;
    background: #e1f2fb;
    padding: 3px 10px;
    border-radius: 6px;
}

.bf-msg {
    max-width: 86%;
    padding: 7px 9px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.bf-out {
    align-self: flex-end;
    background: #dcf8c6;
    border-radius: 8px 8px 2px 8px;
}

.bf-in {
    align-self: flex-start;
    background: var(--white);
    border-radius: 8px 8px 8px 2px;
}

.bf-gap {
    margin-top: 4px;
}

.bf-tag {
    align-self: flex-start;
    margin-top: 2px;
    font-size: 10px;
    font-weight: 600;
    color: var(--primary-dark);
    background: var(--primary-100);
    padding: 2px 7px;
    border-radius: var(--radius-full);
}

.bf-done {
    flex-direction: row;
    align-items: center;
    gap: 6px;
}

.bf-done svg {
    flex-shrink: 0;
    color: #16a34a;
}

.bf-typing {
    flex-direction: row;
    align-items: center;
    gap: 4px;
    padding: 10px 12px;
}

.bf-typing i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--gray-400);
    animation: typing-dot 1.2s infinite;
}

.bf-typing i:nth-child(2) { animation-delay: 0.18s; }
.bf-typing i:nth-child(3) { animation-delay: 0.36s; }

.bf-wa-input {
    flex-shrink: 0;
    height: 46px;
    box-sizing: border-box;
    padding: 6px 8px 10px;
    display: flex;
    gap: 6px;
    align-items: center;
}

.bf-wa-input span {
    flex-grow: 1;
    height: 30px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    border-radius: var(--radius-full);
    background: var(--white);
    color: #8696a0;
    font-size: 12px;
}

.bf-wa-input i {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #00a884;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Phone-call screen */
.bf-call {
    height: 100%;
    box-sizing: border-box;
    padding: 48px 12px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: linear-gradient(180deg, #0f172a 0%, #1e3a8a 70%, #1d4ed8 100%);
}

.bf-call-label {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--primary-300);
}

.bf-call-avatar {
    position: relative;
    width: 58px;
    height: 58px;
    margin: 6px 0 2px;
}

.bf-call-logo {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
}

.bf-call-logo img {
    width: 38px;
    height: 38px;
}

.bf-ring {
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    border: 2px solid rgba(147, 197, 253, 0.6);
    animation: bfRing 1.4s ease-out infinite;
}

.bf-ring-2 {
    animation-delay: 0.7s;
}

@keyframes bfRing {
    from { transform: scale(0.85); opacity: 0.9; }
    to { transform: scale(1.45); opacity: 0; }
}

.bf-call-number {
    font-size: 15px;
    font-weight: 700;
    color: var(--white);
    text-decoration: none;
}

.bf-call-number:hover {
    color: var(--primary-200);
}

.bf-call-status {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.75);
}

.bf-wave {
    display: flex;
    gap: 3px;
    align-items: center;
    height: 30px;
}

.bf-wave i {
    display: block;
    width: 3px;
    height: 26px;
    border-radius: 2px;
    background: var(--primary-300);
    animation: bfWave 0.9s ease-in-out infinite;
}

.bf-wave i:nth-child(2n) { animation-delay: 0.15s; background: #a78bfa; }
.bf-wave i:nth-child(3n) { animation-delay: 0.3s; }
.bf-wave i:nth-child(4n) { animation-delay: 0.45s; }
.bf-wave i:nth-child(5n) { animation-delay: 0.6s; }

@keyframes bfWave {
    0%, 100% { transform: scaleY(0.2); }
    50% { transform: scaleY(1); }
}

.bf-transcript {
    width: 100%;
    padding: 0;
    box-sizing: border-box;
}

.bf-msg em {
    display: block;
    font-style: normal;
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.bf-caller {
    align-self: flex-end;
    background: rgba(255, 255, 255, 0.14);
    border-radius: 10px 10px 2px 10px;
}

.bf-caller em {
    color: rgba(255, 255, 255, 0.6);
}

.bf-ai {
    align-self: flex-start;
    background: var(--white);
    color: var(--navy);
    border-radius: 10px 10px 10px 2px;
}

.bf-ai em {
    color: var(--primary);
}

.bf-hangup {
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--error);
    display: flex;
    align-items: center;
    justify-content: center;
}

.bf-hangup svg {
    transform: rotate(135deg);
}

/* Connector and the booking "packet" */
.bf-conn {
    position: absolute;
    left: 270px;
    top: 318px;
    overflow: visible;
    z-index: 1;
}

.bf-conn line {
    stroke: rgba(147, 197, 253, 0.55);
    stroke-width: 2;
    stroke-dasharray: 4 6;
    animation: bfDash 1s linear infinite;
}

@keyframes bfDash {
    to { stroke-dashoffset: -20; }
}

.bf-packet {
    position: absolute;
    left: 270px;
    top: 315px;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    background: var(--whatsapp);
    box-shadow: 0 0 18px var(--whatsapp);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    animation: bfFly 1s cubic-bezier(0.6, 0, 0.2, 1) both;
}

.bf[data-channel="voice"] .bf-packet {
    background: var(--primary-light);
    box-shadow: 0 0 18px var(--primary-light);
}

@keyframes bfFly {
    0% { transform: translateX(0) scale(0.6); opacity: 0; }
    15% { opacity: 1; }
    100% { transform: translateX(44px) scale(1); opacity: 1; }
}

/* Dispatch board */
.bf-card {
    position: absolute;
    left: 318px;
    top: 168px;
    width: 262px;
    box-sizing: border-box;
    padding: 14px;
    border-radius: var(--radius-lg);
    background: var(--white);
    color: var(--navy);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 4;
    transition: transform 0.55s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.45s ease, box-shadow 0.45s ease;
}

.bf-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bf-card-head div {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.bf-card-head strong {
    font-size: 13px;
}

.bf-card-head div span {
    font-size: 11px;
    color: var(--gray-500);
}

.bf-count {
    color: var(--navy);
}

.bf-card-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 8px;
    background: var(--primary-50);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.bf-live-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: var(--radius-full);
    background: #ecfdf5;
    color: #047857;
    font-size: 10.5px;
    font-weight: 700;
}

.bf-jobs {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bf-job {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 9px;
    border-radius: 10px;
    background: var(--gray-50);
}

.bf-job b {
    width: 38px;
    flex-shrink: 0;
    font-size: 12px;
    color: var(--gray-700);
}

.bf-job > span {
    flex-grow: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.bf-job strong {
    font-size: 11.5px;
    font-weight: 500;
    color: var(--gray-700);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bf-job small {
    font-size: 10.5px;
    color: var(--gray-500);
}

.bf-src {
    font-style: normal;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 7px;
    border-radius: var(--radius-full);
    white-space: nowrap;
    background: var(--gray-100);
    color: var(--gray-600);
}

.bf-src-wa {
    background: #dcfce7;
    color: #15803d;
}

.bf-src-ai {
    background: var(--primary-100);
    color: var(--primary-dark);
}

.bf-job-new {
    background: var(--primary-50);
    outline: 1.5px solid var(--primary-300);
}

.bf-job-new b,
.bf-job-new strong {
    color: var(--navy);
    font-weight: 700;
}

.bf.is-live .bf-job-new {
    animation: bfRowIn 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both, bfGlow 2.6s ease-out 0.5s both;
}

.bf-jobs li:nth-child(n+5) {
    display: none;
}

@keyframes bfRowIn {
    from { opacity: 0; transform: translateY(-14px); }
    to { opacity: 1; transform: none; }
}

@keyframes bfGlow {
    0% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.45); }
    40% { box-shadow: 0 0 0 6px rgba(37, 99, 235, 0.12); }
    100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}

/* Written-to-dispatch toast */
.bf-toast {
    position: absolute;
    left: 318px;
    top: 452px;
    width: 262px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    background: var(--success);
    color: var(--white);
    box-shadow: 0 12px 30px rgba(16, 185, 129, 0.35);
    z-index: 5;
}

.bf-toast svg {
    flex-shrink: 0;
}

.bf-toast div {
    display: flex;
    flex-direction: column;
}

.bf-toast strong {
    font-size: 12.5px;
}

.bf-toast span {
    font-size: 11px;
    opacity: 0.9;
}

/* Phone layout: phone first; the dispatch board waits behind it and only
   comes forward while the booking lands (data-front, set by main.js). */
@media (max-width: 600px) {
    .bf-stage {
        height: 616px;
    }

    .bf {
        --bf-w: 343px;
        --bf-h: 616px;
        font-size: 11px;
    }

    .bf-switch-label {
        padding: 0 6px 0 8px;
        font-size: 11px;
    }

    .bf-tab {
        padding: 0 11px;
    }

    .bf-night,
    .bf-conn,
    .bf-packet {
        display: none !important;
    }

    .bf-phone {
        top: 58px;
        width: 234px;
        height: 490px;
    }

    .bf-card {
        left: 124px;
        top: 338px;
        width: 219px;
    }

    .bf-toast {
        left: 124px;
        top: 290px;
        width: 219px;
    }

    .bf-jobs li:nth-child(n+4) {
        display: none;
    }

    .bf.is-live[data-front="0"] .bf-card {
        transform: translate(18px, 18px) scale(0.9);
        opacity: 0.45;
        z-index: 1;
        box-shadow: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bf *,
    .bf *::before,
    .bf *::after {
        animation: none !important;
        transition: none !important;
    }
}
