/* Live Chat Container */
.live-chat-container {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-2xl);
    padding: 2rem;
    height: 600px;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* Chat Header */
.chat-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 1.5rem;
}

.chat-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-accent-primary), var(--color-accent-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    position: relative;
}

.chat-status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #22c55e;
    border: 2px solid var(--color-bg-secondary);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.chat-info h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--color-text-primary);
}

.chat-info p {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}

/* Chat Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding-right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(125, 125, 125, 0.1);
    border-radius: 3px;
}

/* Message Bubbles */
.message {
    max-width: 80%;
    padding: 1rem 1.25rem;
    border-radius: 1.25rem;
    font-size: 1rem;
    line-height: 1.5;
    position: relative;
    animation: messageSlideIn 0.3s ease-out forwards;
    opacity: 0;
    transform: translateY(10px);
}

@keyframes messageSlideIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.bot {
    align-self: flex-start;
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
    border-bottom-left-radius: 0.25rem;
}

.message.user {
    align-self: flex-end;
    background: var(--color-accent-primary);
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.message-time {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-top: 0.5rem;
    display: block;
}

/* Message Content Formatting */
.message strong {
    font-weight: 600;
    color: var(--color-accent-primary);
}

.message.user strong {
    color: rgba(255, 255, 255, 0.95);
    font-weight: 700;
}

.message em {
    font-style: italic;
    opacity: 0.9;
}

.message ul {
    margin: 0.75rem 0;
    padding-left: 1.25rem;
    list-style: none;
}

.message li {
    position: relative;
    padding-left: 0.5rem;
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.message li:before {
    content: "•";
    position: absolute;
    left: -1rem;
    color: var(--color-accent-primary);
    font-weight: bold;
}

.message.user li:before {
    color: rgba(255, 255, 255, 0.8);
}

.message br {
    display: block;
    content: "";
    margin-top: 0.5rem;
}

/* Clickable Links/Buttons in Messages */
.chat-link-btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    margin: 0.25rem 0.25rem 0.25rem 0;
    background: linear-gradient(135deg, var(--color-accent-primary), var(--color-accent-secondary));
    color: white;
    text-decoration: none;
    border-radius: var(--radius-lg);
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.chat-link-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.chat-link-btn:active {
    transform: translateY(0);
}

/* Typing Indicator */
.typing-indicator {
    display: none;
    align-self: flex-start;
    background: var(--color-bg-tertiary);
    padding: 1rem;
    border-radius: 1.25rem;
    border-bottom-left-radius: 0.25rem;
    gap: 0.25rem;
    width: fit-content;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--color-text-secondary);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    }
}

/* Input Area */
.chat-input-area {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
    display: flex;
    gap: 1rem;
}

.chat-input {
    flex: 1;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    padding: 1rem;
    color: var(--color-text-primary);
    font-family: inherit;
    resize: none;
    max-height: 100px;
    outline: none;
    transition: all 0.3s ease;
}

.chat-input:focus {
    border-color: var(--color-accent-primary);
    background: var(--color-bg-glass-hover);
}

