/* =============================================================
   ZipChatBot v2 — Public Widget Styles
   Colours and type match zipcapitalgroup.com (navy #0b2340,
   gold #c79a3d, Libre Franklin). Change the variables below
   rather than individual rules.
   ============================================================= */

:root {
    --zcb-navy: #0b2340;
    --zcb-navy-dark: #08192e;
    --zcb-navy-hover: #163a63;
    --zcb-gold: #c79a3d;
    --zcb-gold-hover: #e0b455;
    --zcb-gold-text: #b07e1e;
    --zcb-muted: #4a5c6e;
    --zcb-subtle: #9fb4ca;
    --zcb-light-bg: #eef3f8;
    --zcb-border: #D1D5DB;
    --zcb-text: #1F2937;
    --zcb-call: #1E8E3E;
    --zcb-call-hover: #176c30;
    --zcb-font: "Libre Franklin", Inter, Arial, sans-serif;
    /* Distance from the bottom of the viewport. Raised when the site's
       sticky call bar (#sticky-cta) is on the page so the widget sits above it. */
    --zcb-bottom: 24px;
}

body:has(#sticky-cta) {
    --zcb-bottom: 96px;
}

@media (max-width: 767px) {
    body:has(#sticky-cta) {
        --zcb-bottom: 128px;
    }
}

/* ---- Floating Action Button --------------------------------- */

#zcb-toggle {
    position: fixed;
    bottom: var(--zcb-bottom);
    right: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    /* Green so the bubble stands out against the site's navy and gold. */
    background: var(--zcb-call);
    color: #FFFFFF;
    border: 2px solid #FFFFFF;
    border-radius: 9999px;
    padding: 14px 20px;
    font-family: var(--zcb-font);
    font-weight: 600;
    font-size: 15px;
    letter-spacing: 0.01em;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(11, 35, 64, 0.35);
    z-index: 100000;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    white-space: nowrap;
}

#zcb-toggle:hover {
    background: var(--zcb-call-hover);
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(11, 35, 64, 0.45);
}

#zcb-toggle:focus-visible {
    outline: 3px solid var(--zcb-navy);
    outline-offset: 2px;
}

.zcb-toggle-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    fill: currentColor;
    color: #FFFFFF;
}

/* Hidden state — toggle disappears when window is open */
#zcb-toggle.zcb-hidden {
    visibility: hidden;
    pointer-events: none;
    opacity: 0;
}

/* ---- Chat Window -------------------------------------------- */

#zcb-window {
    position: fixed;
    bottom: var(--zcb-bottom);
    right: 24px;
    width: 380px;
    height: 560px;
    max-height: calc(100vh - var(--zcb-bottom) - 16px);
    background: #FFFFFF;
    border-radius: 8px;
    border-top: 3px solid var(--zcb-gold);
    box-shadow: 0 10px 36px rgba(11, 35, 64, 0.28);
    z-index: 100000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: var(--zcb-font);
    /* Hidden by default */
    visibility: hidden;
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.22s ease, transform 0.22s ease, visibility 0s linear 0.22s;
}

#zcb-window.zcb-open {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.22s ease, transform 0.22s ease, visibility 0s linear 0s;
}

/* Phones: the window fills the width with a 16px inset. */
@media (max-width: 480px) {
    #zcb-window {
        right: 16px;
        left: 16px;
        width: auto;
    }

    #zcb-toggle {
        right: 16px;
    }
}

/* Mobile: ≤375px — near full-screen with 16px inset (covers the sticky bar). */
#zcb-window.zcb-mobile {
    bottom: 16px;
    right: 16px;
    left: 16px;
    width: auto;
    top: 16px;
    height: auto;
    max-height: none;
    border-radius: 8px;
}

/* ---- Header ------------------------------------------------- */

#zcb-header {
    background: var(--zcb-navy);
    border-radius: 0;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.zcb-header-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.zcb-header-title {
    color: #FFFFFF;
    font-family: var(--zcb-font);
    font-weight: 700;
    font-size: 18px;
    line-height: 1.2;
}

.zcb-header-subtitle {
    color: var(--zcb-gold);
    font-family: var(--zcb-font);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1.3;
}

.zcb-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.zcb-header-btn {
    background: none;
    border: none;
    color: #FFFFFF;
    font-size: 16px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.15s ease;
    line-height: 1;
    padding: 0;
}

.zcb-header-btn:hover {
    background: var(--zcb-navy-hover);
}

.zcb-header-btn:focus-visible {
    outline: 2px solid var(--zcb-gold);
    outline-offset: 1px;
}

