/**
 * AI Chat Floating Widget Styles
 *
 * @package AI Chat by Purethemes
 * @since 1.0.0
 */

/* === Floating Widget Container === */
/* bottom/right/left offsets are set via inline styles from admin settings */
.listeo-floating-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
}

/* === Left Position === */
.listeo-floating-chat-widget.position-left {
    right: auto;
    left: 20px;
}

.listeo-floating-chat-widget.position-left .listeo-floating-chat-button {
    right: auto;
    left: 0;
}

.listeo-floating-chat-widget.position-left .listeo-floating-chat-popup {
    right: auto;
    left: 0;
}

.listeo-floating-chat-widget.position-left .listeo-floating-welcome-bubble-arrow {
    right: auto;
    left: 20px;
}

/* === Floating Button (60x60px circle) === */
.listeo-floating-chat-button {
    width: 60px !important;
    height: 60px !important;
    min-width: 60px !important;
    min-height: 60px !important;
    max-width: 60px !important;
    max-height: 60px !important;
    border-radius: 100px !important;
    background: #222;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease !important;
    position: absolute !important;
    z-index: 2;
    right: 0;
    bottom: 0;
    top: initial !important;
    padding: 0 !important;
}

.listeo-floating-chat-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.listeo-floating-chat-button.listeo-mini-chat-launcher-return {
    animation: listeoMiniChatLauncherReturn 0.22s cubic-bezier(0.2, 0.8, 0.2, 1) !important;
}

@keyframes listeoMiniChatLauncherReturn {
    from {
        opacity: 0;
        transform: scale(0.88);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* .listeo-floating-chat-button:active {
    transform: scale(0.95);
} */

.listeo-floating-chat-button i {
    color: white;
    font-size: 24px;
    transition: all 0.2s ease;
}
.listeo-floating-chat-button i.sl-icon-arrow-down { font-size: 18px; }
/* Custom icon image styling */
.listeo-floating-custom-icon {
    max-width: 32px;
    max-height: 32px;
    width: auto;
    height: auto;
    border-radius: 100px;
    object-fit: contain;
    transition: all 0.2s ease;
}

/* Icon toggle positioning */
.listeo-floating-icon-open,
.listeo-floating-icon-close {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 28px;
    height: 28px;
}

@supports selector(:has(*)) {
    .listeo-floating-chat-button .listeo-floating-icon-open,
    .listeo-floating-chat-button .listeo-floating-icon-close {
        display: block !important;
        pointer-events: none;
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
        transition: opacity 0.2s ease, transform 0.2s ease;
        will-change: opacity, transform;
    }

    .listeo-floating-chat-button .listeo-floating-icon-close {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0);
    }

    .listeo-floating-chat-widget:has(.listeo-floating-chat-popup[style*="display: block"]):not(:has(.listeo-floating-chat-popup[style*="opacity: 0"])) .listeo-floating-chat-button .listeo-floating-icon-open {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0);
    }

    .listeo-floating-chat-widget:has(.listeo-floating-chat-popup[style*="display: block"]):not(:has(.listeo-floating-chat-popup[style*="opacity: 0"])) .listeo-floating-chat-button .listeo-floating-icon-close {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* === Welcome Bubble === */
.listeo-floating-bubble-stack {
    position: absolute;
    right: 0;
    bottom: 75px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    width: 280px;
    max-width: calc(100vw - 30px);
    z-index: 1;
}

.listeo-floating-chat-widget.position-left .listeo-floating-bubble-stack {
    right: auto;
    left: 0;
    align-items: flex-start;
}

.listeo-floating-bubble-stack .listeo-floating-welcome-bubble {
    box-sizing: border-box;
    right: auto;
    left: auto;
    width: max-content;
    max-width: 100%;
    margin-bottom: 0;
    float: none;
}

.listeo-floating-bubble-stack .listeo-floating-welcome-bubble-arrow {
    display: none;
}

.listeo-floating-bubble-stack > .listeo-floating-welcome-bubble:last-of-type .listeo-floating-welcome-bubble-arrow {
    display: block;
}

.listeo-floating-welcome-bubble {
    right: 0;
    cursor: pointer;
    background: white;
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
    /* max-width: 280px; */
    animation: bubbleFadeIn 0.3s ease;
    z-index: 1;
    text-align: center;
    width: auto;
    margin-bottom: 75px;
    position: relative;
}

.listeo-floating-welcome-bubble-content {
    font-size: 14px;
    line-height: 20px;
    font-weight: 400;
    color: #555;
}

.listeo-floating-welcome-bubble-arrow {
    position: absolute;
    bottom: -6px;
    right: 20px;
    width: 12px;
    height: 12px;
    background: white;
    transform: rotate(45deg);
}

/* Hide welcome bubble */
.listeo-floating-welcome-bubble.hidden {
    display: none;
}

.listeo-floating-mini-chat {
    position: absolute;
    right: 0;
    bottom: 0;
    z-index: 3;
    display: block;
    visibility: hidden;
    box-sizing: border-box;
    width: 340px;
    max-width: calc(100vw - 30px);
    padding: 10px;
    border: none !important;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px) scale(0.94);
    transform-origin: bottom right;
    transition:
        opacity 0.22s ease,
        transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1),
        visibility 0s linear 0.22s;
}

