/**
 * Chat Widget Styles
 */
.vac-widget {
    --vac-primary: #0073aa;
    --vac-secondary: #f0f0f1;
    --vac-cta-bg: #ff5722;
    --vac-cta-text: #ffffff;

    position: fixed;
    bottom: var(--vac-bottom-desktop, 20px);
    z-index: 2147483647;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
}

.vac-widget.vac-bottom-right {
    right: var(--vac-side-desktop, 20px);
}

.vac-widget.vac-bottom-left {
    left: var(--vac-side-desktop, 20px);
}

/* --- CTA Bubble - Reinforced --- */
#vac-chat-widget .vac-cta-bubble {
    position: absolute;
    bottom: 75px;
    background: var(--vac-cta-bg);
    padding: 5px 18px !important;
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    color: var(--vac-cta-text);
    animation: vacSlideIn 0.4s ease-out;
    transform-origin: bottom right;
    transition: all 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.05);
    z-index: 1000000;
    margin: 0 !important;
    line-height: normal !important;
}

#vac-chat-widget.vac-bottom-right .vac-cta-bubble {
    right: 0;
    border-bottom-right-radius: 4px;
}

#vac-chat-widget.vac-bottom-left .vac-cta-bubble {
    left: 0;
    border-bottom-left-radius: 4px;
    transform-origin: bottom left;
}

#vac-chat-widget .vac-cta-bubble::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 20px;
    width: 12px;
    height: 12px;
    background: var(--vac-cta-bg);
    transform: rotate(45deg);
    box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.05);
}

#vac-chat-widget.vac-bottom-left .vac-cta-bubble::after {
    right: auto;
    left: 20px;
}

#vac-chat-widget .vac-cta-close {
    background: rgba(0, 0, 0, 0.05) !important;
    border: none !important;
    border-radius: 50% !important;
    width: 20px !important;
    height: 20px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    font-size: 16px !important;
    line-height: 1 !important;
    color: var(--vac-cta-text) !important;
    opacity: 0.8;
    padding: 0 !important;
    transition: all 0.2s;
    margin: 0 !important;
}

#vac-chat-widget .vac-cta-close:hover {
    background: rgba(0, 0, 0, 0.1) !important;
    color: #333 !important;
}

@keyframes vacSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Chat Button */
.vac-chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--vac-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 5px 20px rgba(var(--vac-primary-rgb, 0, 115, 170), 0.4);
    transition: transform 0.3s, box-shadow 0.3s;
    position: relative;
    z-index: 2;
}

.vac-chat-button:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 25px rgba(var(--vac-primary-rgb, 0, 115, 170), 0.5);
}

.vac-chat-button .vac-icon-chat,
.vac-chat-button .vac-icon-close {
    transition: opacity 0.3s, transform 0.3s;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.vac-widget.vac-open .vac-icon-chat {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(90deg) scale(0);
}

.vac-widget.vac-open .vac-icon-close {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(0) scale(1);
    display: block;
}

.vac-chat-button svg {
    width: 28px;
    height: 28px;
    color: #fff;
}

.vac-chat-button .vac-icon-close {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-90deg) scale(0);
}

/* Pulse Animation */
/* Pulse Animation - Consolidated in footer section */


/* Chat Window */
.vac-chat-window {
    position: absolute;
    bottom: 80px;
    width: 380px;
    max-height: 600px;
    height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: vacSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.vac-widget.vac-open .vac-chat-window {
    display: flex;
}

.vac-bottom-right .vac-chat-window {
    right: 0;
}

.vac-bottom-left .vac-chat-window {
    left: 0;
}

/* Header */
.vac-header {
    background: var(--vac-primary);
    background: linear-gradient(135deg, var(--vac-primary), #005a87);
    color: #fff;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.vac-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.vac-header-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: visible;
    /* Allow dot to be outside */
}

#vac-agent-avatar-container {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vac-agent-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.vac-avatar-icon {
    font-size: 24px;
}

.vac-online-dot {
    position: absolute;
    bottom: -2px;
    /* Slight adjustment */
    right: -2px;
    /* Slight adjustment */
    width: 12px;
    height: 12px;
    background: #00c853;
    border: 2px solid #fff;
    /* White border to stand out */
    border-radius: 50%;
    z-index: 10;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.vac-header-title {
    font-weight: 700;
    font-size: 16px;
    line-height: 1.2;
}

.vac-header-subtitle {
    font-size: 12px;
    opacity: 0.85;
    margin-top: 2px;
}

.vac-header-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    transition: background 0.2s;
}

.vac-header-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Body */
.vac-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #f9f9f9;
}