.chat-send-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--color-accent-primary);
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.chat-send-btn:hover {
    transform: scale(1.1);
    background: var(--color-accent-secondary);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Mobile Floating Chat */
.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .mobile-only {
        display: flex;
    }

    .live-chat-container {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 85vh;
        z-index: 9999;
        margin: 0;
        border-radius: 20px 20px 0 0;
        transform: translateY(110%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        background: var(--color-bg-secondary);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5);
    }

    .live-chat-container.active {
        transform: translateY(0);
    }

    .chat-trigger-btn {
        position: fixed;
        bottom: 20px;
        right: 20px;
        width: 60px;
        height: 60px;
        border-radius: 50%;
        background: var(--color-accent-primary);
        border: none;
        color: white;
        box-shadow: 0 10px 25px rgba(99, 102, 241, 0.3);
        cursor: pointer;
        z-index: 10000;
        animation: chatBounce 2s infinite;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .chat-close-btn {
        background: none;
        border: none;
        color: var(--color-text-secondary);
        cursor: pointer;
        padding: 0.5rem;
    }

    .chat-header-btn {
        background: none;
        border: none;
        color: var(--color-text-secondary);
        cursor: pointer;
        padding: 0.5rem;
        transition: color 0.3s;
    }

    .chat-header-btn:hover {
        color: var(--color-text-primary);
    }


    /* Modern Language Switcher */
    .chat-lang-switcher {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.5rem 0.75rem;
        background: var(--color-bg-glass);
        border: 1px solid var(--glass-border);
        border-radius: var(--radius-lg);
        color: var(--color-text-secondary);
        cursor: pointer;
        transition: all 0.3s ease;
        font-size: 0.875rem;
        font-weight: 500;
        margin-left: auto;
        /* Push to right, but before close button */
    }

    .chat-lang-switcher:hover {
        background: var(--color-bg-glass-hover);
        border-color: var(--color-accent-primary);
        color: var(--color-accent-primary);
    }

    /* ... styles ... */

    .chat-header {
        justify-content: flex-start;
        /* Changed from space-between to handle specific gaps */
        gap: 0.5rem;
        position: relative;
        padding-right: 0;
        z-index: 60;
        /* Ensure header controls (close btn) are clickable above lock overlay (z-index 50) */
        /* Let flex gap handle spacing */
    }

    .chat-info {
        max-width: 140px;
        /* Prevent text expansion pushing buttons off */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Polished Mobile Close Button */
    .chat-close-btn {
        background: var(--color-bg-tertiary);
        /* Distinct background */
        border: 1px solid var(--glass-border);
        color: var(--color-text-secondary);
        cursor: pointer;
        width: 40px;
        /* Larger touch target */
        height: 40px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        margin-left: 0.5rem;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    }

    .chat-close-btn:hover {
        background: var(--color-bg-glass-hover);
        color: var(--color-text-primary);
        transform: scale(1.05) rotate(90deg);
        /* Playful interaction */
        border-color: var(--color-accent-primary);
    }

    .chat-close-btn:active {
        transform: scale(0.95) rotate(90deg);
    }


    @keyframes chatBounce {

        0%,
        100% {
            transform: translateY(0);
        }

        50% {
            transform: translateY(-5px);
        }
    }
}

/* Language Selection Stylized */
.lang-welcome-text {
    margin-bottom: 1.25rem;
    font-weight: 500;
    color: var(--color-text-primary);
}

.language-options {
    display: flex;
    flex-direction: column;
    /* Stack buttons vertically */
    gap: 0.75rem;
    align-items: center;
    /* Center them */
    justify-content: center;
    padding: 0.5rem;
    width: 100%;
}

.btn-lang {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.75rem;
    background: var(--color-bg-glass);
    /* Adaptive glass background */
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    overflow: hidden;
    min-width: 140px;
}

/* Glass shine effect - Adaptive */
.btn-lang::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right,
            transparent,
            var(--color-text-secondary),
            transparent);
    opacity: 0.1;
    transform: skewX(-25deg);
    transition: 0.5s;
    pointer-events: none;
}

/* Gradient Border Effect via pseduo-element */
.btn-lang::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 1rem;
    padding: 1px;
    background: linear-gradient(135deg, var(--color-text-secondary), transparent);
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    mask-composite: exclude;
    opacity: 0.3;
    transition: opacity 0.3s;
}

.btn-lang:hover {
    transform: translateY(-4px) scale(1.02);
    background: var(--color-bg-glass-hover);
    box-shadow:
        0 8px 20px -6px rgba(0, 0, 0, 0.1),
        /* Softer shadow */
        0 0 15px var(--glow-primary);
    border-color: var(--color-accent-primary);
}

.btn-lang:hover::before {
    left: 150%;
}

.btn-lang:hover::after {
    opacity: 0.8;
}

/* Text & Icon Styles */
.lang-icon {
    font-size: 1.5rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.lang-text {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    color: var(--color-text-secondary);
    font-size: 1rem;
    letter-spacing: 0.02em;
    transition: color 0.3s;
}

.btn-lang:hover .lang-text {
    color: var(--color-text-primary);
}

/* Selected State */
.btn-lang.selected {
    background: linear-gradient(135deg, var(--color-accent-primary), var(--color-accent-secondary));
    border-color: transparent;
    box-shadow: 0 0 20px var(--glow-primary);
    transform: scale(0.95);
}

.btn-lang.selected .lang-text {
    color: #ffffff;
    /* Always white on selected since it's an accent color background */
}

/* Disabled State (Non-selected ones) */
.btn-lang.disabled:not(.selected) {
    opacity: 0.4;
    cursor: default;
    transform: none;
    background: transparent;
    box-shadow: none;
}

/* Light Mode Overrides for Better Visibility */
[data-theme="light"] .btn-lang {
    background: rgba(255, 255, 255, 0.8);
    /* More solid for light mode */
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    /* Soft shadow for depth */
}

[data-theme="light"] .btn-lang:hover {
    box-shadow:
        0 10px 15px -3px rgba(0, 0, 0, 0.1),
        0 4px 6px -2px rgba(0, 0, 0, 0.05);
    background: #ffffff;
}

[data-theme="light"] .btn-lang::after {
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.1), transparent);
}

/* Floating WhatsApp Button */
.whatsapp-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #25D366;
    color: white;
    box-shadow: 0 4px 10px rgba(37, 211, 102, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: all 0.3s ease;
    animation: wa-pulse 2s infinite;
}

.whatsapp-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 14px rgba(37, 211, 102, 0.4);
}

@keyframes wa-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(37, 211, 102, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(37, 211, 102, 0);
    }
}

