/* Variables de color - Estilo moderno y corporativo */
:root {
    --chat-primary: #1a1a2e;
    --chat-accent: #e94560;
    --chat-accent-hover: #d13d56;
    --chat-bg: #f9f9f9;
    --chat-bubble-bot: #ffffff;
    --chat-bubble-user: #1a1a2e;
    --chat-text-bot: #333333;
    --chat-text-user: #ffffff;
    --chat-radius: 16px;
    --chat-shadow: 0 8px 32px rgba(0,0,0,0.18);
    --chat-font: 'Inter', 'Poppins', sans-serif;
}

/* Contenedor principal */
.gtdv-chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    font-family: var(--chat-font);
}

/* Botón flotante */
.gtdv-chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--chat-accent);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(233, 69, 96, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    animation: gtdv-pulse 2s infinite;
}

.gtdv-chatbot-toggle:hover {
    transform: scale(1.1);
}

@keyframes gtdv-pulse {
    0% { box-shadow: 0 0 0 0 rgba(233, 69, 96, 0.7); }
    70% { box-shadow: 0 0 0 15px rgba(233, 69, 96, 0); }
    100% { box-shadow: 0 0 0 0 rgba(233, 69, 96, 0); }
}

/* Ventana de chat */
.gtdv-chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    max-height: calc(100vh - 120px);
    background: var(--chat-bg);
    border-radius: var(--chat-radius);
    box-shadow: var(--chat-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: all 0.3s ease;
}

.gtdv-chatbot-window.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

/* Header */
.gtdv-chatbot-header {
    background: var(--chat-primary);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: var(--chat-radius);
    border-top-right-radius: var(--chat-radius);
}

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

.gtdv-chatbot-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gtdv-chatbot-header h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: white;
}

.gtdv-chatbot-status {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
    opacity: 0.8;
}

.gtdv-chatbot-status-dot {
    width: 8px;
    height: 8px;
    background-color: var(--chat-accent);
    border-radius: 50%;
    display: inline-block;
}

.gtdv-chatbot-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    padding: 5px;
}

.gtdv-chatbot-close:hover {
    opacity: 1;
}

/* Área de mensajes */
.gtdv-chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: var(--chat-bg);
}

.gtdv-chat-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: gtdv-slide-in 0.25s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

@keyframes gtdv-slide-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gtdv-chat-message.user {
    align-self: flex-end;
}

.gtdv-chat-message.bot, .gtdv-chat-message.agent {
    align-self: flex-start;
}

.gtdv-chat-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.gtdv-chat-message.user .gtdv-chat-bubble {
    background: var(--chat-bubble-user);
    color: var(--chat-text-user);
    border-bottom-right-radius: 4px;
}

.gtdv-chat-message.bot .gtdv-chat-bubble {
    background: var(--chat-bubble-bot);
    color: var(--chat-text-bot);
    border-bottom-left-radius: 4px;
}

.gtdv-chat-message.agent .gtdv-chat-bubble {
    background: #e3f2fd;
    color: var(--chat-accent);
    border-bottom-left-radius: 4px;
    border: 1px solid #bbdefb;
}

/* Typing indicator */
.gtdv-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--chat-bubble-bot);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

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

.gtdv-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.gtdv-typing-dot:nth-child(2) { animation-delay: -0.16s; }

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

/* Tarjetas de Producto */
.gtdv-chat-products {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
    width: 100%;
}

.gtdv-chat-product-card {
    display: flex;
    background: white;
    border: 1px solid #eee;
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
}

.gtdv-chat-product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.gtdv-chat-product-image {
    width: 70px;
    height: 70px;
    object-fit: cover;
    border-right: 1px solid #eee;
}

.gtdv-chat-product-info {
    padding: 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.gtdv-chat-product-name {
    margin: 0 0 5px 0;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gtdv-chat-product-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.gtdv-chat-product-price {
    font-weight: bold;
    color: var(--chat-accent);
    font-size: 14px;
}

.gtdv-chat-product-stock {
    font-size: 11px;
    background: #eee;
    padding: 2px 6px;
    border-radius: 10px;
}

.gtdv-chat-product-stock.in-stock { background: #e8f5e9; color: #2e7d32; }
.gtdv-chat-product-stock.low-stock { background: #fff3e0; color: #ef6c00; }
.gtdv-chat-product-stock.out-of-stock { background: #ffebee; color: #c62828; }

.gtdv-chat-product-btn {
    display: block;
    text-align: center;
    background: var(--chat-primary);
    color: white;
    padding: 5px;
    border-radius: 4px;
    font-size: 12px;
    text-decoration: none;
    margin-top: auto;
}

.gtdv-chat-product-btn:hover {
    background: #2a2a4a;
    color: white;
}

/* Footer / Formulario */
.gtdv-chatbot-footer {
    background: white;
    padding: 15px;
    border-top: 1px solid #eee;
    border-bottom-left-radius: var(--chat-radius);
    border-bottom-right-radius: var(--chat-radius);
}

.gtdv-chatbot-agent-wrapper {
    text-align: center;
    margin-bottom: 10px;
}

.gtdv-chatbot-request-agent {
    background: none;
    border: 1px solid #ddd;
    color: #666;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s;
}

.gtdv-chatbot-request-agent:hover {
    background: #f5f5f5;
    color: var(--chat-primary);
    border-color: #ccc;
}

.gtdv-chatbot-form {
    display: flex;
    align-items: center;
    background: #f5f5f5;
    border-radius: 20px;
    padding: 5px 5px 5px 15px;
}

.gtdv-chatbot-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 0;
    font-size: 14px;
    outline: none;
    font-family: inherit;
}

.gtdv-chatbot-submit {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--chat-accent);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.gtdv-chatbot-submit:hover {
    background: var(--chat-accent-hover);
}

/* Scrollbar personalizada */
.gtdv-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}
.gtdv-chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}
.gtdv-chatbot-messages::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 10px;
}

/* Responsividad */
@media (max-width: 480px) {
    .gtdv-chatbot-window {
        width: calc(100vw - 40px);
        height: 70vh;
        bottom: 80px;
        right: 20px;
    }
}
