/**
 * ByteTaller - Agente de Soporte al Cliente (Widget Chat)
 * Estética oficial alineada con el sitio web: Plus Jakarta Sans / Outfit
 */

:root {
    --bt-agent-gradient: linear-gradient(135deg, #0070f3 0%, #00d2ff 100%);
    --bt-agent-gradient-hover: linear-gradient(135deg, #005bb5 0%, #00b4db 100%);
    --bt-agent-gradient-client: linear-gradient(45deg, #10b981, #06b6d4);
    --bt-agent-font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --bt-agent-shadow: 0 12px 35px rgba(0, 112, 243, 0.25);
    --bt-agent-border: 1px solid rgba(255, 255, 255, 0.1);
}

/* 1. Botón Flotante de Lanzamiento */
.bt-chat-launcher {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: var(--bt-agent-gradient);
    color: #ffffff;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(0, 123, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

.bt-chat-launcher:hover {
    transform: translateY(-4px) scale(1.06);
    box-shadow: 0 14px 30px rgba(40, 167, 69, 0.5);
    background: var(--bt-agent-gradient-hover);
}

.bt-chat-launcher svg {
    width: 30px;
    height: 30px;
    transition: transform 0.3s ease;
}

.bt-chat-launcher.active svg.chat-icon {
    display: none;
}

.bt-chat-launcher:not(.active) svg.close-icon {
    display: none;
}

/* Pulso animado del launcher */
.bt-chat-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: inherit;
    opacity: 0.5;
    z-index: -1;
    animation: btPulse 2.5s cubic-bezier(0.25, 1, 0.5, 1) infinite;
}

@keyframes btPulse {
    0% { transform: scale(1); opacity: 0.6; }
    70% { transform: scale(1.4); opacity: 0; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* Badge de notificación */
.bt-chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ff4757;
    color: #ffffff;
    font-size: 11px;
    font-weight: 800;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #ffffff;
    font-family: var(--bt-agent-font);
    box-shadow: 0 2px 8px rgba(255, 71, 87, 0.5);
}

/* Burbuja de sugerencia inicial flotante */
.bt-chat-greeting-bubble {
    position: fixed;
    bottom: 96px;
    right: 25px;
    background: #ffffff;
    color: #1e293b;
    padding: 12px 18px;
    border-radius: 18px;
    font-family: var(--bt-agent-font);
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
    border: 1px solid #e2e8f0;
    z-index: 9998;
    max-width: 250px;
    animation: btSlideUp 0.4s ease-out;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.bt-chat-greeting-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 24px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #ffffff;
}

/* 2. Ventana de Chat */
.bt-chat-window {
    position: fixed;
    bottom: 98px;
    right: 25px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 560px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border-radius: 20px;
    box-shadow: var(--bt-agent-shadow);
    border: var(--bt-agent-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    font-family: var(--bt-agent-font);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.96);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.bt-chat-window.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Cabecera del Chat */
.bt-chat-header {
    background: var(--bt-agent-gradient);
    color: #ffffff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.2);
}

.bt-chat-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bt-chat-avatar {
    width: 44px;
    height: 44px;
    background: #ffffff;
    border-radius: 50%;
    padding: 3px;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.bt-chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

.bt-chat-status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 11px;
    height: 11px;
    background: #20c997;
    border: 2px solid #ffffff;
    border-radius: 50%;
}

.bt-chat-title h3 {
    font-size: 17px;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
    color: #ffffff;
}

.bt-chat-title span {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 5px;
}

.bt-chat-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
}

.bt-chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* Cuerpo de Mensajes */
.bt-chat-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Mensajes */
.bt-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: btFadeIn 0.3s ease;
}

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

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

.bt-bubble {
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.bt-message.bot .bt-bubble {
    background: #ffffff;
    color: #1e293b;
    border-radius: 16px 16px 16px 4px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.bt-message.bot .bt-bubble a {
    color: #007bff;
    font-weight: 700;
    text-decoration: underline;
}

.bt-message.user .bt-bubble {
    background: linear-gradient(135deg, #007bff, #1e40af);
    color: #ffffff;
    border-radius: 16px 16px 4px 16px;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.bt-message-time {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
    align-self: flex-end;
}

/* Opciones Rápidas (Quick Chips) */
.bt-quick-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.bt-chip {
    background: #ffffff;
    border: 1.5px solid #007bff;
    color: #007bff;
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--bt-agent-font);
    cursor: pointer;
    transition: all 0.25s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.bt-chip:hover {
    background: var(--bt-agent-gradient-client);
    border-color: transparent;
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(40, 167, 69, 0.3);
}

/* Indicador de Escritura (Typing Dots) */
.bt-typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: #ffffff;
    border-radius: 16px 16px 16px 4px;
    border: 1px solid #e2e8f0;
    width: fit-content;
}

.bt-dot {
    width: 7px;
    height: 7px;
    background: #007bff;
    border-radius: 50%;
    animation: btBlink 1.4s infinite both;
}

.bt-dot:nth-child(2) { animation-delay: 0.2s; background: #20c997; }
.bt-dot:nth-child(3) { animation-delay: 0.4s; background: #28a745; }

@keyframes btBlink {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Footer & Input */
.bt-chat-footer {
    padding: 12px 16px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
}

.bt-chat-form {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bt-chat-input {
    flex: 1;
    border: 2px solid #e1e5e9;
    border-radius: 25px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: var(--bt-agent-font);
    outline: none;
    transition: border-color 0.2s ease;
}

.bt-chat-input:focus {
    border-color: #007bff;
}

.bt-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bt-agent-gradient);
    border: none;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, background 0.2s ease;
    flex-shrink: 0;
}

.bt-chat-send:hover {
    transform: scale(1.08);
    background: var(--bt-agent-gradient-hover);
}

.bt-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Animaciones */
@keyframes btFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes btSlideUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive Móvil */
@media (max-width: 480px) {
    .bt-chat-window {
        bottom: 0;
        right: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .bt-chat-launcher {
        bottom: 18px;
        right: 18px;
    }
}
