/**
 * Apex Chatbot — Front-End Stylesheet
 *
 * HOW TO CUSTOMIZE:
 *   All visual variables are in the :root { } block below.
 *   Change colors, fonts, spacing, and border-radius there.
 *   Do NOT edit Divi's global CSS — all selectors here are namespaced
 *   with .apex-chatbot-wrap to prevent conflicts.
 *
 * SECTIONS:
 *   1. CSS Custom Properties (variables)
 *   2. Outer wrapper & card
 *   3. Header
 *   4. Progress bar
 *   5. Message feed
 *   6. Option buttons
 *   7. Lead form
 *   8. Booking step
 *   9. Typing indicator
 *  10. Responsive overrides
 */

/* ════════════════════════════════════════════════════════════════════════════
   1. CSS CUSTOM PROPERTIES
   Change these to restyle the entire chatbot without touching other rules.
   ════════════════════════════════════════════════════════════════════════════ */
.apex-chatbot-wrap {
    /* ── Brand colors ────────────────────────────────────────────────────── */
    --apex-accent:         #0f2d52;   /* Primary brand color — buttons, header, accents */
    --apex-accent-hover:   #1a4278;   /* Button hover state */
    --apex-accent-light:   #e8eef6;   /* Soft tint used for option button hover */
    --apex-success:        #1a6b3c;   /* High tier / success states */

    /* ── Neutrals ────────────────────────────────────────────────────────── */
    --apex-bg:             #f5f6f8;   /* Page-level background behind the card */
    --apex-card-bg:        #ffffff;   /* Chat card background */
    --apex-header-bg:      #0f2d52;   /* Chat card header bar */
    --apex-header-text:    #ffffff;
    --apex-msg-bot-bg:     #f0f4f9;   /* Bot message bubble background */
    --apex-msg-bot-text:   #1a1d23;
    --apex-msg-user-bg:    #0f2d52;   /* User answer bubble background */
    --apex-msg-user-text:  #ffffff;

    /* ── Typography ──────────────────────────────────────────────────────── */
    --apex-font:           -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
    --apex-font-size:      15px;      /* Base font size for messages */
    --apex-line-height:    1.6;

    /* ── Spacing ─────────────────────────────────────────────────────────── */
    --apex-card-radius:    16px;      /* Card corner radius */
    --apex-msg-radius:     12px;      /* Message bubble corner radius */
    --apex-btn-radius:     10px;      /* Option button corner radius */
    --apex-input-radius:   10px;      /* Form input corner radius */
    --apex-padding:        28px;      /* Card inner padding */

    /* ── Shadow ──────────────────────────────────────────────────────────── */
    --apex-shadow:         0 8px 40px rgba(15, 45, 82, 0.10), 0 2px 8px rgba(0,0,0,0.04);

    /* ── Max width ───────────────────────────────────────────────────────── */
    --apex-card-max-width: 680px;     /* Maximum width of the chat card */
}


/* ════════════════════════════════════════════════════════════════════════════
   2. OUTER WRAPPER & CARD
   ════════════════════════════════════════════════════════════════════════════ */
.apex-chatbot-wrap {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 40px 16px;
    box-sizing: border-box;
    font-family: var(--apex-font);
    font-size: var(--apex-font-size);
    line-height: var(--apex-line-height);
    -webkit-font-smoothing: antialiased;
}

.apex-cb-card {
    width: 100%;
    max-width: var(--apex-card-max-width);
    background: var(--apex-card-bg);
    border-radius: var(--apex-card-radius);
    box-shadow: var(--apex-shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}


/* ════════════════════════════════════════════════════════════════════════════
   3. HEADER
   ════════════════════════════════════════════════════════════════════════════ */
.apex-cb-header {
    background: var(--apex-header-bg);
    color: var(--apex-header-text);
    padding: 20px var(--apex-padding);
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
}

/* Logo mark — abstract geometric square */
.apex-cb-header-logo {
    flex-shrink: 0;
}

.apex-cb-logo-mark {
    display: block;
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.15);
    border-radius: 8px;
    position: relative;
    border: 1.5px solid rgba(255,255,255,0.25);
}

