/* ======================================================
   n8n Chatbot - Estilos v4.0
   Autor: Lucas Turza
====================================================== */

/* === Botón flotante del chat === */
#n8n-chatbot-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: #0073aa;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 9998;
    transition: transform 0.2s;
}

#n8n-chatbot-toggle:hover {
    transform: scale(1.1);
}

#n8n-chatbot-toggle svg {
    color: white;
}

/* === Ventana principal del chatbot === */
#n8n-chatbot-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 420px;
    height: 600px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    transition: all 0.3s ease;
}

/* === Modo Fullscreen === */
#n8n-chatbot-window.fullscreen {
    bottom: 0 !important;
    right: 0 !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border-radius: 0 !important;
    max-width: 100% !important;
}

/* === Encabezado del chat === */
#n8n-chatbot-header {
    background: #0073aa;
    color: white;
    padding: 15px;
    border-radius: 10px 10px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#n8n-chatbot-window.fullscreen #n8n-chatbot-header {
    border-radius: 0;
}

#n8n-chatbot-header h3 {
    margin: 0;
    font-size: 18px;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

#n8n-chatbot-fullscreen,
#n8n-chatbot-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

#n8n-chatbot-fullscreen:hover,
#n8n-chatbot-close:hover {
    background: rgba(255,255,255,0.2);
}

#n8n-chatbot-close {
    font-size: 24px;
}

.bot-avatar-header {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

/* === Contenedor de mensajes === */
#n8n-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.n8n-message-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin-bottom: 12px;
}

.n8n-message-wrapper.user {
    justify-content: flex-end;
}

.n8n-message-wrapper.bot {
    justify-content: flex-start;
}

.bot-avatar-msg {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    margin-top: 2px;
}

.n8n-message {
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 75%;
    word-wrap: break-word;
    line-height: 1.5;
    white-space: pre-wrap;
}

.user-message {
    background: #0073aa;
    color: white;
}

.bot-message {
    background: #f1f1f1;
    color: #333;
}

.n8n-message a {
    color: inherit;
    text-decoration: underline;
    font-weight: bold;
}

.n8n-message a:hover {
    opacity: 0.8;
}

/* === Botón de Calendly === */
.calendly-button {
    background: #0073aa;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    margin-top: 8px;
    transition: background 0.2s;
}

.calendly-button:hover {
    background: #005a87;
}

/* === Contenedor del input === */
#n8n-chatbot-input-container {
    display: flex;
    padding: 15px;
    border-top: 1px solid #e1e1e1;
    gap: 10px;
    align-items: flex-end;
}

#n8n-chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 20px;
    outline: none;
    font-family: inherit;
    font-size: 14px;
    resize: none;
    max-height: 120px;
    min-height: 44px;
    line-height: 1.4;
}

#n8n-chatbot-input:focus {
    border-color: #0073aa;
}

#n8n-chatbot-send {
    background: #0073aa;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

#n8n-chatbot-send:hover {
    background: #005a87;
}

#n8n-chatbot-send:disabled {
    background: #ccc;
    cursor: not-allowed;
}

#n8n-chatbot-send svg {
    width: 20px;
    height: 20px;
}

/* === Indicador de escritura === */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px 15px !important;
    max-width: fit-content !important;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* === Responsive === */
@media (max-width: 768px) {
    #n8n-chatbot-window {
        width: calc(100% - 40px);
        height: calc(100% - 110px);
        bottom: 90px;
        right: 20px;
        left: 20px;
    }
    
    .n8n-message {
        max-width: 85%;
    }
}

/* === Personalización del pop-up de Calendly === */
.calendly-overlay {
    background: rgba(0, 0, 0, 0.55) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 999999 !important;
}

.calendly-popup-content {
    max-width: 600px !important;
    width: 90% !important;
    margin: 0 auto !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35) !important;
    position: relative !important;
}

.calendly-close {
    position: absolute !important;
    top: 12px !important;
    right: 12px !important;
    background: #0073aa !important;
    color: #fff !important;
    width: 28px !important;
    height: 28px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 18px !important;
    cursor: pointer !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25) !important;
    z-index: 100000 !important;
}

.calendly-close:hover {
    background: #005a87 !important;
}