/**
 * Estilos del Widget de Chat Bot
 * WooCommerce Bot Connector
 */

/* ========== CONTENEDOR PRINCIPAL ========== */
.wbc-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ========== BOTÓN FLOTANTE ========== */
.wbc-chat-trigger {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    border: none;
    outline: none;
}

.wbc-chat-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.5);
}

.wbc-chat-trigger svg {
    width: 28px;
    height: 28px;
    fill: white;
}

/* Badge de notificación */
.wbc-chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
}

/* ========== VENTANA DE CHAT ========== */
.wbc-chat-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.wbc-chat-window.active {
    display: flex;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========== HEADER ========== */
.wbc-chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.wbc-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.wbc-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.wbc-chat-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.wbc-chat-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 5px;
}

.wbc-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.wbc-chat-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.wbc-chat-close:hover {
    opacity: 1;
}

/* ========== BANNER DE AUTENTICACIÓN ========== */
.wbc-auth-banner {
    padding: 12px 20px;
    font-size: 13px;
    text-align: center;
    border-bottom: 1px solid #e5e7eb;
}

.wbc-auth-banner.logged-in {
    background: #d1fae5;
    color: #065f46;
}

.wbc-auth-banner.guest {
    background: #fef3c7;
    color: #92400e;
}

.wbc-auth-banner a {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
}

/* ========== ÁREA DE MENSAJES ========== */
.wbc-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.wbc-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.wbc-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.wbc-chat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

/* ========== MENSAJE ========== */
.wbc-message {
    display: flex;
    gap: 10px;
    animation: messageIn 0.3s ease;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wbc-message.user {
    flex-direction: row-reverse;
}

.wbc-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.wbc-message.bot .wbc-message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.wbc-message.user .wbc-message-avatar {
    background: #3b82f6;
    color: white;
}

.wbc-message-content {
    max-width: 75%;
}

.wbc-message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.wbc-message.bot .wbc-message-bubble {
    background: white;
    color: #1f2937;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.wbc-message.user .wbc-message-bubble {
    background: #3b82f6;
    color: white;
    border-bottom-right-radius: 4px;
}

.wbc-message-time {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 4px;
    padding: 0 8px;
}

/* ========== INDICADOR DE ESCRITURA ========== */
.wbc-typing-indicator {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: white;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.wbc-typing-indicator.active {
    display: flex;
}

.wbc-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    animation: typing 1.4s infinite;
}

.wbc-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.wbc-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* ========== ÁREA DE ENTRADA ========== */
.wbc-chat-input-wrapper {
    border-top: 1px solid #e5e7eb;
    padding: 16px 20px;
    background: white;
}

.wbc-chat-input-container {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.wbc-chat-input {
    flex: 1;
    border: 2px solid #e5e7eb;
    border-radius: 24px;
    padding: 12px 16px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    /* max-height: 100px; */  /* <--- LA ELIMINAMOS */
    overflow-y: hidden;   /* <--- CAMBIAMOS 'auto' A 'hidden' */
    transition: border-color 0.2s;
    box-sizing: border-box; /* <--- Añadimos esto por seguridad */
}



.wbc-chat-input:focus {
    outline: none;
    border-color: #667eea;
}

.wbc-chat-input::placeholder {
    color: #9ca3af;
}

.wbc-chat-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.wbc-chat-send:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.wbc-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.wbc-chat-send svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* ========== MENSAJE DE BIENVENIDA ========== */
.wbc-welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
}

.wbc-welcome-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.wbc-welcome-title {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 8px;
}

.wbc-welcome-text {
    font-size: 14px;
    line-height: 1.5;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 480px) {
    .wbc-chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 80px;
        right: 10px;
        left: 10px;
        max-height: calc(100vh - 100px);
    }
    
    .wbc-chat-trigger {
        bottom: 15px;
        right: 15px;
    }
}

/* ========== MODO OSCURO (opcional) ========== */
@media (prefers-color-scheme: dark) {
    .wbc-chat-window {
        background: #1f2937;
    }
    
    .wbc-chat-messages {
        background: #111827;
    }
    
    .wbc-message.bot .wbc-message-bubble {
        background: #374151;
        color: #f3f4f6;
    }
    
    .wbc-chat-input-wrapper {
        background: #1f2937;
        border-top-color: #374151;
    }
    
    .wbc-chat-input {
        background: #374151;
        color: #f3f4f6;
        border-color: #4b5563;
    }
    
    .wbc-typing-indicator {
        background: #374151;
    }

    /* --- AÑADE ESTO --- */
        .wbc-chat-input:focus {
            color: #f3f4f6; /* Asegura que el texto siga siendo claro al escribir */
            border-color: #667eea; /* Mantenemos el borde de foco que ya tenías */
        }
        /* --- FIN DE LO AÑADIDO --- */

        .wbc-typing-indicator {
            background: #374151;
        }


}

/* Estilos para imágenes en avatares */
.wbc-chat-avatar img,
.wbc-message-avatar img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Estilos para icono personalizado en burbuja */
.wbc-chat-trigger img {
    display: block;
}