/**
 * Estilos del Chatbot
 * Ubicación: assets/css/chatbot.css
 */

/* Variables CSS */
:root {
    --dcb-primary: #2563eb;
    --dcb-primary-hover: #1d4ed8;
    --dcb-bg-light: #f9fafb;
    --dcb-text-dark: #1f2937;
    --dcb-text-light: #6b7280;
    --dcb-border: #e5e7eb;
    --dcb-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    --dcb-shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.15);
}

/* Contenedor principal */
#dcb-chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Botón flotante */
.dcb-chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--dcb-primary) 0%, var(--dcb-primary-hover) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--dcb-shadow);
    transition: all 0.3s ease;
    position: relative;
}

.dcb-chat-button:hover {
    transform: scale(1.1);
    box-shadow: var(--dcb-shadow-lg);
}

.dcb-chat-button svg {
    width: 28px;
    height: 28px;
}

/* Badge de notificación */
.dcb-notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid white;
}

/* Ventana del chat */
.dcb-chat-window {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 140px);
    background: white;
    border-radius: 16px;
    box-shadow: var(--dcb-shadow-lg);
    display: none; /* Oculta por defecto */
    flex-direction: column;
    overflow: hidden;
    animation: dcbSlideUp 0.3s ease;
}

@keyframes dcbSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- CAMBIO APLICADO --- */
/* Muestra la ventana del chat cuando tiene la clase .dcb-open */
.dcb-chat-window.dcb-open {
    display: flex;
}

/* La regla para ocultar el botón ya no es necesaria, la gestiona el JS */

/* Header del chat */
.dcb-chat-header {
    background: linear-gradient(135deg, var(--dcb-primary) 0%, var(--dcb-primary-hover) 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dcb-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dcb-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.dcb-header-avatar svg {
    width: 24px;
    height: 24px;
}

.dcb-header-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.dcb-status {
    font-size: 12px;
    opacity: 0.9;
}

.dcb-close-button {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.dcb-close-button:hover {
    background: rgba(255, 255, 255, 0.1);
}

.dcb-close-button svg {
    width: 20px;
    height: 20px;
}

/* Área de mensajes */
.dcb-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--dcb-bg-light);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.dcb-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.dcb-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.dcb-chat-messages::-webkit-scrollbar-thumb {
    background: var(--dcb-border);
    border-radius: 3px;
}

/* Mensajes */
.dcb-message {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    animation: dcbMessageSlide 0.3s ease;
}

@keyframes dcbMessageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dcb-message-user {
    flex-direction: row-reverse;
}

.dcb-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--dcb-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.dcb-message-avatar svg {
    width: 18px;
    height: 18px;
}

.dcb-message-user .dcb-message-avatar {
    background: #10b981;
}

.dcb-message-content {
    flex: 1;
    max-width: 75%;
}

.dcb-message-bubble {
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    color: var(--dcb-text-dark);
    line-height: 1.5;
    font-size: 14px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.dcb-message-user .dcb-message-bubble {
    background: var(--dcb-primary);
    color: white;
}

/* Indicador de escritura */
.dcb-typing-indicator {
    padding: 0 20px 10px;
}

.dcb-typing-dots {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.dcb-typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--dcb-text-light);
    animation: dcbTypingAnimation 1.4s infinite;
}

.dcb-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.dcb-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dcbTypingAnimation {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Input del chat */
.dcb-chat-input {
    padding: 16px;
    background: white;
    border-top: 1px solid var(--dcb-border);
}

.dcb-chat-input form {
    display: flex;
    gap: 10px;
    align-items: center;
}

#dcb-message-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--dcb-border);
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#dcb-message-input:focus {
    border-color: var(--dcb-primary);
}

.dcb-send-button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--dcb-primary);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.dcb-send-button:hover {
    background: var(--dcb-primary-hover);
    transform: scale(1.05);
}

.dcb-send-button:disabled {
    background: var(--dcb-border);
    cursor: not-allowed;
    transform: scale(1);
}

.dcb-send-button svg {
    width: 20px;
    height: 20px;
}

/* Responsive */
@media (max-width: 480px) {
    .dcb-chat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 120px);
        right: 20px;
        bottom: 90px;
    }
    
    #dcb-chatbot-container {
        bottom: 10px;
        right: 10px;
    }
}

/* Estados de carga */
.dcb-loading .dcb-send-button {
    pointer-events: none;
}

.dcb-loading .dcb-send-button svg {
    animation: dcbRotate 1s linear infinite;
}

@keyframes dcbRotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}