/* Ensure it moves up when chat trigger is present on mobile */
@media (max-width: 768px) {
    .whatsapp-btn {
        bottom: 100px;
        /* Above the chat trigger which is at bottom: 20px + height: 60px + gap */
        right: 20px;
    }

    /* Hide WhatsApp button when chat is open on mobile */
    body.chat-is-open .whatsapp-btn {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transform: translateY(20px);
    }

    /* Stack Social Floater above WhatsApp on Mobile */
    .social-floater {
        bottom: 180px !important;
        /* Stack: Chat(20) + WA(100) + Spacing */
        right: 20px !important;
        left: auto !important;
    }

    /* Hide Social Floater when chat is open on mobile */
    body.chat-is-open .social-floater {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transform: translateY(20px);
        transition: all 0.3s ease;
    }
}

/* Social Media Floater */
.social-floater {
    position: fixed;
    bottom: 90px;
    right: 20px;
    left: auto;
    z-index: 10000;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    pointer-events: none;
    /* KEY FIX: Let clicks pass through empty areas */
}

.social-floater-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--color-bg-secondary);
    border: 1px solid var(--glass-border);
    color: var(--color-text-primary);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
    pointer-events: auto;
    /* Restore clicks on the button itself */
}

/* Wrapper for overlapping icons */
.btn-icon-wrapper {
    position: relative;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.social-icon-default,
.social-icon-close {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.social-icon-close {
    opacity: 0;
    transform: rotate(-180deg) scale(0.5);
}

/* Active State for Button */
#socialFloaterBtn.active {
    background: var(--color-accent-primary);
    color: white;
}

#socialFloaterBtn.active .social-icon-default {
    opacity: 0;
    transform: rotate(180deg) scale(0.5);
}

#socialFloaterBtn.active .social-icon-close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

.social-floater.active .social-floater-list {
    pointer-events: auto;
    /* Enable clicks on list when active */
}

.social-floater-item {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--color-bg-glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.3s;
    pointer-events: none;
    /* Disable clicks when hidden */

    /* Animation Init State */
    opacity: 0;
    transform: translateY(20px) scale(0.8);
}

.social-floater.active .social-floater-item {
    pointer-events: auto;
    /* Enable clicks only when menu is active */
    opacity: 1;
    transform: translateY(0) scale(1);
}

.social-floater-item:hover {
    background: var(--color-accent-primary);
    color: white;
    transform: scale(1.1) !important;
    /* Override animation transform */
}

/* Staggered Animation on Active */
.social-floater.active .social-floater-item {
    opacity: 1;
    transform: translateY(0) scale(1);
    transition-delay: var(--d, 0s);
}

/* Hide/Lower Z-index when Mobile Menu is Active */
body.mobile-menu-active .whatsapp-btn,
body.mobile-menu-active .social-floater,
body.mobile-menu-active .chat-trigger-btn {
    z-index: 1 !important;
    /* Push behind mobile menu */
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
}

/* Chat Lock Overlay - Email Requirement */
.chat-lock-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.6);
    /* Lighter base for glass */
    backdrop-filter: blur(12px);
    /* Stronger blur */
    -webkit-backdrop-filter: blur(12px);
    z-index: 50;
    /* Above messages, below absolute header if we wanted, but lets cover everything inside container */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    border-radius: inherit;
    /* Inherit container radius */
}

[data-theme="dark"] .chat-lock-overlay {
    background: rgba(15, 23, 42, 0.6);
}

.chat-lock-card {
    background: rgba(255, 255, 255, 0.9);
    padding: 2rem;
    border-radius: 20px;
    box-shadow:
        0 20px 40px -5px rgba(0, 0, 0, 0.1),
        0 10px 20px -5px rgba(0, 0, 0, 0.05);
    width: 100%;
    max-width: 320px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.5);
    transform: translateY(10px);
    opacity: 0;
    animation: lockCardEntrance 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

[data-theme="dark"] .chat-lock-card {
    background: rgba(30, 41, 59, 0.9);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow:
        0 20px 40px -5px rgba(0, 0, 0, 0.3),
        0 10px 20px -5px rgba(0, 0, 0, 0.2);
}

@keyframes lockCardEntrance {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-lock-icon {
    font-size: 48px;
    margin-bottom: 1rem;
    display: inline-block;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
}

.chat-lock-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    line-height: 1.4;
}

.chat-lock-input {
    width: 100%;
    background: var(--bg-input, #f8fafc);
    border: 2px solid transparent;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 0.95rem;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .chat-lock-input {
    background: #0f172a;
    color: white;
}

.chat-lock-input:focus {
    background: var(--bg-card);
    border-color: var(--color-accent-primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
    outline: none;
}

.chat-lock-btn {
    width: 100%;
    background: var(--color-accent-primary);
    /* Use theme accent instead of hard black */
    color: white;
    border: none;
    padding: 0.875rem;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.2);
}

.chat-lock-btn:hover {
    background: var(--color-accent-secondary);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.3);
}

.chat-lock-btn:active {
    transform: scale(0.98);
}