.listeo-floating-mini-chat.is-visible {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
    transition-delay: 0s;
}

.listeo-floating-chat-widget.position-left .listeo-floating-mini-chat {
    right: auto;
    left: 0;
    transform-origin: bottom left;
}

.listeo-floating-mini-chat-close {
    position: absolute !important;
    top: -42px !important;
    right: 0 !important;
    display: inline-flex !important;
    box-sizing: border-box !important;
    width: 32px !important;
    min-width: 32px !important;
    max-width: 32px !important;
    height: 32px !important;
    min-height: 32px !important;
    max-height: 32px !important;
    margin: 0 !important;
    padding: 0 !important;
    align-items: center !important;
    justify-content: center !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: #f0f0f0 !important;
    box-shadow: none !important;
    color: #666 !important;
    cursor: pointer !important;
    appearance: none !important;
    transform: none !important;
    transition:
        background-color 0.2s ease,
        color 0.2s ease,
        transform 0.2s ease !important;
}

.listeo-floating-chat-widget.position-left .listeo-floating-mini-chat-close {
    right: auto !important;
    left: 0 !important;
}

.listeo-floating-mini-chat-message {
    max-height: 180px;
    overflow-y: auto;
    padding: 16px;
    border-radius: 10px;
    background: #f5f5f5;
    color: #333;
    font-size: 15px;
    line-height: 24px;
    white-space: pre-wrap;
}

.listeo-floating-mini-chat-quick-actions {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    margin: 10px 0 2px !important;
    padding: 0 !important;
}

.listeo-floating-mini-chat-quick-actions[hidden] {
    display: none !important;
}

.listeo-floating-mini-chat-quick-action {
    display: inline-flex !important;
    box-sizing: border-box !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 32px !important;
    margin: 0 !important;
    padding: 6px 12px !important;
    align-items: center !important;
    gap: 6px !important;
    border: none !important;
    border-radius: 8px !important;
    outline: 0 !important;
    background: #ebebeb !important;
    box-shadow: none !important;
    color: #777 !important;
    cursor: pointer !important;
    font: inherit !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    line-height: 20px !important;
    text-align: left !important;
    text-transform: none !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    appearance: none !important;
    transform: none !important;
    transition:
        background-color 0.2s ease,
        color 0.2s ease,
        transform 0.2s ease !important;
}