.apex-cb-logo-mark::after {
    content: '';
    position: absolute;
    inset: 6px;
    background: rgba(255,255,255,0.5);
    border-radius: 4px;
}

.apex-cb-header-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.apex-cb-header-title {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.apex-cb-header-sub {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    opacity: 0.6;
    font-weight: 500;
}


/* ════════════════════════════════════════════════════════════════════════════
   4. PROGRESS BAR
   ════════════════════════════════════════════════════════════════════════════ */
.apex-cb-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(255,255,255,0.15);
}

.apex-cb-progress-bar {
    height: 100%;
    background: rgba(255,255,255,0.7);
    width: 0%;
    transition: width 0.5s ease;
}


/* ════════════════════════════════════════════════════════════════════════════
   5. MESSAGE FEED
   ════════════════════════════════════════════════════════════════════════════ */
.apex-cb-messages {
    padding: var(--apex-padding) var(--apex-padding) 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 360px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

/* Scrollbar styling */
.apex-cb-messages::-webkit-scrollbar {
    width: 4px;
}

.apex-cb-messages::-webkit-scrollbar-track {
    background: transparent;
}

.apex-cb-messages::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.12);
    border-radius: 2px;
}

.apex-cb-message {
    max-width: 85%;
    border-radius: var(--apex-msg-radius);
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.65;
    animation: apexFadeUp 0.25s ease forwards;
}

.apex-cb-message p {
    margin: 0 0 8px;
}

.apex-cb-message p:last-child {
    margin-bottom: 0;
}

/* Bot message */
.apex-cb-message--bot {
    background: var(--apex-msg-bot-bg);
    color: var(--apex-msg-bot-text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

/* User answer */
.apex-cb-message--user {
    background: var(--apex-msg-user-bg);
    color: var(--apex-msg-user-text);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    font-size: 13px;
    font-weight: 500;
}

/* Typing indicator */
.apex-cb-message--typing {
    background: var(--apex-msg-bot-bg);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    padding: 14px 18px;
    display: flex;
    gap: 5px;
    align-items: center;
}

.apex-cb-message--typing span {
    display: block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(15, 45, 82, 0.35);
    animation: apexDot 1.2s ease-in-out infinite;
}

.apex-cb-message--typing span:nth-child(2) { animation-delay: 0.2s; }
.apex-cb-message--typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes apexDot {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.4; }
    40%            { transform: scale(1.2); opacity: 1;   }
}

@keyframes apexFadeUp {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0);   }
}


/* ════════════════════════════════════════════════════════════════════════════
   6. INTERACTION AREA & OPTION BUTTONS
   ════════════════════════════════════════════════════════════════════════════ */
.apex-cb-interaction {
    padding: 8px var(--apex-padding) var(--apex-padding);
}

.apex-cb-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 4px;
}

.apex-cb-option {
    display: block;
    width: 100%;
    padding: 14px 20px;
    background: transparent;
    border: 1.5px solid #dce3ed;
    border-radius: var(--apex-btn-radius);
    font-family: var(--apex-font);
    font-size: 14px;
    font-weight: 500;
    color: #2c3b52;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
    line-height: 1.4;
    -webkit-appearance: none;
    appearance: none;
    position: relative;
}

.apex-cb-option::after {
    content: '→';
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 0.15s ease, right 0.15s ease;
    font-size: 14px;
    color: var(--apex-accent);
}

.apex-cb-option:hover {
    background: var(--apex-accent-light);
    border-color: var(--apex-accent);
    color: var(--apex-accent);
}

.apex-cb-option:hover::after {
    opacity: 1;
    right: 14px;
}

.apex-cb-option:active {
    transform: scale(0.98);
}

.apex-cb-option:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.apex-cb-option--chosen {
    background: var(--apex-accent) !important;
    border-color: var(--apex-accent) !important;
    color: #ffffff !important;
}

.apex-cb-option--chosen::after {
    display: none;
}

/* On wider screens, show 2-column option grid for short options */
@media (min-width: 520px) {
    .apex-cb-options--grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
}


/* ════════════════════════════════════════════════════════════════════════════
   7. LEAD CAPTURE FORM
   ════════════════════════════════════════════════════════════════════════════ */