/* ---- Messages Area ------------------------------------------ */

#zcb-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #F9FAFB;
    display: flex;
    flex-direction: column;
}

/* Custom scrollbar */
#zcb-messages::-webkit-scrollbar {
    width: 6px;
}
#zcb-messages::-webkit-scrollbar-track {
    background: transparent;
}
#zcb-messages::-webkit-scrollbar-thumb {
    background: var(--zcb-border);
    border-radius: 3px;
}
#zcb-messages::-webkit-scrollbar-thumb:hover {
    background: var(--zcb-subtle);
}

/* ---- Message Bubbles ---------------------------------------- */

.zcb-bubble {
    font-family: var(--zcb-font);
    font-size: 14px;
    line-height: 1.5;
    padding: 12px 16px;
    word-wrap: break-word;
    animation: zcb-fade-in 0.18s ease;
}

/* Bot bubble — left-aligned */
.zcb-bubble-bot {
    background: var(--zcb-light-bg);
    color: var(--zcb-navy);
    border-radius: 14px 14px 14px 2px;
    max-width: 80%;
    margin: 0 auto 16px 0;
    /* Preserve the newlines the agent emits (e.g. the confirmation summary is
       a plain-text list, one field per line). Without this, the browser
       collapses the line breaks into a single run-on line. */
    white-space: pre-line;
}

/* User bubble — right-aligned */
.zcb-bubble-user {
    background: var(--zcb-navy);
    color: #FFFFFF;
    border-radius: 14px 14px 2px 14px;
    max-width: 75%;
    margin: 0 0 16px auto;
}

/* Error bubble — left-aligned */
.zcb-bubble-error {
    background: #FEF2F2;
    border: 1px solid #FEE2E2;
    color: #991B1B;
    border-radius: 14px 14px 14px 2px;
    max-width: 80%;
    margin: 0 auto 16px 0;
}

@keyframes zcb-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---- Handoff Elements --------------------------------------- */

.zcb-handoff-link {
    color: var(--zcb-gold-text);
    font-weight: 600;
    text-decoration: none;
}

.zcb-handoff-link:hover {
    text-decoration: underline;
}

.zcb-phone-number {
    display: block;
    font-size: 18px;
    font-weight: 600;
    color: var(--zcb-navy);
    margin-top: 6px;
}

/* Inline phone link rendered in place of a number already in the prose, so
   it reads as part of the sentence rather than a separate block. */
.zcb-phone-inline {
    display: inline;
    font-size: inherit;
    font-weight: 600;
    margin-top: 0;
    color: var(--zcb-gold-text);
    text-decoration: none;
    white-space: nowrap;
}

.zcb-phone-inline:hover {
    text-decoration: underline;
}

/* Wrapper that separates a handoff action (e.g. booking) from the message. */
.zcb-handoff-actions {
    display: block;
    margin: 10px 0;
}

/* Intro line shown directly above the booking button. */
.zcb-booking-intro {
    margin-bottom: 6px;
}

/* "Call a Zip Specialist Now" — tap-to-call button (business hours, agent free).
   Kept green (approved by Farid) so it stands apart from the navy booking button. */
.zcb-call-button {
    display: inline-block;
    padding: 10px 16px;
    margin-bottom: 8px;
    background: var(--zcb-call);
    color: #fff;
    font-family: var(--zcb-font);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    border-radius: 4px;
    text-decoration: none;
    transition: background 0.15s ease;
}

.zcb-call-button:hover,
.zcb-call-button:focus {
    background: var(--zcb-call-hover);
    color: #fff;
    text-decoration: none;
}

/* The number on the Call Now button never breaks across lines (Todd, Nov 17 #5). */
.zcb-nowrap {
    white-space: nowrap;
}

/* The DID, shown under the label so desktop visitors can dial it manually. */
.zcb-call-number {
    display: block;
    margin-top: 3px;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* After-hours booking link, rendered as a tappable button (site navy). */
.zcb-booking-button {
    display: inline-block;
    padding: 10px 16px;
    background: var(--zcb-navy);
    color: #fff;
    border: 1px solid var(--zcb-gold);
    font-family: var(--zcb-font);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    border-radius: 4px;
    text-decoration: none;
    transition: background 0.15s ease;
}

.zcb-booking-button:hover,
.zcb-booking-button:focus {
    background: var(--zcb-navy-hover);
    color: #fff;
    text-decoration: none;
}

/* ---- Typing Indicator --------------------------------------- */

.zcb-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 14px 16px;
    min-width: 60px;
}

