/**
 * ET Chatbot Embedder - v6.0
 * Unified launcher with choice menu
 */

/* Chat Button - Rendered in WordPress DOM */
.etce-chat-button {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    color: white;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.etce-chat-button:hover {
    transform: scale(1.05);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
}

.etce-chat-button:active {
    transform: scale(0.95);
}

/* Pulse dot indicator */
.etce-pulse-dot {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    background-color: #10b981;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.1);
    }
}

/* Chat icon */
.etce-chat-icon {
    transition: transform 0.3s ease;
}

.etce-chat-button:hover .etce-chat-icon {
    transform: scale(1.1);
}

/* Choice Menu - Popup above the button */
.etce-choice-menu {
    position: fixed;
    bottom: 100px;
    right: 24px;
    flex-direction: column;
    gap: 8px;
    z-index: 1000000;
    animation: etce-menu-slide-up 0.2s ease-out;
}

@keyframes etce-menu-slide-up {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.etce-choice-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: white !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 12px;
    cursor: pointer;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: #1f2937 !important;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
    min-width: 220px;
}

.etce-choice-option:hover,
.etce-choice-option:focus,
.etce-choice-option:active {
    background: #f3f4f6 !important;
    border-color: #d1d5db !important;
    color: #1f2937 !important;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
    transform: translateX(-4px);
}

.etce-choice-option span {
    color: #1f2937 !important;
}

.etce-choice-icon {
    flex-shrink: 0;
    color: #6366f1;
}

.etce-choice-livechat .etce-choice-icon {
    color: #42a8df;
}

/* Iframe Wrapper - Hidden by default */
#etce-iframe-wrapper {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 400px;
    height: 100%;
    z-index: 999998;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
}

#etce-chatbot-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
}

/* Desktop Layout - Content Shift */
.etce-site-wrapper {
    transition: width 0.3s ease-out;
    width: 100%;
}

/*
 * Breadcrumb / full-bleed fix when chat is open:
 * Kadence sets --global-vw on .wp-site-blocks (#wrapper) to ~100vw. Alignfull and
 * similar rows use margin-left: calc(50% - var(--global-vw)/2), which pulls content
 * past the narrowed .etce-site-wrapper; body overflow-x then clips the left edge.
 * Use the wrapper width as the "viewport" for those calcs instead.
 */
body.etce-chat-open-desktop {
    overflow-x: visible;
}

body.etce-chat-open-desktop .etce-site-wrapper {
    width: calc(100% - 400px);
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
}

body.etce-chat-open-desktop .etce-site-wrapper #wrapper.site {
    --global-vw: 100%;
}

/* Yoast (and similar) breadcrumbs if they use breakout margins */
body.etce-chat-open-desktop .etce-site-wrapper .yoast-breadcrumb,
body.etce-chat-open-desktop .etce-site-wrapper .yoast-breadcrumbs {
    max-width: 100%;
    box-sizing: border-box;
}

/* === Algolia Refinements Panel — Desktop Only === */
/* When the AI concierge is open on desktop, hide the Zen Agency filter
   panel entirely. Mobile is left untouched. */
body.etce-chat-open-desktop #zen-agency-algolia-refinements-panel {
    display: none !important;
}

@media (max-width: 767px) {
    body.etce-chat-open-desktop #zen-agency-algolia-refinements-panel,
    body.etce-chat-open-mobile #zen-agency-algolia-refinements-panel {
        display: revert !important;
    }
}

/* === LiveChat overlay backdrop === */
/* Dims the concierge iframe area while LiveChat is open over it.
   Sits ABOVE #etce-iframe-wrapper (z-index 999998) and BELOW the native
   LiveChat widget container (~2147483600). pointer-events:auto so the
   backdrop swallows clicks targeted at the dimmed concierge — closing
   LiveChat is only done via its own minimize button. (The native LiveChat
   widget sits at a much higher z-index, so its clicks are unaffected.) */
.etce-livechat-backdrop {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 400px;
    background: rgba(0, 0, 0, 0.45);
    z-index: 999999;
    pointer-events: auto;
    opacity: 0;
    transition: opacity 0.3s ease-out;
}

.etce-livechat-backdrop.etce-visible {
    opacity: 1;
}

body.admin-bar .etce-livechat-backdrop {
    top: 32px;
}

@media screen and (max-width: 782px) {
    body.admin-bar .etce-livechat-backdrop {
        top: 46px;
    }
}

@media (max-width: 767px) {
    .etce-livechat-backdrop {
        width: 100%;
    }
}

/* "Back to AI Concierge" pill — sits above the backdrop and below the
   native LiveChat widget container (~2147483600). Only rendered while
   LiveChat overlays the dimmed concierge. */
/* All visual properties use !important so the host WordPress theme's
   global button:hover / a:hover styles can't recolor the pill's text
   or background out from under us. */
.etce-back-to-concierge,
.etce-back-to-concierge:hover,
.etce-back-to-concierge:focus,
.etce-back-to-concierge:focus-visible,
.etce-back-to-concierge:active,
.etce-back-to-concierge:visited {
    color: #111111 !important;
    text-decoration: none !important;
    text-shadow: none !important;
}

.etce-back-to-concierge {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1000000;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: none !important;
    border-radius: 999px !important;
    background: #ffffff !important;
    font: 600 13px/1.2 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.25s ease-out, transform 0.25s ease-out, background-color 0.15s ease-out, box-shadow 0.15s ease-out;
}

.etce-back-to-concierge:hover {
    background: #f3f4f6 !important;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}

.etce-back-to-concierge:focus,
.etce-back-to-concierge:focus-visible {
    background: #f3f4f6 !important;
    outline: none !important;
}

.etce-back-to-concierge:focus-visible {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.5), 0 4px 14px rgba(0, 0, 0, 0.25);
}

.etce-back-to-concierge.etce-visible {
    opacity: 1;
    transform: translateY(0);
}

body.admin-bar .etce-back-to-concierge {
    top: 48px;
}

@media screen and (max-width: 782px) {
    body.admin-bar .etce-back-to-concierge {
        top: 62px;
    }
}

/* Mobile Layout - Full Screen Overlay */
body.etce-chat-open-mobile {
    overflow: hidden;
}

body.etce-chat-open-mobile #etce-iframe-wrapper {
    width: 100%;
}

/* WordPress Admin Bar Handling */
body.admin-bar #etce-iframe-wrapper {
    top: 32px;
    height: calc(100% - 32px);
}

@media screen and (max-width: 782px) {
    body.admin-bar #etce-iframe-wrapper {
        top: 46px;
        height: calc(100% - 46px);
    }
}

/* Mobile Breakpoint */
@media (max-width: 767px) {
    #etce-iframe-wrapper {
        width: 100%;
    }
    
    .etce-chat-button {
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
    }
    
    .etce-choice-menu {
        bottom: 88px;
        right: 20px;
    }
    
    .etce-choice-option {
        font-size: 13px;
        padding: 10px 16px;
        min-width: 200px;
    }
}