.apex-cb-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 4px;
}

.apex-cb-form-row {
    width: 100%;
}

.apex-cb-input {
    display: block;
    width: 100%;
    padding: 13px 16px;
    background: #f8f9fc;
    border: 1.5px solid #dce3ed;
    border-radius: var(--apex-input-radius);
    font-family: var(--apex-font);
    font-size: 14px;
    color: #1a1d23;
    outline: none;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}

.apex-cb-input::placeholder {
    color: #9aa3b2;
}

.apex-cb-input:focus {
    border-color: var(--apex-accent);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(15, 45, 82, 0.08);
}

.apex-cb-textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.5;
}

.apex-cb-form-error {
    font-size: 13px;
    color: #c0392b;
    min-height: 1em;
    font-weight: 500;
}

/* Submit button */
.apex-cb-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 28px;
    background: var(--apex-accent);
    color: #ffffff;
    border: none;
    border-radius: var(--apex-btn-radius);
    font-family: var(--apex-font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
    letter-spacing: 0.01em;
    -webkit-appearance: none;
    appearance: none;
    align-self: flex-start;
}

.apex-cb-submit:hover {
    background: var(--apex-accent-hover);
    box-shadow: 0 4px 16px rgba(15,45,82,0.25);
}

.apex-cb-submit:active {
    transform: scale(0.97);
}

.apex-cb-submit:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* Spinner inside submit button */
.apex-cb-submit-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: apexSpin 0.65s linear infinite;
}

.apex-cb-submit--loading .apex-cb-submit-label {
    opacity: 0.7;
}

.apex-cb-submit--loading .apex-cb-submit-spinner {
    display: block;
}

@keyframes apexSpin {
    to { transform: rotate(360deg); }
}


/* ════════════════════════════════════════════════════════════════════════════
   8. BOOKING STEP
   ════════════════════════════════════════════════════════════════════════════ */
.apex-cb-booking {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    padding-top: 4px;
}

/* Primary booking CTA button */
.apex-cb-book-btn {
    display: inline-flex;
    align-items: center;
    padding: 15px 30px;
    background: var(--apex-accent);
    color: #ffffff !important;
    text-decoration: none !important;
    border-radius: var(--apex-btn-radius);
    font-family: var(--apex-font);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.01em;
    transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
    cursor: pointer;
    border: none;
    -webkit-appearance: none;
    appearance: none;
}

.apex-cb-book-btn:hover {
    background: var(--apex-accent-hover);
    box-shadow: 0 6px 20px rgba(15,45,82,0.28);
    transform: translateY(-1px);
}

.apex-cb-book-btn:active {
    transform: translateY(0) scale(0.98);
}

/* Subtext below the CTA */
.apex-cb-booking-sub {
    font-size: 12px;
    color: #8a93a4;
    margin: 0;
    font-style: italic;
    letter-spacing: 0.01em;
}

/* Calendly inline widget container */
.calendly-inline-widget {
    width: 100%;
    border-radius: var(--apex-msg-radius);
    overflow: hidden;
}


/* ════════════════════════════════════════════════════════════════════════════
   9. DIVIDER
   ════════════════════════════════════════════════════════════════════════════ */
.apex-cb-divider {
    height: 1px;
    background: #edf0f5;
    margin: 0;
    border: none;
}


/* ════════════════════════════════════════════════════════════════════════════
   10. RESPONSIVE
   ════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
    .apex-chatbot-wrap {
        padding: 20px 0;
    }

    .apex-cb-card {
        border-radius: 0;
        box-shadow: none;
    }

    .apex-cb-header {
        padding: 18px 20px;
    }

    .apex-cb-messages {
        padding: 20px 20px 12px;
        max-height: 280px;
    }

    .apex-cb-interaction {
        padding: 8px 20px 24px;
    }

    .apex-cb-message {
        max-width: 92%;
    }

    .apex-cb-submit {
        width: 100%;
        justify-content: center;
    }

    .apex-cb-book-btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 400px) {
    .apex-cb-option {
        font-size: 13px;
        padding: 12px 16px;
    }
}