.listeo-floating-mini-chat-quick-action:hover {
    background: var(--quick-btn-color-light, var(--ai-chat-primary-color-light, rgba(0, 115, 238, 0.1))) !important;
    color: var(--quick-btn-color, var(--ai-chat-primary-color, #0073ee)) !important;
}

.listeo-floating-mini-chat-quick-action:active {
    transform: scale(0.97) !important;
}

.listeo-floating-mini-chat-quick-action:focus-visible {
    outline: 2px solid var(--quick-btn-color, var(--ai-chat-primary-color, #0073ee)) !important;
    outline-offset: 2px !important;
}

.listeo-floating-mini-chat-quick-action.listeo-floating-mini-chat-quick-action-custom {
    background: var(--quick-btn-color-light) !important;
    color: var(--quick-btn-color) !important;
}

.listeo-floating-mini-chat-quick-action.listeo-floating-mini-chat-quick-action-custom:hover {
    background: var(--quick-btn-color-light) !important;
    color: var(--quick-btn-color) !important;
}

.listeo-floating-mini-chat-quick-action.listeo-floating-mini-chat-quick-action-custom:focus-visible {
    outline-color: var(--quick-btn-color) !important;
}

.listeo-floating-mini-chat-form {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    align-items: center;
}

.listeo-floating-mini-chat-input {
    flex: 1 1 auto !important;
    box-sizing: border-box !important;
    width: 0 !important;
    min-width: 0 !important;
    height: 44px !important;
    min-height: 44px !important;
    max-height: 44px !important;
    margin: 0 !important;
    padding: 0 10px !important;
    border: 0 !important;
    border-radius: 0 !important;
    outline: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    color: #333 !important;
    font: inherit !important;
    font-size: 15px !important;
    line-height: 44px !important;
    appearance: none !important;
}

.listeo-floating-mini-chat-send {
    display: inline-flex !important;
    flex: 0 0 44px !important;
    box-sizing: border-box !important;
    width: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    max-height: 44px !important;
    margin: 0 !important;
    padding: 0 !important;
    align-items: center !important;
    justify-content: center !important;
    border: none !important;
    border-radius: 50% !important;
    background: var(--ai-chat-button-color, #222) !important;
    box-shadow: none !important;
    color: #fff !important;
    cursor: pointer !important;
    appearance: none !important;
    transform: none !important;
    transition:
        background-color 0.2s ease,
        color 0.2s ease,
        transform 0.2s ease !important;
}

.listeo-floating-mini-chat-close:hover,
.listeo-floating-mini-chat-close:focus-visible {
    background: #dcdcdc !important;
    transform: scale(1.03) !important;
}

.listeo-floating-mini-chat-send:hover,
.listeo-floating-mini-chat-send:focus-visible {
    background: var(--ai-chat-button-color, #222) !important;
    background: color-mix(in srgb, var(--ai-chat-button-color, #222) 88%, #000) !important;
    color: #fff !important;
    transform: scale(1.03) !important;
}

.listeo-floating-mini-chat-send svg,
.listeo-floating-mini-chat-send:hover svg,
.listeo-floating-mini-chat-send:focus-visible svg {
    color: #fff !important;
    stroke: #fff !important;
}

.listeo-floating-chat-widget.dark-mode .listeo-floating-mini-chat {
    background: #1a1a1a;
    color-scheme: dark;
}

.listeo-floating-chat-widget.dark-mode .listeo-floating-mini-chat-message {
    background: #2e2e2e !important;
    color: #e5e5e5;
}

.listeo-floating-chat-widget.dark-mode .listeo-floating-mini-chat-send,
.listeo-floating-chat-widget.dark-mode .listeo-floating-mini-chat-send:hover,
.listeo-floating-chat-widget.dark-mode .listeo-floating-mini-chat-send:focus-visible {
    background: var(--ai-chat-primary-color, #0073ee) !important;
    color: #fff !important;
}

.listeo-floating-chat-widget.dark-mode .listeo-floating-mini-chat-quick-action {
    background: #2b2b2b !important;
    color: #e5e5e5 !important;
}

.listeo-floating-chat-widget.dark-mode .listeo-floating-mini-chat-quick-action:hover {
    background: var(--quick-btn-color, var(--ai-chat-primary-color, #0073ee)) !important;
    color: #fff !important;
}

.listeo-floating-chat-widget.dark-mode .listeo-floating-mini-chat-quick-action.listeo-floating-mini-chat-quick-action-custom {
    background: var(--quick-btn-color) !important;
    color: #fff !important;
}

.listeo-floating-chat-widget.dark-mode .listeo-floating-mini-chat-quick-action.listeo-floating-mini-chat-quick-action-custom:hover {
    background: var(--quick-btn-color) !important;
}

.listeo-floating-chat-widget.dark-mode .listeo-floating-mini-chat-input {
    background: transparent !important;
    color: #e5e5e5 !important;
}

.listeo-floating-chat-widget.dark-mode .listeo-floating-mini-chat-input::placeholder {
    color: #999 !important;
    opacity: 1;
}

.listeo-floating-chat-widget.dark-mode .listeo-floating-mini-chat-close {
    background: #333 !important;
    color: #e5e5e5 !important;
}

.listeo-floating-chat-widget.dark-mode .listeo-floating-mini-chat-close:hover,
.listeo-floating-chat-widget.dark-mode .listeo-floating-mini-chat-close:focus-visible {
    background: #444 !important;
}

@media (prefers-reduced-motion: reduce) {
    .listeo-floating-mini-chat,
    .listeo-floating-mini-chat-quick-action {
        transition: none;
    }

    .listeo-floating-chat-button.listeo-mini-chat-launcher-return {
        animation: none !important;
    }
}

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

/* === Chat Popup (dimensions set via inline styles) === */
.listeo-floating-chat-popup {
    position: absolute;
    bottom: 75px;
    right: 0;
    /* width and height set dynamically via inline styles */
    background: white;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    animation: popupSlideIn 0.3s ease;
}

.listeo-floating-chat-popup.listeo-no-animation {
    animation: none !important;
}

@keyframes popupSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Override chat wrapper height for popup */
.listeo-floating-chat-popup .listeo-ai-chat-wrapper {
    display: block !important;
    height: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
}

.listeo-floating-chat-popup .listeo-ai-chat-container {
    height: 100%;
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
}


.listeo-floating-chat-popup { max-height: 75vh; }

@media (max-width: 768px) {
    .listeo-floating-chat-widget {
        bottom: 0;
        right: 0;
        left: auto;
        width: 100%;
    }

    .listeo-floating-chat-widget.position-left {
        left: 0;
        right: auto;
    }

    .listeo-floating-chat-popup {
        width: calc(100% - 30px) !important;
        height: calc(100vh - 100px) !important;
        bottom: 80px !important;
        right: 15px !important;
    }

    .listeo-floating-chat-widget.position-left .listeo-floating-chat-popup {
        right: auto !important;
        left: 15px !important;
    }

    .listeo-floating-chat-button {
        bottom: 20px;
        right: 20px;
        position: absolute;
        zoom: 0.8;
    }

    .listeo-floating-chat-widget.position-left .listeo-floating-chat-button {
        right: auto;
        left: 20px;
    }
    .listeo-floating-welcome-bubble {
         right: 15px;
        width: fit-content;
        float: right;
    }

    .listeo-floating-chat-widget.position-left .listeo-floating-welcome-bubble {
        float: left;
        right: auto;
        left: 15px;
    }

    .listeo-floating-bubble-stack {
        right: 15px;
    }

    .listeo-floating-chat-widget.position-left .listeo-floating-bubble-stack {
        right: auto;
        left: 15px;
    }

    .listeo-floating-chat-widget .listeo-floating-bubble-stack .listeo-floating-welcome-bubble {
        right: auto;
        left: auto;
        float: none;
    }

    .listeo-floating-mini-chat {
        right: 15px;
        bottom: 20px;
    }

    .listeo-floating-chat-widget.position-left .listeo-floating-mini-chat {
        right: auto;
        left: 15px;
    }
}

/* === Terms of Use Notice === */
.listeo-ai-chat-terms-notice {
    padding: 16px;
    padding-top: 0;
    font-size: 13px;
    line-height: 19px;
    text-align: center;
    margin-top: -5px;
    color: #666;
}

.listeo-ai-chat-terms-notice a {
    color: var(--ai-chat-primary-color);
    text-decoration: none;
}

.listeo-ai-chat-terms-notice a:hover {
    text-decoration: underline;
}

/* === Lazy Load State === */
/* Hide all chat content while scripts load, show only spinner */
.listeo-ai-chat-lazy-state .listeo-ai-chat-container {
    position: relative;
}

.listeo-ai-chat-lazy-state .listeo-ai-chat-header,
.listeo-ai-chat-lazy-state .listeo-ai-chat-messages,
.listeo-ai-chat-lazy-state .listeo-ai-chat-input-wrapper,
.listeo-ai-chat-lazy-state .listeo-ai-chat-quick-buttons,
.listeo-ai-chat-lazy-state .listeo-ai-chat-terms-notice,
.listeo-ai-chat-lazy-state .listeo-ai-chat-powered-by,
.listeo-ai-chat-lazy-state .listeo-ai-chat-menu {
    opacity: 0;
}

/* Spinner */
.listeo-ai-chat-lazy-state .listeo-ai-chat-container::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: #666;
    border-radius: 50%;
    animation: listeoLazyLoadSpin 0.7s linear infinite;
    z-index: 1;
}

.listeo-ai-chat-lazy-state.dark-mode .listeo-ai-chat-container::after {
    border-color: rgba(255, 255, 255, 0.15);
    border-top-color: #aaa;
}

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