/* Botón flotante del chatbot */
.chatbot-button {
    position: fixed;
    bottom: 20px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: #28A789;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(61, 108, 94, 0.4);
    transition: all 0.3s ease;
    z-index: 10; /* Siempre por encima del contenedor */
    border: none;
}

.chatbot-button:hover {
    background: var(--color-secondary);
}

.chatbot-button svg,
.chatbot-button img {
    width: 50px;
    height: 50px;
    object-fit: contain;
}

.chatbot-button.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0);
}

.chatbot-button.chat-open {
    /* Ajustado a 470px para compensar el nuevo ancho de 420px del contenedor + margen */
    right: 450px;
    opacity: 1;
    pointer-events: all;
    transform: scale(1);
}

/* Contenedor del chatbot - PANTALLA COMPLETA */
.chatbot-container {
    position: fixed;
    /* 1. SEPARACIÓN DE 5PX DEL NAVBAR (Calculado sobre un nav de 60px) */
    top: 110px !important; 
    
    /* 2. ANCHO AUMENTADO EN 20PX (De 400px a 420px) */
    right: 20px;
    width: 420px; 
    
    /* 3. ALTO DE PANTALLA COMPLETA */
    /* 100% de la pantalla menos el espacio del nav y 20px de margen inferior */
    height: calc(100vh - 110px - 20px) !important; 
    
    background: #F9FAFB;
    border-radius: 20px;
    box-shadow: 0 4px 16px rgba(81, 132, 81, 0.168);
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8) translateY(20px);
    transition: all 0.3s ease;
    z-index: 999;
    overflow: hidden;
}

.chatbot-container.active {
    opacity: 1;
    pointer-events: all;
    transform: scale(1) translateY(0) !important;
}

/* Panel interno */
.chat-panel {
    margin-top: 0; 
    height: 100%; 
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Header del chatbot */
.chatbot-header { 
    background: linear-gradient(90deg,#3fbfa7 0%, var(--color-primary) 100%);
    padding: 15px 50px;
    border-radius: 20px 20px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
}

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

.chatbot-icon {
    width: 50px;
    height: 50px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 3px;
}

.chatbot-icon svg,
.chatbot-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.chatbot-title {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

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

.chatbot-close:hover {
    background: var(--color-secondary);
}

.chatbot-close i {
    font-size: 16px;
}

/* Opciones del chatbot */
.chatbot-options {
    display: flex;
    gap: 12px;
    padding: 15px 20px;
    border-bottom: 1px solid #e8e8e8;
    background: #E6F8F6;
}

.chatbot-option-btn {
    flex: 1;
    padding: 14px;
    background: white;
    border: 1.5px solid #8DD0C5;
    border-radius: 12px;
    cursor: pointer;
    height: 100px;
    transition: all 0.2s;
    /* color: #3D6C5E; */
    font-size: 20px;
}

.chatbot-option-btn:hover {
    background: var(--color-secondary);
    color: white;
    border-color: var(--color-secondary);
}

/* Mensajes del chatbot */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: white;
}

.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #d0d0d0;
    border-radius: 3px;
}

.chatbot-message {
    display: flex;
    gap: 10px;
    animation: messageSlide 0.3s ease;
}

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

.message-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: #D9FAF1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    padding: 2px;
}

.message-avatar svg,
.message-avatar img {
    width: 100%;
    height: 100%;
    color: #3D6C5E;
    object-fit: contain;
}

.message-content {
    flex: 1;
    max-width: 75%;
}

.message-content p {
    background: #F9FAFB;
    padding: 12px 16px;
    border-radius: 16px;
    margin: 0 0 4px 0;
    color: #202020;
    line-height: 1.5;
    font-size: 14px;
    font-weight: normal;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    border: 1px solid #8DD0C5;
}

/* ------ Ayuda extra ------*/
.message-content > .bot-text {
    background: #F9FAFB;
    padding: 12px 16px;
    border-radius: 16px;
    border: 1px solid #8DD0C5;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    margin: 0 0 4px 0;
}
/* -------------------------*/
/* Anular el estilo de burbuja para <p> dentro del bot-text */
.bot-message .bot-text p {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 0 8px 0 !important;
    font-size: 14px;
    color: #202020;
    line-height: 1.5;
}

.bot-message .bot-text p:last-child {
    margin-bottom: 0 !important;
}

