/* =========================================================
   WhatsApp Chatbot — The Reserve Club
   Fixed bottom-right · mobile-safe · isolated styles
========================================================= */

.rc-wa .visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.rc-wa {
    --wa-green: #25d366;
    --wa-green-deep: #128c7e;
    --wa-ink: #111b21;
    --wa-muted: #667781;
    --wa-panel: #fff;
    --wa-chat-bg: #e5ddd5;
    --wa-bubble-bot: #fff;
    --wa-bubble-user: #d9fdd3;
    --wa-copper: #b87333;
    --wa-ease: cubic-bezier(0.22, 1, 0.36, 1);
    --wa-z: 9200;
    --wa-fab-size: 58px;
    --wa-gap: 16px;
    --wa-safe-b: env(safe-area-inset-bottom, 0px);
    --wa-safe-r: env(safe-area-inset-right, 0px);
    font-family: "Poppins", system-ui, sans-serif;
    box-sizing: border-box;
}

.rc-wa *,
.rc-wa *::before,
.rc-wa *::after {
    box-sizing: border-box;
}

/* Hide back-to-top — conflicts with WhatsApp FAB */
.back-to-top {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.rc-wa__fab {
    position: fixed;
    right: calc(18px + var(--wa-safe-r));
    bottom: calc(18px + var(--wa-safe-b));
    z-index: var(--wa-z);
    width: var(--wa-fab-size);
    height: var(--wa-fab-size);
    border: 0;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--wa-green), var(--wa-green-deep));
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 10px 28px rgba(18, 140, 126, 0.42),
        0 2px 8px rgba(0, 0, 0, 0.12);
    transition: transform 0.25s var(--wa-ease), box-shadow 0.25s ease;
    -webkit-tap-highlight-color: transparent;
}

.rc-wa__fab:hover,
.rc-wa__fab:focus-visible {
    transform: translateY(-3px) scale(1.04);
    box-shadow:
        0 14px 34px rgba(18, 140, 126, 0.5),
        0 4px 10px rgba(0, 0, 0, 0.14);
    outline: none;
}

.rc-wa__fab i {
    font-size: 30px;
    line-height: 1;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.rc-wa__fab-icon--close {
    position: absolute;
    font-size: 22px;
    opacity: 0;
    transform: rotate(-90deg) scale(0.6);
}

.rc-wa.is-open .rc-wa__fab-icon--whatsapp {
    opacity: 0;
    transform: rotate(90deg) scale(0.6);
}

.rc-wa.is-open .rc-wa__fab-icon--close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

.rc-wa__pulse {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--wa-green);
    animation: rc-wa-pulse 2.2s ease-out infinite;
    pointer-events: none;
}

.rc-wa.is-open .rc-wa__pulse {
    display: none;
}

@keyframes rc-wa-pulse {
    0% {
        transform: scale(1);
        opacity: 0.7;
    }
    100% {
        transform: scale(1.55);
        opacity: 0;
    }
}

.rc-wa__badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #e11d48;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(225, 29, 72, 0.45);
}

.rc-wa.is-open .rc-wa__badge,
.rc-wa.is-seen .rc-wa__badge {
    display: none;
}

/* Panel */
.rc-wa__panel {
    position: fixed;
    right: calc(18px + var(--wa-safe-r));
    bottom: calc(18px + var(--wa-fab-size) + 14px + var(--wa-safe-b));
    z-index: calc(var(--wa-z) + 1);
    width: min(360px, calc(100vw - 28px));
    max-height: min(560px, calc(100dvh - 110px - var(--wa-safe-b)));
    display: flex;
    flex-direction: column;
    background: var(--wa-panel);
    border-radius: 18px;
    overflow: hidden;
    box-shadow:
        0 24px 60px rgba(17, 27, 33, 0.28),
        0 4px 16px rgba(17, 27, 33, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(18px) scale(0.96);
    transform-origin: bottom right;
    pointer-events: none;
    transition:
        opacity 0.28s var(--wa-ease),
        transform 0.28s var(--wa-ease),
        visibility 0.28s;
}

.rc-wa.is-open .rc-wa__panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.rc-wa__head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 14px 14px 16px;
    background: linear-gradient(135deg, var(--wa-green-deep), #075e54);
    color: #fff;
    flex-shrink: 0;
}

.rc-wa__avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #fff;
    display: grid;
    place-items: center;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
}

.rc-wa__avatar img {
    width: 70%;
    height: auto;
    display: block;
}

.rc-wa__head-meta {
    min-width: 0;
    flex: 1;
}

.rc-wa__head-meta strong {
    display: block;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
}

.rc-wa__status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
    font-size: 12px;
    opacity: 0.92;
}

.rc-wa__status::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.25);
}