/* Messages */
.vac-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Messages Layout */
.vac-message {
    display: flex;
    animation: vacFadeIn 0.3s;
    max-width: 80%;
    margin-bottom: 5px;
}

/* Visitor (ME/RIGHT) */
.vac-message.vac-visitor {
    align-self: flex-end;
    justify-content: flex-end;
}

/* AI/Staff (THEM/LEFT) */
.vac-message.vac-ai,
.vac-message.vac-staff {
    align-self: flex-start;
    justify-content: flex-start;
}

.vac-message.vac-ai {
    flex-direction: row;
    align-self: flex-start;
}

.vac-message.vac-ai::before {
    content: attr(data-avatar);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--vac-secondary);
    border-radius: 50%;
    margin-right: 8px;
    flex-shrink: 0;
    font-size: 16px;
    margin-top: auto;
}

/* If avatar image is available, we will handle it via JS adding a class or replacing ::before */
.vac-message.vac-ai.vac-has-avatar::before {
    content: '';
    background-image: var(--vac-agent-avatar-url);
    background-size: cover;
    background-position: center;
}

.vac-message-bubble {
    padding: 10px 15px;
    border-radius: 18px;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* AI/Staff Style (Gray/White) */
.vac-message.vac-ai .vac-message-bubble,
.vac-message.vac-staff .vac-message-bubble {
    background: #fff;
    color: #333;
    border-bottom-left-radius: 4px;
    border: 1px solid #e5e5e5;
}

.vac-message-bubble strong {
    color: var(--vac-primary);
    font-weight: 700;
}

.vac-chat-h3 {
    margin: 12px 0 8px 0;
    font-size: 1.1em;
    font-weight: 700;
    color: var(--vac-primary);
    border-bottom: 2px solid var(--vac-primary);
    display: inline-block;
    padding-bottom: 2px;
}

.vac-chat-h3:first-child {
    margin-top: 5px;
}

/* Visitor Style (Primary Color) */
.vac-message.vac-visitor .vac-message-bubble {
    background: var(--vac-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 5px rgba(var(--vac-primary-rgb, 0, 115, 170), 0.2);
}

.vac-message-time {
    font-size: 10px;
    color: #999;
    margin-top: 4px;
    margin-bottom: 2px;
}

.vac-message.vac-visitor .vac-message-time {
    text-align: right;
    margin-right: 4px;
}

.vac-message.vac-ai .vac-message-bubble,
.vac-message.vac-staff .vac-message-bubble {
    background: #fff;
    color: #333;
    border-bottom-left-radius: 4px;
    border: 1px solid #e5e5e5;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* Skeleton Loading */
.vac-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: vacSkeleton 1.5s infinite;
    border-radius: 8px;
}

@keyframes vacSkeleton {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.vac-message.vac-ai.vac-loading .vac-message-bubble {
    width: 60%;
    height: 40px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
}

.vac-skeleton-line {
    height: 10px;
    width: 100%;
    border-radius: 4px;
}

.vac-skeleton-line:last-child {
    width: 60%;
}

/* Chat Buttons / Links */
.vac-chat-btn {
    display: inline-block;
    margin-top: 8px;
    padding: 8px 16px;
    background-color: var(--vac-primary);
    color: #fff !important;
    /* Force white text */
    text-decoration: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    transition: background-color 0.2s, transform 0.1s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.vac-chat-btn:hover {
    filter: brightness(0.9);
    transform: translateY(-1px);
    text-decoration: none;
    color: #fff;
}

/* Input Area - Reinforced for Flatsome */
#vac-chat-widget .vac-input-area {
    padding: 15px;
    background: #fff;
    border-top: 1px solid #eee;
    box-sizing: border-box;
}

#vac-chat-widget .vac-input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f5f5f5;
    border-radius: 24px;
    padding: 6px 6px 6px 16px;
    border: 1px solid transparent;
    transition: border-color 0.2s, background 0.2s;
    box-sizing: border-box;
    margin: 0;
}

#vac-chat-widget .vac-input-wrapper:focus-within {
    background: #fff;
    border-color: var(--vac-primary);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

#vac-chat-widget .vac-input-wrapper textarea {
    flex: 1;
    border: none !important;
    background: transparent !important;
    resize: none;
    font-size: 14px;
    max-height: 100px;
    padding: 8px 0 !important;
    line-height: 1.4;
    color: #333;
    box-shadow: none !important;
    margin: 0 !important;
    min-height: 20px;
    font-family: inherit;
}

#vac-chat-widget .vac-input-wrapper textarea:focus {
    outline: none !important;
    background: transparent !important;
}