.zcb-typing span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--zcb-gold);
    border-radius: 50%;
    animation: zcb-dot-pulse 1.2s ease-in-out infinite;
}

.zcb-typing span:nth-child(1) {
    animation-delay: 0s;
}
.zcb-typing span:nth-child(2) {
    animation-delay: 0.2s;
}
.zcb-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes zcb-dot-pulse {
    0%, 60%, 100% { opacity: 0.3; }
    30%            { opacity: 1;   }
}

/* ---- Data Confirmation Card --------------------------------- */

.zcb-confirmation-card {
    background: #FFFFFF;
    border: 1px solid var(--zcb-border);
    border-radius: 6px;
    padding: 12px;
    margin-top: 10px;
}

.zcb-card-field {
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--zcb-muted);
    line-height: 1.4;
}

.zcb-card-label {
    font-weight: 600;
    color: var(--zcb-muted);
}

.zcb-card-value {
    color: var(--zcb-navy);
}

.zcb-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.zcb-card-confirm {
    background: var(--zcb-gold);
    color: var(--zcb-navy);
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    font-family: var(--zcb-font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}

.zcb-card-confirm:hover {
    background: var(--zcb-gold-hover);
}

.zcb-card-confirm:disabled {
    background: var(--zcb-border);
    color: #6B7280;
    cursor: not-allowed;
}

.zcb-card-edit {
    background: #FFFFFF;
    color: var(--zcb-navy);
    border: 1px solid var(--zcb-navy);
    border-radius: 4px;
    padding: 8px 16px;
    font-family: var(--zcb-font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.zcb-card-edit:hover {
    background: var(--zcb-light-bg);
}

.zcb-card-edit:disabled {
    border-color: var(--zcb-border);
    color: #9CA3AF;
    cursor: not-allowed;
}

/* ---- Input Area --------------------------------------------- */

#zcb-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px;
    background: #FFFFFF;
    border-top: 1px solid var(--zcb-border);
    flex-shrink: 0;
}

#zcb-input {
    flex: 1;
    min-width: 0;
    padding: 8px 16px;
    border: 1px solid var(--zcb-border);
    border-radius: 4px;
    font-family: var(--zcb-font);
    font-size: 14px;
    color: var(--zcb-text);
    background: #FFFFFF;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#zcb-input::placeholder {
    color: #9CA3AF;
}

#zcb-input:focus {
    border-color: var(--zcb-gold);
    box-shadow: 0 0 0 2px rgba(199, 154, 61, 0.25);
}

#zcb-input:disabled {
    background: #F9FAFB;
    color: #9CA3AF;
}

#zcb-send {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    background: var(--zcb-gold);
    color: var(--zcb-navy);
    border: none;
    border-radius: 4px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
    padding: 0;
    line-height: 1;
}

#zcb-send:hover:not(:disabled) {
    background: var(--zcb-gold-hover);
}

#zcb-send:disabled {
    background: var(--zcb-border);
    color: #FFFFFF;
    cursor: not-allowed;
}

#zcb-send:focus-visible {
    outline: 3px solid var(--zcb-navy);
    outline-offset: 2px;
}

/* ---- Intake gate form --------------------------------------- */

#zcb-intake {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px 16px;
    font-family: var(--zcb-font);
    overflow-y: auto;
}

#zcb-intake[hidden] {
    display: none;
}

.zcb-intake-intro {
    margin: 0 0 4px;
    font-size: 14px;
    color: var(--zcb-muted);
}

.zcb-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.zcb-field-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--zcb-navy);
}

.zcb-field input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid var(--zcb-border);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    color: var(--zcb-text);
}

.zcb-field input:focus {
    outline: none;
    border-color: var(--zcb-gold);
    box-shadow: 0 0 0 3px rgba(199, 154, 61, 0.2);
}

.zcb-field-error {
    font-size: 12px;
    color: #DC2626;
    min-height: 14px;
}

#zcb-intake-submit {
    margin-top: 4px;
    background: var(--zcb-gold);
    color: var(--zcb-navy);
    border: none;
    border-radius: 4px;
    padding: 12px 16px;
    font-family: inherit;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.2s ease;
}

#zcb-intake-submit:hover:not(:disabled) {
    background: var(--zcb-gold-hover);
}

#zcb-intake-submit:disabled {
    opacity: 0.6;
    cursor: default;
}

#zcb-messages[hidden],
#zcb-input-area[hidden] {
    display: none;
}
