/* TWLAdvisor - Frontend Styles */
:root {
    --twla-green: #2ECC71;
    --twla-orange: #F4A259;
    --twla-purple: #9B59B6;
    --twla-navy: #1F3864;
    --twla-teal: #1ABC9C;
    --twla-red: #E74C3C;
    --twla-bg: #f8f9fa;
    --twla-white: #ffffff;
    --twla-border: #e0e0e0;
    --twla-text: #333333;
    --twla-text-secondary: #666666;
    --twla-radius: 12px;
    --twla-radius-sm: 6px;
}

/* CONTAINER */
.twla-advisor {
    font-family: 'Lato', 'Arial', sans-serif;
    max-width: 640px;
    margin: 0 auto;
    padding: 1rem 0;
    color: var(--twla-text);
}

/* PHASES */
.twla-phase { display: none; }
.twla-phase--active { display: block; }

/* BUTTONS */
.twla-btn {
    display: inline-block;
    padding: 10px 24px;
    border-radius: var(--twla-radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: opacity 0.2s;
    font-family: inherit;
}
.twla-btn:hover { opacity: 0.88; }
.twla-btn--primary { background: var(--twla-teal); color: #fff; }
.twla-btn--send { background: var(--twla-teal); color: #fff; padding: 10px 18px; font-size: 14px; }
.twla-btn--outline { background: transparent; color: var(--twla-teal); border: 2px solid var(--twla-teal); }
.twla-btn--whatsapp { background: #25D366; color: #fff; margin-right: 8px; }
.twla-btn--email { background: var(--twla-navy); color: #fff; }
.twla-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* WELCOME SCREEN */
.twla-welcome { text-align: center; padding: 2rem 1rem; }
.twla-welcome__icon {
    width: 56px; height: 56px; border-radius: 50%;
    background: #E8F8F5; border: 2px solid var(--twla-teal);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 1rem; color: var(--twla-teal);
}
.twla-welcome__icon svg { width: 26px; height: 26px; }
.twla-welcome__headline { font-size: 22px; font-weight: 700; margin-bottom: 10px; color: var(--twla-navy); }
.twla-welcome__sub { font-size: 15px; color: var(--twla-text-secondary); line-height: 1.65; max-width: 440px; margin: 0 auto 1.25rem; }
.twla-welcome__checks { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-bottom: 1.5rem; }
.twla-check {
    font-size: 13px; color: var(--twla-text-secondary);
    padding: 4px 12px; background: #E8F8F5; border-radius: 20px;
    border: 1px solid #ABEBD4;
}

/* PROGRESS BAR */
.twla-progress-bar { height: 3px; background: var(--twla-border); border-radius: 2px; margin-bottom: 8px; }
.twla-progress-fill { height: 100%; background: var(--twla-teal); border-radius: 2px; transition: width 0.5s ease; }
.twla-progress-label { font-size: 12px; color: var(--twla-text-secondary); margin-bottom: 10px; }

/* CHAT */
.twla-chat {
    height: 300px; overflow-y: auto;
    padding: 1rem; border: 1px solid var(--twla-border);
    border-radius: var(--twla-radius); background: var(--twla-bg);
    margin-bottom: 12px;
    scroll-behavior: smooth;
}
.twla-bubble { margin-bottom: 12px; display: flex; }
.twla-bubble--ai { justify-content: flex-start; }
.twla-bubble--user { justify-content: flex-end; }
.twla-bubble-inner {
    max-width: 78%; padding: 10px 14px; font-size: 14px; line-height: 1.6;
    border-radius: var(--twla-radius);
}
.twla-bubble--ai .twla-bubble-inner {
    background: var(--twla-white); border: 1px solid var(--twla-border);
    color: var(--twla-text); border-radius: 4px 12px 12px 12px;
}
.twla-bubble--user .twla-bubble-inner {
    background: var(--twla-teal); color: #fff;
    border-radius: 12px 4px 12px 12px;
}
.twla-input-row { display: flex; gap: 8px; }
.twla-input {
    flex: 1; padding: 10px 14px; border: 1px solid var(--twla-border);
    border-radius: var(--twla-radius-sm); font-size: 14px;
    font-family: inherit; outline: none;
}
.twla-input:focus { border-color: var(--twla-teal); }
.twla-input:disabled { background: var(--twla-bg); }

/* TYPING DOTS */
.twla-typing { display: flex; gap: 5px; align-items: center; padding: 4px 0; }
.twla-typing span {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--twla-text-secondary);
    animation: twla-bounce 1.2s infinite;
}
.twla-typing span:nth-child(2) { animation-delay: 0.2s; }
.twla-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes twla-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* LEAD CAPTURE */
.twla-capture { text-align: center; padding: 2rem 1rem; }
.twla-capture__icon {
    width: 52px; height: 52px; border-radius: 50%;
    background: #E8F8F5; border: 2px solid var(--twla-teal);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 1rem; color: var(--twla-teal);
}
.twla-capture__icon svg { width: 24px; height: 24px; }
.twla-capture__headline { font-size: 20px; font-weight: 700; margin-bottom: 8px; color: var(--twla-navy); }
.twla-capture__sub { font-size: 14px; color: var(--twla-text-secondary); margin-bottom: 1.5rem; }
.twla-capture__form { max-width: 360px; margin: 0 auto; text-align: left; }
.twla-field { margin-bottom: 14px; }
.twla-field label { display: block; font-size: 13px; color: var(--twla-text-secondary); margin-bottom: 5px; font-weight: 500; }
.twla-field input {
    width: 100%; padding: 10px 14px; border: 1px solid var(--twla-border);
    border-radius: var(--twla-radius-sm); font-size: 14px;
    font-family: inherit; box-sizing: border-box; outline: none;
}
.twla-field input:focus { border-color: var(--twla-teal); }
.twla-generate-btn { width: 100%; padding: 12px; font-size: 15px; margin-top: 4px; }
.twla-capture__disclaimer { font-size: 12px; color: var(--twla-text-secondary); text-align: center; margin-top: 10px; }

/* LOADING */
.twla-loading { text-align: center; padding: 3rem 1rem; }
.twla-dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 14px; }
.twla-dots span {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--twla-teal); animation: twla-bounce 1.2s infinite;
}
.twla-dots span:nth-child(2) { animation-delay: 0.2s; }
.twla-dots span:nth-child(3) { animation-delay: 0.4s; }

/* GUIDE OUTPUT HEADER */
.twla-guide-actions { text-align: right; margin-bottom: 1rem; }

/* GUIDE DOCUMENT */
.twla-guide-doc {
    background: var(--twla-white); border: 1px solid var(--twla-border);
    border-radius: var(--twla-radius); padding: 2rem;
    line-height: 1.7;
}
.twla-guide-header { margin-bottom: 2rem; padding-bottom: 1.25rem; border-bottom: 2px solid var(--twla-teal); }
.twla-guide-label { font-size: 11px; font-weight: 700; color: var(--twla-teal); letter-spacing: 1px; text-transform: uppercase; margin-bottom: 8px; }
.twla-guide-title { font-size: 24px; font-weight: 700; color: var(--twla-navy); margin: 0; line-height: 1.3; }
.twla-guide-opening { font-size: 15px; font-weight: 600; color: var(--twla-navy); margin-bottom: 0.5rem; }
.twla-guide-section { margin-bottom: 1.25rem; }
.twla-guide-section p { font-size: 14px; color: var(--twla-text); margin: 0; }
.twla-guide-section--outcome { background: #E8F8F5; border-radius: var(--twla-radius-sm); padding: 1rem 1.25rem; }
.twla-guide-section--outcome p { font-weight: 500; }
.twla-guide-scripture { font-style: italic; color: var(--twla-purple); font-size: 14px; margin-top: 0.75rem; border-left: 3px solid var(--twla-purple); padding-left: 14px; }

/* PRODUCTS */
.twla-guide-products { margin: 2rem 0; }
.twla-guide-products-label { font-size: 12px; font-weight: 700; color: var(--twla-text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 1rem; }
.twla-product-card { border: 1px solid var(--twla-border); border-radius: var(--twla-radius); padding: 1.25rem; margin-bottom: 1rem; background: var(--twla-bg); }
.twla-product-name { font-size: 17px; font-weight: 700; color: var(--twla-navy); margin: 0 0 8px; }
.twla-product-why { font-size: 14px; color: var(--twla-text); line-height: 1.6; margin-bottom: 10px; }
.twla-product-benefits { list-style: none; padding: 0; margin: 0 0 12px; }
.twla-product-benefits li { font-size: 13px; color: var(--twla-text-secondary); padding: 2px 0 2px 18px; position: relative; }
.twla-product-benefits li::before { content: ""; position: absolute; left: 0; top: 9px; width: 6px; height: 6px; border-radius: 50%; background: var(--twla-teal); }
.twla-product-link { display: inline-block; background: var(--twla-teal); color: #fff; text-decoration: none; padding: 8px 18px; border-radius: var(--twla-radius-sm); font-size: 13px; font-weight: 600; }
.twla-store-backup { font-size: 12px; color: var(--twla-text-secondary); margin-top: 1rem; padding: 0.75rem 1rem; background: var(--twla-bg); border-radius: var(--twla-radius-sm); }
.twla-store-backup a { color: var(--twla-teal); }
.twla-african-cta { margin-top: 1rem; padding: 1rem 1.25rem; background: #FEF9F0; border: 1px solid var(--twla-orange); border-radius: var(--twla-radius-sm); }
.twla-african-cta p { font-size: 14px; margin-bottom: 0.75rem; }

/* ACTION / TIP / CLOSING */
.twla-guide-action { border-left: 3px solid var(--twla-teal); padding: 10px 14px; background: #E8F8F5; border-radius: 0 var(--twla-radius-sm) var(--twla-radius-sm) 0; margin: 1.25rem 0; }
.twla-guide-action-label { font-size: 11px; font-weight: 700; color: #0E7A5F; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.twla-guide-action p { font-size: 14px; color: #085841; margin: 0; }
.twla-guide-tip { border: 1px solid var(--twla-border); border-radius: var(--twla-radius-sm); padding: 1rem 1.25rem; margin: 1.25rem 0; }
.twla-guide-tip-label { font-size: 11px; font-weight: 700; color: var(--twla-text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.twla-guide-tip p { font-size: 14px; color: var(--twla-text); margin: 0; }
.twla-guide-closing { background: var(--twla-bg); border-radius: var(--twla-radius-sm); padding: 1rem 1.25rem; margin: 1.25rem 0; }
.twla-guide-closing p { font-size: 14px; color: var(--twla-text-secondary); margin: 0; font-style: italic; }
.twla-guide-caveat { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--twla-border); }
.twla-guide-caveat p { font-size: 11px; color: var(--twla-text-secondary); line-height: 1.6; margin: 0; }

/* PRINT STYLES */
@media print {
    .twla-guide-actions, .twla-welcome, .twla-chat, .twla-input-row,
    .twla-capture, .twla-loading, .twla-btn:not(.twla-product-link) { display: none !important; }
    .twla-guide-doc { border: none; padding: 0; }
    .twla-product-link { border: 1px solid #000 !important; }
    body * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* RESPONSIVE */
@media (max-width: 480px) {
    .twla-guide-doc { padding: 1rem; }
    .twla-welcome__headline { font-size: 18px; }
    .twla-guide-title { font-size: 20px; }
    .twla-welcome__checks { flex-direction: column; align-items: center; }
}

/* ================================================
   PRINT / PDF STYLES - Full width guide output
   ================================================ */
@media print {

    /* Hide site header, footer, navigation, widgets */
    #main-header,
    #et-main-area aside,
    .et_pb_section_parallax,
    #main-footer,
    footer,
    header,
    nav,
    .et-fixed-header,
    .et_fixed_nav,
    #top-header,
    .twla-guide-actions,
    .twla-welcome,
    .twla-phase:not(.twla-phase--active),
    .twla-chat,
    .twla-input-row,
    .twla-capture,
    .twla-loading,
    .twla-progress-bar,
    .twla-progress-label,
    .twla-btn:not(.twla-product-link):not(.twla-btn--whatsapp):not(.twla-btn--email) {
        display: none !important;
    }

    /* Reset Divi column constraints for print */
    html, body {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .et_pb_section,
    .et_pb_row,
    .et_pb_row_inner,
    .et_pb_column,
    .et_pb_column_inner,
    .et_pb_code,
    .et_pb_module,
    .et_pb_text {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        float: none !important;
        display: block !important;
    }

    /* Make advisor and guide full width */
    .twla-advisor,
    .twla-phase,
    .twla-guide-output,
    .twla-guide-content {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Style the guide document for print */
    .twla-guide-doc {
        border: none !important;
        padding: 15px 20px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Ensure product cards span full width */
    .twla-product-card {
        width: 100% !important;
        box-sizing: border-box !important;
        page-break-inside: avoid;
        margin-bottom: 20px !important;
    }

    /* Keep product links visible and styled */
    .twla-product-link {
        display: inline-block !important;
        border: 1px solid #1ABC9C !important;
        padding: 5px 12px !important;
        text-decoration: none !important;
    }

    /* Avoid breaking sections across pages */
    .twla-guide-section,
    .twla-guide-action,
    .twla-guide-tip,
    .twla-guide-closing,
    .twla-guide-caveat,
    .twla-african-cta {
        page-break-inside: avoid;
        width: 100% !important;
    }

    /* Ensure colours print */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }
}