#vac-chat-widget .vac-send-btn,
#vac-chat-widget .vac-upload-btn {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    border-radius: 50% !important;
    border: none !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none;
}

#vac-chat-widget .vac-send-btn {
    background: var(--vac-primary) !important;
    color: #fff !important;
    opacity: 1;
}

#vac-chat-widget .vac-send-btn:disabled {
    background: #ccc !important;
    cursor: default;
}

#vac-chat-widget .vac-send-btn svg {
    width: 18px;
    height: 18px;
    margin-left: 2px;
    fill: currentColor;
    display: block;
}

/* Pulse Animation */
.vac-chat-button.vac-pulse::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--vac-primary);
    opacity: 0.5;
    z-index: -1;
    transform: translate(-50%, -50%);
    animation: vacPulse 2s infinite;
}

@keyframes vacPulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.5;
    }

    70% {
        transform: translate(-50%, -50%) scale(1.6);
        opacity: 0;
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0;
    }
}

/* Unread Badge */
.vac-unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff3b30;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    border: 2px solid #fff;
}

/* Animations */
@keyframes vacSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes vacFadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 480px) {
    .vac-widget {
        bottom: var(--vac-bottom-mobile, 85px) !important;
        /* Move up to avoid bottom nav */
    }

    .vac-widget.vac-bottom-right {
        right: var(--vac-side-mobile, 20px) !important;
    }

    .vac-widget.vac-bottom-left {
        left: var(--vac-side-mobile, 20px) !important;
    }

    .vac-chat-window {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
        margin: 0 !important;
        z-index: 2147483648 !important;
        /* Ensure it's on top of everything inside the widget context */
    }

    .vac-cta-bubble {
        display: none !important;
        /* Hide bubble on mobile to save space */
    }
}

/* =========================================
   Typing Indicator
   ========================================= */
#vac-typing {
    display: flex;
    align-self: flex-start;
    max-width: 80%;
    animation: vacFadeIn 0.3s;
    padding: 0 20px 10px;
}

#vac-typing .vac-message-bubble {
    background: #fff;
    color: #333;
    border-bottom-left-radius: 4px;
    border: 1px solid #e5e5e5;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.vac-typing-dots {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 0;
}

.vac-typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--vac-primary);
    border-radius: 50%;
    animation: vacTypingBounce 1.2s infinite ease-in-out;
    opacity: 0.6;
}

.vac-typing-dots span:nth-child(1) {
    animation-delay: 0s;
}

.vac-typing-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.vac-typing-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes vacTypingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0) scale(1);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-8px) scale(1.1);
        opacity: 1;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    }
}

/* Quick Replies Area */
.vac-quick-replies {
    padding: 10px 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background: #fff;
    border-top: 1px solid #f0f0f0;
}