.rc-wa__close {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.rc-wa__close:hover,
.rc-wa__close:focus-visible {
    background: rgba(255, 255, 255, 0.22);
    outline: none;
}

.rc-wa__body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 14px 12px 8px;
    background:
        linear-gradient(rgba(229, 221, 213, 0.92), rgba(229, 221, 213, 0.92)),
        url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23c9c0b5' fill-opacity='0.35'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.rc-wa__msg {
    display: flex;
    flex-direction: column;
    max-width: 88%;
    margin-bottom: 10px;
    animation: rc-wa-in 0.28s var(--wa-ease);
}

@keyframes rc-wa-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.rc-wa__msg--bot {
    align-self: flex-start;
}

.rc-wa__msg--user {
    align-self: flex-end;
}

.rc-wa__bubble {
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.45;
    color: var(--wa-ink);
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
    white-space: pre-wrap;
    word-break: break-word;
}

.rc-wa__msg--bot .rc-wa__bubble {
    background: var(--wa-bubble-bot);
    border-top-left-radius: 4px;
}

.rc-wa__msg--user .rc-wa__bubble {
    background: var(--wa-bubble-user);
    border-top-right-radius: 4px;
}

.rc-wa__time {
    margin-top: 3px;
    padding: 0 4px;
    font-size: 10.5px;
    color: var(--wa-muted);
}

.rc-wa__msg--user .rc-wa__time {
    text-align: right;
}

.rc-wa__typing {
    display: none;
    align-self: flex-start;
    gap: 4px;
    padding: 12px 14px;
    margin-bottom: 10px;
    background: #fff;
    border-radius: 12px 12px 12px 4px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
}

.rc-wa__typing.is-on {
    display: inline-flex;
}

.rc-wa__typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #8696a0;
    animation: rc-wa-dot 1.2s infinite ease-in-out;
}

.rc-wa__typing span:nth-child(2) {
    animation-delay: 0.15s;
}

.rc-wa__typing span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes rc-wa-dot {
    0%,
    80%,
    100% {
        transform: translateY(0);
        opacity: 0.45;
    }
    40% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

.rc-wa__quick {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 12px 12px;
    background: transparent;
    flex-shrink: 0;
}

.rc-wa__chip {
    border: 1px solid rgba(18, 140, 126, 0.35);
    background: #fff;
    color: var(--wa-green-deep);
    font-size: 12.5px;
    font-weight: 500;
    font-family: inherit;
    line-height: 1.2;
    padding: 8px 12px;
    border-radius: 999px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.rc-wa__chip:hover,
.rc-wa__chip:focus-visible {
    background: rgba(37, 211, 102, 0.12);
    border-color: var(--wa-green);
    outline: none;
}

.rc-wa__foot {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom, 0px));
    background: #f0f2f5;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
}

.rc-wa__input {
    flex: 1;
    min-width: 0;
    height: 42px;
    border: 0;
    border-radius: 999px;
    background: #fff;
    padding: 0 16px;
    font-size: 14px;
    font-family: inherit;
    color: var(--wa-ink);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.rc-wa__input::placeholder {
    color: #8696a0;
}

.rc-wa__input:focus {
    outline: 2px solid rgba(37, 211, 102, 0.45);
    outline-offset: 0;
}

.rc-wa__send {
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 50%;
    background: var(--wa-green);
    color: #fff;
    cursor: pointer;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.2s ease, transform 0.2s ease;
}

.rc-wa__send:hover,
.rc-wa__send:focus-visible {
    background: var(--wa-green-deep);
    outline: none;
}

.rc-wa__send:active {
    transform: scale(0.96);
}

.rc-wa__cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--wa-green);
    color: #fff !important;
    text-decoration: none !important;
    font-size: 13px;
    font-weight: 600;
}

.rc-wa__cta:hover {
    background: var(--wa-green-deep);
}

.rc-wa__hint {
    font-size: 11px;
    color: var(--wa-muted);
    text-align: center;
    padding: 0 12px 8px;
    background: #f0f2f5;
}

/* Mobile */
@media (max-width: 640px) {
    .rc-wa {
        --wa-fab-size: 54px;
    }

    .rc-wa__fab {
        right: calc(14px + var(--wa-safe-r));
        bottom: calc(14px + var(--wa-safe-b));
    }

    .rc-wa__panel {
        right: 10px;
        left: 10px;
        width: auto;
        bottom: calc(14px + var(--wa-fab-size) + 12px + var(--wa-safe-b));
        max-height: min(72dvh, calc(100dvh - 90px - var(--wa-safe-b)));
        border-radius: 16px;
    }

    .rc-wa__bubble {
        font-size: 14px;
    }

    .rc-wa__chip {
        font-size: 13px;
        padding: 9px 13px;
    }
}

@media (max-width: 380px) {
    .rc-wa__panel {
        max-height: min(68dvh, calc(100dvh - 86px - var(--wa-safe-b)));
    }
}

@media (prefers-reduced-motion: reduce) {
    .rc-wa__pulse,
    .rc-wa__typing span,
    .rc-wa__msg {
        animation: none !important;
    }

    .rc-wa__fab,
    .rc-wa__panel {
        transition: none !important;
    }
}