.message-time {
    font-size: 11px;
    color: #999;
    padding-left: 4px;
    font-weight: normal;
}

.user-message {
    flex-direction: row-reverse;
}

.user-message .message-avatar {
    background: #E6E7EB;
    padding: 0;
}

.user-message .message-avatar i {
    color: #4E5562;
    font-size: 22px;
}

.user-message .message-content {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.user-message .message-content p {
    background: #F9FAFB;
    color: #4E5562;
    border: 1px solid #8DD0C5;
}

.user-message .message-time {
    text-align: right;
    padding-right: 4px;
    padding-left: 0;
}

/* ---------------------------------------- */
/* TYPING INDICATOR - Animación de 3 puntos */
/* ---------------------------------------- */

/* Indicador de escritura del bot */
.typing-indicator {
    background: #F9FAFB;
    border: 1px solid #8DD0C5;
    border-radius: 16px;
    padding: 12px 16px;
    display: inline-flex;
    gap: 6px;
    align-items: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: #3D6C5E;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

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

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.3;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ---------------------------------------- */

/* Input del chatbot */
.chatbot-input-container {
    display: flex;
    gap: 10px;
    padding: 15px 20px;
    border-top: 1px solid #e8e8e8;
    background: #F9FAFB;
}

.chatbot-input {
    flex: 1;
    padding: 12px 18px;
    border: 1.5px solid #d0d0d0;
    border-radius: 24px;
    outline: none;
    font-size: 14px;
    font-family: 'Lucida Sans', sans-serif;
    transition: all 0.2s;
    background: #fafafa;
}

.chatbot-input:focus {
    border-color: #3D6C5E;
    background: white;
}

.chatbot-input::placeholder {
    color: #999;
}

/* Botón clip para adjuntar archivos */
.chatbot-clip-btn {
    width: 44px;
    height: 44px;
    background: #e8e8e8;
    border: none;
    border-radius: 50%;
    color: #555;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chatbot-clip-btn:hover {
    background: #d0d0d0;
    color: #333;
}

.chatbot-clip-btn i {
    font-size: 20px;
}

/* Chip de archivo seleccionado */
.chatbot-file-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 16px;
    margin: 0 20px 5px;
    background: #E6F8F6;
    border: 1px solid #8DD0C5;
    border-radius: 20px;
    font-size: 13px;
    color: #3D6C5E;
}

.chatbot-file-chip span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chatbot-file-chip button {
    background: none;
    border: none;
    color: #999;
    font-size: 18px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
}

.chatbot-file-chip button:hover {
    color: #e74c3c;
}

.chatbot-send {
    width: 44px;
    height: 44px;
    background: #28A789;
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(61, 108, 94, 0.3);
}

.chatbot-send:hover {
    background: var(--color-secondary);
}

.chatbot-send i {
    font-size: 20px;
}

.chatbot-footer-text {
    font-size: 11px;
    color: #999;
    text-align: center;
    padding: 0 20px 15px;
    margin: 0;
    font-weight: normal;
}

/* Responsive para chatbot */
@media (max-width: 950px) {
    .chatbot-container {
        width: calc(100vw - 40px) !important;
        max-width: 400px;
        height: calc(100vh - 140px) !important;
        bottom: 20px !important;
        right: 20px !important;
        top: auto !important;
    }

    .chatbot-container.active {
        /* Se desplaza hacia arriba para dejar espacio al botón debajo */
        bottom: calc(20px + 56px + 12px) !important;
    }

    .chatbot-button {
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
    }

    .chatbot-button svg,
    .chatbot-button img {
        width: 28px;
        height: 28px;
    }

    .chatbot-button.chat-open {
        /* Debajo de la ventana de chat, alineado a la derecha */
        bottom: 20px;
        right: 20px;
        z-index: 1000;
    }
}

@media (max-width: 480px) {
    .chatbot-container {
        width: calc(100vw - 30px) !important;
        height: calc(100vh - 120px) !important;
        right: 15px !important;
        bottom: 15px !important;
        top: auto !important;
    }

    .chatbot-container.active {
        /* Se desplaza hacia arriba para dejar espacio al botón debajo */
        bottom: calc(15px + 50px + 10px) !important;
    }

    .chatbot-button {
        bottom: 15px;
        right: 15px;
        width: 50px;
        height: 50px;
    }

    .chatbot-button.chat-open {
        /* Debajo de la ventana de chat, alineado a la derecha */
        bottom: 15px;
        right: 15px;
        z-index: 1000;
    }

    .chatbot-title {
        font-size: 16px;
    }

    .chatbot-options {
        padding: 12px 15px;
        gap: 8px;
    }

    .chatbot-option-btn {
        padding: 10px;
        font-size: 16px;
    }
}

/* Estilos para contenido con Markdown en mensajes del bot */
.bot-message .bot-text {
    line-height: 1.5;  /* antes era 1.6 */
    font-size: 14px;
    color: #202020;
}

.bot-message .bot-text strong {
    font-weight: 600;
    color: #1a1a1a;
}

/* Estilos para cursiva */
.bot-message .bot-text em {
    font-style: italic;
    color: #2c3e50;
}

.bot-message .bot-text h3 {
    font-size: 1.15em;
    font-weight: 600;
    margin: 18px 0 12px 0;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 5px;
}

.bot-message .bot-text h4 {
    font-size: 1.05em;
    font-weight: 600;
    margin: 15px 0 10px 0;
    color: #2c3e50;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 5px;
}

/* Estilos para blockquotes (citas) */
.bot-message .bot-text blockquote {
    margin: 10px 0;
    padding: 8px 15px;
    border-left: 4px solid #3498db;
    background-color: #f8f9fa;
    font-style: italic;
    color: #555;
}

.bot-message .bot-text blockquote em {
    color: #555;
}

.bot-message .bot-text ul,
.bot-message .bot-text ol {
    margin: 10px 0;
    padding-left: 25px;
}

.bot-message .bot-text li {
    margin: 6px 0;
    line-height: 1.5;
}

.bot-message .bot-text ul li {
    list-style-type: disc;
}

.bot-message .bot-text ol li {
    list-style-type: decimal;
}

/* Reducir espacio entre elementos consecutivos del mismo tipo */
.bot-message .bot-text p + p {
    margin-top: 8px;
}

.bot-message .bot-text h4 + ul,
.bot-message .bot-text h4 + ol,
.bot-message .bot-text h4 + p {
    margin-top: 8px;
}

.bot-message .bot-text ul + p,
.bot-message .bot-text ol + p {
    margin-top: 12px;
}

/* Mejorar espaciado entre bloques */
.bot-message .bot-text > *:first-child {
    margin-top: 0;
}

.bot-message .bot-text > *:last-child {
    margin-bottom: 0;
}

/* Ajuste especial para referencias y contextos */
.bot-message .bot-text p:empty {
    display: none;
}

/* ── Botones de confirmación de denuncia ────────────────────────── */
.preview-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.btn-confirmar-denuncia,
.btn-cancelar-denuncia {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-confirmar-denuncia {
    background-color: #2e7d32;
    color: #fff;
}

.btn-confirmar-denuncia:hover {
    background-color: var(--color-secondary);
}

.btn-cancelar-denuncia {
    background-color: #f5f5f5;
    color: #555;
    border: 1px solid #ddd;
}

.btn-cancelar-denuncia:hover {
    background-color: var(--color-secondary);
    color: white;
    border-color: var(--color-secondary);
}

/* ── Separador dentro del chat ──────────────────────────────────── */
.chat-divider {
    border: none;
    border-top: 1px solid #e0e0e0;
    margin: 8px 0;
}

/* ── Quick-reply buttons ────────────────────────────────────────── */
.chatbot-quick-replies {
    display: flex;
    gap: 8px;
    padding: 8px 20px 4px;
    background: #F9FAFB;
    border-top: 1px solid #e8e8e8;
    flex-wrap: wrap;
}

.quick-reply-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: white;
    border: 1.5px solid #8DD0C5;
    border-radius: 20px;
    color: #3D6C5E;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
    min-width: 0;
    justify-content: center;
    white-space: nowrap;
}

.quick-reply-btn i {
    font-size: 16px;
}

.quick-reply-btn:hover {
    background: #28A789;
    color: white;
    border-color: #28A789;
}

.quick-reply-btn:active {
    transform: scale(0.96);
}

/* ── Input deshabilitado mientras espera ────────────────────────── */
.chatbot-input:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
    opacity: 0.7;
}