/* Estilos principales del chatbot */

.netlogyc-chatbot-container {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Posiciones */

.netlogyc-chatbot-container.bottom-right {
    bottom: 20px;
    right: 20px;
}

.netlogyc-chatbot-container.bottom-left {
    bottom: 20px;
    left: 20px;
}

.netlogyc-chatbot-container.top-right {
    top: 20px;
    right: 20px;
}

.netlogyc-chatbot-container.top-left {
    top: 20px;
    left: 20px;
}

/* Mensaje de bienvenida - Diseño moderno */

.netlogyc-welcome-message {
    position: absolute;
    bottom: 70px;
    background: white;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    max-width: 220px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border: 1px solid;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 999998;
    text-align: center;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.netlogyc-welcome-message.active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    cursor: pointer;
}

.netlogyc-welcome-message::after {
    content: '';
    position: absolute;
    border: 6px solid transparent;
    border-top-color: currentColor;
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
}

/* Posicionamiento del mensaje de bienvenida */

.netlogyc-chatbot-container.bottom-right .netlogyc-welcome-message {
    right: 0;
}

.netlogyc-chatbot-container.bottom-left .netlogyc-welcome-message {
    left: 0;
}

.netlogyc-chatbot-container.top-right .netlogyc-welcome-message {
    bottom: auto;
    top: 70px;
}

.netlogyc-chatbot-container.top-right .netlogyc-welcome-message::after {
    bottom: auto;
    top: -12px;
    border-top-color: transparent;
    border-bottom-color: currentColor;
}

.netlogyc-chatbot-container.top-left .netlogyc-welcome-message {
    bottom: auto;
    top: 70px;
}

.netlogyc-chatbot-container.top-left .netlogyc-welcome-message::after {
    bottom: auto;
    top: -12px;
    border-top-color: transparent;
    border-bottom-color: currentColor;
}

/* Botón del chat */

.netlogyc-chatbot-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: all 0.3s ease;
    overflow: hidden;
    padding: 0;
    background: var(--netlogyc-primary-color, #007cba);
}

.netlogyc-chatbot-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

.netlogyc-chatbot-button img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.netlogyc-chatbot-button .icon-fallback {
    display: none;
    font-size: 24px;
    color: white;
}

.netlogyc-chatbot-button:has(img[src=""]) .icon-fallback,
.netlogyc-chatbot-button:has(img:not([src])) .icon-fallback {
    display: block;
}

.netlogyc-chatbot-button:has(img[src=""]) img,
.netlogyc-chatbot-button:has(img:not([src])) img {
    display: none;
}

/* Ventana del widget (desktop base) */

.netlogyc-chatbot-widget {
    position: absolute;
    width: 380px;
    max-width: 100vw;
    max-height: calc(100vh - 100px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e1e5e9;
}

/* Posicionamiento de la ventana */

.netlogyc-chatbot-container.bottom-right .netlogyc-chatbot-widget {
    bottom: 70px;
    right: 0;
    left: auto;
}

.netlogyc-chatbot-container.bottom-left .netlogyc-chatbot-widget {
    bottom: 70px;
    left: 0;
    right: auto;
}

.netlogyc-chatbot-container.top-right .netlogyc-chatbot-widget {
    top: 70px;
    right: 0;
    left: auto;
    bottom: auto;
}

.netlogyc-chatbot-container.top-left .netlogyc-chatbot-widget {
    top: 70px;
    left: 0;
    right: auto;
    bottom: auto;
}

.netlogyc-chatbot-widget.active {
    display: flex;
}

/* Header del chat */

.netlogyc-chatbot-header {
    padding: 18px 20px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--netlogyc-primary-color, #007cba) !important;
    color: var(--netlogyc-secondary-color, #ffffff) !important;
}

.netlogyc-chatbot-title {
    font-weight: 600;
    font-size: 16px;
    color: inherit;
}

/* Acciones header */

.netlogyc-chatbot-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.netlogyc-chatbot-refresh,
.netlogyc-chatbot-close {
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s ease;
    width: 32px;
    height: 32px;
}

.netlogyc-chatbot-refresh:hover,
.netlogyc-chatbot-close:hover {
    background-color: rgba(255, 255, 255, 0.15);
    transform: scale(1.1);
}

.netlogyc-chatbot-refresh svg,
.netlogyc-chatbot-close svg {
    width: 18px;
    height: 18px;
}

/* Área de mensajes */

.netlogyc-chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
    background: #fafbfc;
}

/* Mensajes */

.netlogyc-message.bot {
    align-self: flex-start;
    border-bottom-left-radius: 6px;
    background: var(--netlogyc-primary-color, #007cba) !important;
    color: var(--netlogyc-secondary-color, #ffffff) !important;
    max-width: 85%;
    padding: 14px 18px;
    border-radius: 18px;
    line-height: 1.4;
    word-wrap: break-word;
    font-size: 14px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.netlogyc-message.user {
    align-self: flex-end;
    border-bottom-right-radius: 6px;
    background: white;
    color: #333;
    border: 1px solid #e1e5e9;
    max-width: 85%;
    padding: 14px 18px;
    border-radius: 18px;
    line-height: 1.4;
    word-wrap: break-word;
    font-size: 14px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Mensajes temporales */

.netlogyc-temp-message {
    opacity: 0.8;
    font-style: italic;
}

/* Input */

.netlogyc-chatbot-input-container {
    padding: 0;
    border-top: 1px solid #f0f0f0;
    background: white;
}

.netlogyc-chatbot-input-wrapper {
    position: relative;
    margin: 16px;
    display: flex;
    align-items: center;
}

.netlogyc-chatbot-input {
    flex: 1;
    padding: 16px 60px 16px 20px !important;
    border: 2px solid #e1e5e9 !important;
    border-radius: 25px !important;
    outline: none !important;
    font-size: 14px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    background: #f8f9fa !important;
    transition: all 0.3s ease !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif !important;
    line-height: normal !important;
    height: auto !important;
    min-height: auto !important;
    margin: 0 !important;
    box-shadow: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

.netlogyc-chatbot-input:focus {
    border-color: var(--netlogyc-primary-color, #007cba) !important;
    background: white !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--netlogyc-primary-color, #007cba) 20%, transparent) !important;
}

.netlogyc-chatbot-input::placeholder {
    color: #999 !important;
    opacity: 1 !important;
}

/* Botón enviar */

.netlogyc-chatbot-send {
    position: absolute !important;
    right: 8px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    border: none !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    transition: all 0.3s ease !important;
    background: var(--netlogyc-primary-color, #007cba) !important;
    box-shadow: 0 4px 12px color-mix(in srgb, var(--netlogyc-primary-color, #007cba) 40%, transparent) !important;
    padding: 0 !important;
    margin: 0 !important;
    min-width: auto !important;
    min-height: auto !important;
}

.netlogyc-chatbot-send:hover {
    transform: translateY(-50%) scale(1.05) !important;
    box-shadow: 0 6px 16px color-mix(in srgb, var(--netlogyc-primary-color, #007cba) 50%, transparent) !important;
}

.netlogyc-chatbot-send:active {
    transform: translateY(-50%) scale(0.95) !important;
}

/* Icono envío */

.netlogyc-send-icon {
    width: 20px !important;
    height: 20px !important;
    display: block !important;
    color: white !important;
    fill: currentColor !important;
}

/* Indicador typing */

.netlogyc-typing-indicator {
    display: none;
    align-self: flex-start;
    padding: 14px 18px;
    background: #f1f1f1;
    border-radius: 18px;
    border-bottom-left-radius: 6px;
}

.netlogyc-typing-indicator.active {
    display: block;
}

.netlogyc-typing-dots {
    display: flex;
    gap: 4px;
}

.netlogyc-typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: netlogyc-typing 1.4s infinite ease-in-out;
}

.netlogyc-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.netlogyc-typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes netlogyc-typing {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Watermark protegido */

.netlogyc-chatbot-watermark {
    padding: 12px;
    text-align: center;
    background: #f9f9f9;
    border-top: 1px solid #eee;
    font-size: 11px;
    color: #888;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    flex-shrink: 0;
}

.netlogyc-chatbot-watermark a {
    color: #888;
    text-decoration: none;
    pointer-events: auto;
    font-weight: 500;
}

.netlogyc-chatbot-watermark a:hover {
    text-decoration: underline;
    color: #666;
}

.netlogyc-chatbot-watermark[data-protected="true"] {
    position: relative;
}

.netlogyc-chatbot-watermark[data-protected="true"]::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    pointer-events: none;
}

/* Responsive móviles */

@media (max-width: 768px) {

    .netlogyc-chatbot-container {
        bottom: 15px !important;
        right: 15px !important;
        left: 15px !important;
    }

    .netlogyc-chatbot-widget {
        position: fixed;
        width: 100vw;
        max-width: 100vw;
        height: 100vh !important;
        max-height: 100vh !important;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        border-radius: 0;
        border: none;
    }

    .netlogyc-chatbot-messages {
        padding: 16px;
    }

    .netlogyc-welcome-message {
        max-width: 180px;
        font-size: 13px;
        padding: 8px 12px;
    }

    .netlogyc-chatbot-input-wrapper {
        margin: 12px;
    }

    .netlogyc-chatbot-input {
        padding: 14px 55px 14px 16px !important;
    }

    .netlogyc-chatbot-send {
        width: 36px !important;
        height: 36px !important;
        right: 6px !important;
    }

    .netlogyc-send-icon {
        width: 18px !important;
        height: 18px !important;
    }
}

/* Animación apertura */

.netlogyc-chatbot-widget {
    animation: netlogyc-widget-appear 0.3s ease-out;
}

@keyframes netlogyc-widget-appear {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.netlogyc-chatbot-link-button {
    display: inline-block;
    margin-top: 8px;
    padding: 6px 10px;
    background-color: var(--netlogyc-secondary-color, #ffffff);
    color: var(--netlogyc-primary-color, #007cba) !important;
    text-decoration: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid rgba(255,255,255,0.8);
}

.netlogyc-chatbot-message.bot .netlogyc-chatbot-link-button,
.netlogyc-message.bot .netlogyc-chatbot-link-button {
    background-color: #ffffff;
    color: var(--netlogyc-primary-color, #007cba) !important;
}

.netlogyc-chatbot-link-button:hover {
    opacity: 0.9;
}

/* Ocultar caracteres de Markdown sobrantes en las respuestas del bot */
.netlogyc-chatbot-widget .netlogyc-message.bot .netlogyc-hide-char {
    display: none;
}
