/* WP Welcomer & AI Live Chat Styles */

.welcomer-chat-wrapper {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    box-sizing: border-box;
}

/* Positioning Classes with Dynamic Bottom Offset Clearance */
.welcomer-chat-wrapper.pos-bottom-right { bottom: var(--welcomer-bottom-offset, 75px); right: 25px; left: auto; top: auto; }
.welcomer-chat-wrapper.pos-bottom-left { bottom: var(--welcomer-bottom-offset, 75px); left: 25px; right: auto; top: auto; }
.welcomer-chat-wrapper.pos-top-right { top: 25px; right: 25px; left: auto; bottom: auto; }
.welcomer-chat-wrapper.pos-top-left { top: 25px; left: 25px; right: auto; bottom: auto; }

.welcomer-chat-wrapper *, 
.welcomer-chat-wrapper *:before, 
.welcomer-chat-wrapper *:after {
    box-sizing: border-box;
}

/* Floating WhatsApp Trigger Button with "Live Chat" Label */
.welcomer-trigger-btn {
    position: relative;
    height: 56px;
    padding: 0 20px 0 16px;
    border-radius: 28px;
    background-color: var(--welcomer-primary, #25D366);
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(37, 211, 102, 0.4);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
    outline: none;
    color: var(--welcomer-icon-color, #ffffff);
}

.welcomer-trigger-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 28px rgba(37, 211, 102, 0.5);
}

.welcomer-wa-icon path {
    fill: var(--welcomer-icon-color, #ffffff);
}

.welcomer-trigger-label {
    font-size: 15px;
    font-weight: 700;
    color: var(--welcomer-icon-color, #ffffff);
    letter-spacing: 0.3px;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.welcomer-pulse-ring {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 28px;
    border: 2px solid var(--welcomer-primary, #25D366);
    animation: welcomer-pulse 2s infinite ease-out;
}

@keyframes welcomer-pulse {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(1.2, 1.3); opacity: 0; }
}

.welcomer-badge-dot {
    position: absolute;
    top: 0px;
    right: 0px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #ffffff;
}

.welcomer-badge-dot.online { background-color: #2ecc71; }
.welcomer-badge-dot.offline { background-color: #95a5a6; }

/* Chat Window Box */
.welcomer-chat-box {
    position: absolute;
    bottom: 75px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 30px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s;
    transform-origin: bottom right;
}

.welcomer-chat-wrapper.pos-bottom-left .welcomer-chat-box {
    right: auto;
    left: 0;
    transform-origin: bottom left;
}

.welcomer-chat-wrapper.pos-top-right .welcomer-chat-box {
    bottom: auto;
    top: 75px;
    transform-origin: top right;
}

.welcomer-chat-wrapper.pos-top-left .welcomer-chat-box {
    bottom: auto;
    top: 75px;
    right: auto;
    left: 0;
    transform-origin: top left;
}

.welcomer-chat-box.welcomer-hidden {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.85) translateY(20px);
    pointer-events: none;
}

/* Header */
.welcomer-chat-header {
    background-color: var(--welcomer-header, #075E54);
    color: #ffffff;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.welcomer-avatar-wrap {
    position: relative;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

.welcomer-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #ffffff;
}

.welcomer-status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #ffffff;
}
.welcomer-status-dot.online { background-color: #2ecc71; }
.welcomer-status-dot.offline { background-color: #95a5a6; }

.welcomer-header-info {
    flex: 1;
    overflow: hidden;
}

.welcomer-chat-title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #ffffff;
}

.welcomer-status-text {
    font-size: 12px;
    opacity: 0.85;
    display: block;
    margin-top: 2px;
}

.welcomer-close-btn {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.8;
    padding: 0 4px;
    transition: opacity 0.2s;
}

.welcomer-close-btn:hover { opacity: 1; }

/* Tabs Bar */
.welcomer-chat-tabs {
    display: flex;
    background: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
    padding: 4px;
}

.welcomer-tab-btn {
    flex: 1;
    text-align: center;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 8px;
    color: #64748b;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.2s;
}

.welcomer-tab-btn.active {
    background: #ffffff;
    color: var(--welcomer-header, #075E54);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.welcomer-tab-btn.wa-btn:hover {
    color: #25D366;
}

/* Chat Messages Area */
.welcomer-chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background-color: #efeae2;
    background-image: radial-gradient(rgba(0,0,0,0.03) 1px, transparent 0);
    background-size: 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Login Lock View */
.welcomer-login-lock {
    background: #ffffff;
    padding: 24px 16px;
    border-radius: 12px;
    text-align: center;
    margin: auto 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.welcomer-lock-icon {
    font-size: 40px;
    margin-bottom: 8px;
}

.welcomer-login-lock h3 {
    margin: 0 0 8px 0;
    color: #1e293b;
    font-size: 16px;
}

.welcomer-login-lock p {
    font-size: 13px;
    color: #64748b;
    margin: 0 0 16px 0;
    line-height: 1.4;
}

.welcomer-login-btn {
    display: inline-block;
    background-color: var(--welcomer-primary, #25D366);
    color: #ffffff !important;
    text-decoration: none;
    font-weight: 700;
    font-size: 13px;
    padding: 10px 20px;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
    transition: transform 0.2s, background-color 0.2s;
}

.welcomer-login-btn:hover {
    transform: translateY(-2px);
    filter: brightness(0.95);
}

/* Message Bubbles */
.welcomer-message {
    display: flex;
    flex-direction: column;
    max-width: 82%;
}

.welcomer-message.user-msg {
    align-self: flex-end;
}

.welcomer-message.bot-msg {
    align-self: flex-start;
}

.welcomer-msg-content {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.45;
    word-break: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.welcomer-message.user-msg .welcomer-msg-content {
    background-color: var(--welcomer-bubble-user, #DCF8C6);
    color: #111b21;
    border-top-right-radius: 2px;
}

.welcomer-message.bot-msg .welcomer-msg-content {
    background-color: var(--welcomer-bubble-bot, #FFFFFF);
    color: #111b21;
    border-top-left-radius: 2px;
}

/* Links inside chat */
.welcomer-msg-content a {
    color: #0284c7;
    text-decoration: underline;
    word-break: break-all;
    font-weight: 600;
}

.welcomer-msg-content a:hover {
    color: #0369a1;
}

.welcomer-msg-time {
    font-size: 10px;
    color: #8696a0;
    margin-top: 3px;
    align-self: flex-end;
}

/* Typing Indicator */
.welcomer-typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: #ffffff;
    border-radius: 12px;
    width: fit-content;
}

.welcomer-typing-dots span {
    width: 6px;
    height: 6px;
    background-color: #8696a0;
    border-radius: 50%;
    animation: welcomer-bounce 1.4s infinite ease-in-out both;
}

.welcomer-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.welcomer-typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes welcomer-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Input Area */
.welcomer-chat-input-wrap {
    padding: 10px 12px;
    background: #f0f2f5;
    border-top: 1px solid #e2e8f0;
}

#welcomer-chat-form {
    display: flex;
    align-items: center;
    gap: 8px;
}

#welcomer-chat-input {
    flex: 1;
    height: 40px;
    border-radius: 20px;
    border: 1px solid #cbd5e1;
    padding: 0 16px;
    font-size: 13px;
    outline: none;
    background: #ffffff;
    transition: border-color 0.2s;
}

#welcomer-chat-input:focus {
    border-color: var(--welcomer-primary, #25D366);
}

.welcomer-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--welcomer-primary, #25D366);
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
    outline: none;
}

.welcomer-send-btn:hover {
    transform: scale(1.05);
}

/* Mobile Responsiveness (<600px) */
@media screen and (max-width: 600px) {
    .welcomer-chat-wrapper {
        bottom: var(--welcomer-bottom-offset, 75px);
        right: 15px;
    }

    .welcomer-chat-box {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
        bottom: 0;
    }
}