.vac-quick-reply {
    background: #fff;
    border: 1px solid var(--vac-primary);
    color: var(--vac-primary);
    padding: 6px 14px;
    border-radius: 18px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.vac-quick-reply:hover {
    background: var(--vac-primary);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(var(--vac-primary-rgb, 0, 115, 170), 0.2);
}

.vac-chat-image {
    margin: 10px 0;
    max-width: 100%;
    border-radius: 8px;
    overflow: hidden;
}

.vac-chat-image img {
    display: block;
    width: 100%;
    height: 150px;
    object-fit: cover;
    object-position: center;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
}

.vac-chat-image img:hover {
    transform: scale(1.02);
}

/* Clickable Image Lightbox Effect */
.vac-image-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.vac-image-lightbox.active {
    opacity: 1;
    visibility: visible;
}

.vac-image-lightbox img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}

.vac-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.vac-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* =========================================
   List Items in Chat
   ========================================= */
.vac-list-item {
    margin: 4px 0;
    padding-left: 18px;
    line-height: 1.6;
    position: relative;
    display: block;
}

.vac-list-item::before {
    content: '•';
    position: absolute;
    left: 4px;
    top: 0;
    color: var(--vac-primary);
    font-weight: 700;
    font-size: 1.2em;
}

.vac-message-bubble br {
    display: inline;
}

.vac-message-bubble strong {
    color: var(--vac-primary);
    font-weight: 700;
}


/* =========================================
   View Details Button
   ========================================= */
.vac-view-details-btn {
    display: block;
    width: 100%;
    margin-top: 12px;
    padding: 10px 16px;
    background: linear-gradient(135deg, var(--vac-primary) 0%, #005a87 100%);
    color: #fff !important;
    text-align: center;
    text-decoration: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 115, 170, 0.3);
}

.vac-view-details-btn:hover {
    background: linear-gradient(135deg, #005a87 0%, var(--vac-primary) 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.4);
    color: #fff !important;
    text-decoration: none;
}

/* Fancybox Integration */
.vac-chat-image a {
    display: block;
    cursor: zoom-in;
}

.vac-chat-image a:hover img {
    opacity: 0.9;
}

/* =========================================
   Pre-chat Form Styles - Reinforced
   ========================================= */
#vac-chat-widget .vac-prechat {
    padding: 30px 25px 25px;
    display: flex;
    flex-direction: column;
    gap: 25px;
    animation: vacFadeIn 0.3s ease-out;
    background: #fff;
    box-sizing: border-box;
}

#vac-chat-widget .vac-prechat-greeting p {
    margin: 0 !important;
    font-size: 15px !important;
    color: #444 !important;
    line-height: 1.6 !important;
    text-align: center;
    font-weight: 500;
}

#vac-visitor-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 0 !important;
    padding: 0 !important;
}

#vac-chat-widget .vac-form-group {
    position: relative;
    margin: 0 !important;
    padding: 0 !important;
}

#vac-chat-widget .vac-form-group input {
    width: 100% !important;
    padding: 14px 18px !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 12px !important;
    font-size: 15px !important;
    transition: all 0.3s ease;
    background: #f9f9f9 !important;
    box-sizing: border-box;
    color: #333 !important;
    margin: 0 !important;
    height: auto !important;
    min-height: 48px !important;
    box-shadow: none !important;
}

#vac-chat-widget .vac-form-group input::placeholder {
    color: #aaa !important;
}

#vac-chat-widget .vac-form-group input:focus {
    outline: none !important;
    border-color: var(--vac-primary) !important;
    box-shadow: 0 0 0 4px rgba(var(--vac-primary-rgb, 0, 115, 170), 0.1) !important;
    background: #fff !important;
}

#vac-chat-widget .vac-btn-start {
    width: 100% !important;
    padding: 16px !important;
    background: var(--vac-primary) !important;
    background: linear-gradient(135deg, var(--vac-primary) 0%, #005a87 100%) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 12px !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 4px 12px rgba(var(--vac-primary-rgb, 0, 115, 170), 0.3) !important;
    margin-top: 10px !important;
    height: auto !important;
    text-transform: none !important;
    line-height: normal !important;
}

#vac-chat-widget .vac-btn-start:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(var(--vac-primary-rgb, 0, 115, 170), 0.4) !important;
}

#vac-chat-widget .vac-btn-start:active {
    transform: translateY(1px);
    box-shadow: 0 2px 5px rgba(var(--vac-primary-rgb, 0, 115, 170), 0.2) !important;
}