/* VariaVista Chatbot Widget - Premium Glassmorphism Design */

:root {
    /* Use global dynamic variable or fallback */
    --vv-chat-primary: var(--vv-primary, #2563eb);
    --vv-chat-bg: rgba(255, 255, 255, 0.85);
    --vv-chat-backdrop: blur(12px);
    --vv-chat-text: #1e293b;
    --vv-chat-text-light: #64748b;
    --vv-chat-border: rgba(255, 255, 255, 0.5);
    --vv-chat-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --vv-chat-radius: 16px;
    --vv-chat-font: 'Inter', system-ui, -apple-system, sans-serif;

    /* Contrast color for text/icons on primary background */
    --vv-chat-primary-contrast: var(--vv-primary-contrast, #ffffff);
}

/* Floating Button */
#vv-chat-launcher {
    position: fixed;
    bottom: 12px;
    right: 20px;
    width: 56px;
    height: 56px;
    background: var(--vv-chat-primary);
    border-radius: 50%;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
    cursor: pointer;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    color: var(--vv-chat-primary-contrast);
    /* Ensure text color matches contrast */
}

#vv-chat-launcher:hover {
    transform: scale(1.1);
}

#vv-chat-launcher svg {
    width: 30px;
    height: 30px;
    fill: var(--vv-chat-primary-contrast);
    /* Use calculated contrast color */
}

/* Chat Window */
#vv-chat-window {
    position: fixed;
    bottom: 75px;
    right: 20px;
    width: 380px;
    height: 520px;
    max-height: calc(100vh - 100px);
    background: var(--vv-chat-bg);
    backdrop-filter: var(--vv-chat-backdrop);
    -webkit-backdrop-filter: var(--vv-chat-backdrop);
    border: 1px solid var(--vv-chat-border);
    border-radius: var(--vv-chat-radius);
    box-shadow: var(--vv-chat-shadow);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: var(--vv-chat-font);
    overflow: hidden;
}

#vv-chat-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Header - Diseño profesional con gradiente */
.vv-chat-header {
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--vv-chat-primary), color-mix(in srgb, var(--vv-chat-primary) 80%, #000));
    border-bottom: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 60px;
}

.vv-chat-title {
    font-weight: 600;
    color: var(--vv-chat-primary-contrast);
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0; /* Permite truncar */
}

.vv-chat-title-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.vv-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: rgba(255,255,255,0.2);
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,0.3);
}

.vv-chat-close {
    background: rgba(255,255,255,0.15);
    border: none;
    cursor: pointer;
    color: var(--vv-chat-primary-contrast);
    padding: 6px;
    border-radius: 50%;
    transition: background 0.2s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vv-chat-close:hover {
    background: rgba(255,255,255,0.25);
}

.vv-chat-close svg {
    width: 18px;
    height: 18px;
    stroke: var(--vv-chat-primary-contrast);
    fill: none;
}

/* Messages Area */
.vv-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.vv-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
}

.vv-message.bot {
    align-self: flex-start;
    background: white;
    color: var(--vv-chat-text);
    border-bottom-left-radius: 2px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.vv-message.user {
    align-self: flex-end;
    background: var(--vv-chat-primary);
    color: white;
    border-bottom-right-radius: 2px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.vv-message-time {
    font-size: 10px;
    opacity: 0.7;
    margin-top: 4px;
    display: block;
    text-align: right;
}

/* Markdown Styles */
.vv-message-content ul,
.vv-message-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

.vv-message-content li {
    margin-bottom: 4px;
}

.vv-message-content strong {
    font-weight: 600;
}

.vv-message-content a {
    color: var(--vv-chat-primary);
    text-decoration: underline;
}

.vv-message.user .vv-message-content a {
    color: white;
}

/* Typing Indicator */
.vv-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 12px;
    border-bottom-left-radius: 2px;
    align-self: flex-start;
    width: fit-content;
}

.vv-dot {
    width: 6px;
    height: 6px;
    background: #cbd5e1;
    border-radius: 50%;
    animation: vv-bounce 1.4s infinite ease-in-out both;
}

.vv-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.vv-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes vv-bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Input Area */
.vv-chat-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    gap: 10px;
    align-items: center;
}

.vv-chat-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.vv-chat-input:focus {
    border-color: var(--vv-chat-primary);
}

.vv-chat-send {
    background: var(--vv-chat-primary);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.vv-chat-send:hover {
    transform: scale(1.05);
}

.vv-chat-send svg {
    width: 16px;
    height: 16px;
    fill: var(--vv-chat-primary-contrast);
    margin-left: 2px;
    /* Optical adjustment */
}

/* Mobile Responsive */
@media (max-width: 480px) {
    #vv-chat-window {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
        max-height: 100vh;
    }
}