/* ========== CHATBOT FLOTANTE ========== */

/* Botón flotante del chatbot */
.chatbot-toggle-btn {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    left: auto !important;
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border: none;
    border-radius: 10%;
    box-shadow: 0 8px 25px rgba(134, 185, 16, 0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 2147483647 !important;
    animation: chatbotPulse 1s ease-in-out infinite;
}

.chatbot-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 35px #858585;
}

.chatbot-toggle-btn svg {           
    width: 95px;
    height: auto;
    color: white;
    transition: all 0.3s ease;
    display: flex;
}

.chatbot-toggle-btn.active svg {
    transform: rotateY(180deg);
}

@keyframes chatbotPulse {
    0%, 100% {
        box-shadow: 0 8px 30px #b9ae10;
    }
    50% {
        box-shadow: 0 8px 25px rgba(16, 185, 24, 0.8), 0 0 0 15px rgba(16, 185, 129, 0.35);
    }
}

/* Contenedor del chatbot */
.chatbot-container {
    position: fixed !important;
    bottom: 100px !important;
    right: 30px !important;
    left: auto !important;
    width: 350px;
    max-width: 100vw;
    height: auto;
    max-height: 80vh;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3);
    display: none;
    flex-direction: column;
    z-index: 2147483647 !important;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.chatbot-container.active {
    display: flex;
}

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

/* Header del chatbot */
.chatbot-header {
    background: linear-gradient(145deg, #ffefbd, #003B49, #003B49, #003B49, #003B49, #003B49, #003B49, #ffefbd);
    padding: 10px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 20px 20px 0 0;
}

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

.chatbot-avatar {/*"""""""""*/
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 1);
/*    border: 1px solid rgba(0, 59, 73, 1);*/
    border-radius: 20%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.imagen_Saludo_de_Avatar {
    border-radius: 10%;
    margin-bottom: 10px;
}

.message-avatar bot{
    display: flex;
    border-radius: 10%;
    margin-bottom: 10px;
}

.imagen_de_Avatar {
    display: flex;
    width: 50px;
    height: 50px;
    border-radius: 20%;
}

.imagen_Respuesta_de_Avatar {
    border-radius: 30%;
}

.typing-indicator {
    width: 30px;
    height: 30px;
    background: rgba(255, 255, 255, 1);
/*    border: 1px solid rgba(0, 59, 73, 1);*/
    border-radius: 30%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.chatbot-title h3 {
    font-size: 18px;
    margin: 0;
    font-weight: 700;
}

.chatbot-status {
    font-size: 15px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-dot {
    width: 15px;
    height: 15px;
    background: #48e400 !important;
    border-radius: 50%;
    animation: statusPulse 0.8s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

a, .page-title {
    color: #10d957;
    font-weight: 600;
    text-decoration: none;
}

.chatbot-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 50px;
    height: 50px;
    min-width: 32px;
    min-height: 32px;
    border-radius: 30%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
/*    transition: all 0.3s ease;*/
    flex-shrink: 0;
    padding: 0;
}

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.chatbot-close svg {
    width: 20px;
    height: 20px;
    color: white;
    stroke: white;
    stroke-width: 2.5;
    display: block;
}

main#chatbotMessages {
    box-sizing: content-box !important;
}

main#chatbotMessages {
    background-color: #edffd7;
    border: 2px solid #ffefbd;
    animation: fondoProgresivo 50s infinite;
}

@keyframes fondoProgresivo {
    0%   { background-color: #ffd7d7; }
    10%  { background-color: #fffcd7; }
    20%  { background-color: #f0ffd7; }
    30%  { background-color: #dcffd7; }
    40%  { background-color: #d7ffe1; }
    50%  { background-color: #d7fffc; }
    60%  { background-color: #d7e2ff; }
    70%  { background-color: #dbd7ff; }
    80%  { background-color: #efd7ff; }
    90%  { background-color: #ffd7f2; }
    100% { background-color: #ffd7d7; }
}



/* Mensajes del chat */
.chatbot-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    overflow-x: hidden !important;
    background: #858585;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 200px;
    max-height: 500px;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

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

.chatbot-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

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

/* Mensaje individual */
.chat-message {
    display: flex;
    gap: 5px;
    animation: messageAppear 0.3s ease;
}

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

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

.message-avatar {
    width: 35px;
    height: 35px;
    border-radius: 25%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.message-avatar {
    background:  white;
    color: white;
}

.message-avatar.user {
    background: #ffefbd;
    color: white;
}

.message-content {
    max-width: 85%;
    padding: 10px 10px;
    border-radius: 15px;
    font-size: 16px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.chat-message.bot .message-content {
    background: #003B49;
    color: white;
    border-top-left-radius: 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.chat-message.user .message-content {
    background: #ffedbd;
    color: black;
    border-top-right-radius: 5px;
}

.message-time {
    font-size: 11px;
    color: #003B49;
    margin-top: 0px;
    font-weight: 600;
}

/* Mensaje de bienvenida */
.welcome-message {
    text-align: center;
    padding: 15px 12px;
    color: #858585;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100%;
}

.welcome-message svg {
    width: 45px;
    height: 45px;
    color: #858585;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.welcome-message h4 {
    font-size: 16px;
    color: #003B49;
    margin: 0 0 8px 0;
    line-height: 1.3;
}

.welcome-message p {
    font-size: 16px;
    line-height: 1.5;
    margin: 0 0 12px 0;
    max-width: 280px;
}


.Cuentame {
    font-size: 1.8em;
    color: #003B49;
    font-weight: 100;
}

/* Indicador de escritura */
.typing-indicator {
    display: none;
    gap: 10px;
    align-items: flex-end;
}

.typing-indicator.active {
    display: flex;
}

.typing-dots {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 15px;
    border-bottom-left-radius: 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #858585;
    border-radius: 50%;
    animation: typingDot 1.4s infinite;
}

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

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

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

/* Input del chat */
.chatbot-input-container {
    padding: 10px;
    background: linear-gradient(145deg, #ffefbd, #003B49, #ffefbd);
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
}

.chatbot-input {
    flex: 1;
    padding: 10px;
    border: 2px solid #e5e7eb;
    border-radius: 10px !important;
    font-size: 16px;
    outline: none;
    transition: all 0.3s ease;
    text-align: left;
}

.chatbot-input:focus {
    border-color: #858585;
}

.chatbot-send-btn {
    width: 45px;
    height: 45px;
    min-width: 50px;
    min-height: 50px;
    background: linear-gradient(135deg, #003B49 50%, #003B49 100%);
/*    background: linear-gradient(135deg, #e94057, #8a2387, #8a2387, #003B49);
    background: linear-gradient(135deg, #09ff00, #E7AD00);
    background: linear-gradient(135deg, #e94057, #E7AD00, #E7AD00, #e94057);
    background: linear-gradient(125deg, #003B49, #ffefbd, #ffefbd, #003B49);*/
    border: none;
    border-radius: 30%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
    padding-top: 5px;
    padding-right: 10px;
    padding-bottom: 5px;
    padding-left: 10px;
}

.chatbot-send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 15px #858585;
}

.chatbot-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: scale(1);
}

.chatbot-send-btn svg {
    width: 26px;
    height: 26px;
    color: white;
}

/* Sugerencias rápidas */
.quick-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    justify-content: center;
    width: 100%;
}

.suggestion-btn {
    padding: 6px 12px;
    background: white;
    border: 1.5px solid #e5e7eb;
    border-radius: 18px;
    font-size: 12px;
    color: #858585;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.suggestion-btn:hover {
    background: #858585;
    color: white;
    border-color: #858585;
}

/* ========== RESPONSIVE DESIGN ========== */

/* Tablet Landscape (max-width: 1024px) */
@media (max-width: 1024px) {
    .chatbot-container {
        width: 350px !important;
        max-height: 70vh !important;
        height: auto !important;
    }
}

/* Tablet Portrait (max-width: 768px) */
@media (max-width: 768px) {
    .chatbot-container {
        width: calc(100% - 40px) !important;
        max-width: 400px !important;
        height: auto !important;
        max-height: 80vh !important;
        right: 20px !important;
        left: auto !important;
        bottom: 90px !important;
        border-radius: 15px !important;
    }

    .chatbot-toggle-btn {
        width: 55px !important;
        height: 55px !important;
        bottom: 20px !important;
        right: 20px !important;
        left: auto !important;
        padding: 5px;
    }

    .chatbot-toggle-btn svg {
        width: 26px;
        height: 26px;
    }

    .chatbot-header {
        padding: 15px;
        border-radius: 15px 15px 0 0;
    }

    .chatbot-avatar {
        width: 60px;
        height: 60px;
        font-size: 18px;
    }

    .chatbot-title h3 {
        font-size: 15px;
    }

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

    .message-content {
        max-width: 80%;
        padding: 10px 14px;
        font-size: 13px;
    }

    .chatbot-input-container {
        padding: 12px 15px;
    }

    .chatbot-input {
        padding: 10px 14px;
        font-size: 14px;
    }

    .chatbot-send-btn {
        width: 48px;
        height: 48px;
        min-width: 48px;
        min-height: 48px;
    }

    .chatbot-send-btn svg {
        width: 24px;
        height: 24px;
    }

    .chatbot-close {
        width: 30px;
        height: 30px;
        min-width: 30px;
        min-height: 30px;
    }

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

/* Mobile Large (max-width: 576px) */
@media (max-width: 576px) {
    .chatbot-container {
        width: calc(100% - 20px) !important;
        height: calc(100vh - 100px) !important;
        max-height: none !important;
        right: 2px !important;
        left: auto !important;
        bottom: 80px !important;
        border-radius: 12px !important;
    }

    .chatbot-toggle-btn {
        width: 50px !important;
        height: 50px !important;
        bottom: 2px !important;
        right: 2px !important;
        left: auto !important;
    }

    .chatbot-toggle-btn svg {
        width: 24px;
        height: 24px;
    }

    .chatbot-header {
        padding: 12px 15px;
        border-radius: 12px 12px 0 0;
    }

    .chatbot-header-info {        
        gap: 10px;
    }

    .chatbot-avatar {
        width: 50px; /*  32  */
        height: auto;
        font-size: 16px;
    }

    .chatbot-title h3 {
        font-size: 14px;
    }

    .chatbot-status {
        font-size: 11px;
    }

    .chatbot-close {
        width: 28px;
        height: 28px;
    }

    .chatbot-close svg {
        width: 16px;
        height: 16px;
    }

    .chatbot-messages {
        padding: 12px;
        gap: 10px;
    }

    .message-avatar {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }

    .message-content {
        max-width: 85%;
        padding: 8px 12px;
        font-size: 14px;
        border-radius: 12px;
    }

    .chat-message.bot .message-content {
        border-bottom-left-radius: 4px;
    }

    .chat-message.user .message-content {
        border-bottom-right-radius: 4px;
    }

    .message-time {
        font-size: 10px;
    }

    .welcome-message {
        padding: 20px 15px;
    }

    .welcome-message svg {
        width: 50px;
        height: 50px;
    }

    .welcome-message h4 {
        font-size: 16px;
    }

    .welcome-message p {
        font-size: 13px;
    }

    .quick-suggestions {
        gap: 6px;
        justify-content: center;
    }

    .suggestion-btn {
        padding: 6px 12px;
        font-size: 12px;
        border-radius: 15px;
    }

    .typing-indicator {
        padding: 0 12px;
    }

    .typing-dots {
        padding: 10px 14px;
    }

    .typing-dot {
        width: 6px;
        height: 6px;
    }

    .chatbot-input-container {
        padding: 10px 12px;
        gap: 8px;
    }

    .chatbot-input {
        padding: 10px 12px;
        font-size: 14px;
        border-radius: 10px;
    }

    .chatbot-send-btn {
        width: 46px;
        height: 46px;
        min-width: 46px;
        min-height: 46px;
        flex-shrink: 0;
    }

    .chatbot-send-btn svg {
        width: 22px;
        height: 22px;
    }

    .chatbot-close {
        width: 28px;
        height: 28px;
        min-width: 28px;
        min-height: 28px;
    }

    .chatbot-close svg {
        width: 16px;
        height: 16px;
        stroke-width: 2.5;
    }
}

/* Mobile Small (max-width: 375px) */
@media (max-width: 375px) {
    .chatbot-container {
        width: 100% !important;
        height: 100vh !important;
        height: 100dvh !important;
        left: 2 !important;
        right: 2 !important;
        top: 2 !important;
        bottom: 2 !important;
        border-radius: 10 !important;
    }

    .chatbot-toggle-btn {
        width: 48px !important;
        height: 48px !important;
        bottom: 2px !important;
        right: 2px !important;
        left: auto !important;
    }

    .chatbot-header {
        border-radius: 10;
        padding: 5px;
    }

    .chatbot-avatar {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }

    .chatbot-title h3 {
        font-size: 13px;
    }

    .message-content {
        max-width: 90%;
        font-size: 12px;
    }

    .suggestion-btn {
        padding: 5px 10px;
        font-size: 11px;
    }
}

/* Landscape mode on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .chatbot-container {
        height: calc(100vh - 20px) !important;
        height: calc(100dvh - 20px) !important;
        bottom: 10px !important;
        max-height: none !important;
    }

    .chatbot-toggle-btn {
        bottom: 10px !important;
    }

    .chatbot-header {
        padding: 10px 15px;
    }

    .chatbot-messages {
        padding: 10px;
    }

    .welcome-message {
        padding: 15px 10px;
    }

    .welcome-message svg {
        width: 40px;
        height: 40px;
        margin-bottom: 10px;
    }

    .chatbot-input-container {
        padding: 8px 10px;
    }
}

/* High DPI / Retina displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .chatbot-toggle-btn,
    .chatbot-container {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .chatbot-toggle-btn,
    .chatbot-container,
    .chat-message,
    .typing-dot {
        animation: none !important;
        transition: none !important;
    }
}

/* Tema oscuro */
body.dark-theme .chatbot-container {
    background: #2d3748;
}

body.dark-theme .chatbot-messages {
    background: #1a202c;
}

body.dark-theme .chat-message.bot .message-content {
    background: #374151;
    color: #e5e7eb;
}

body.dark-theme .chatbot-input-container {
    background: #2d3748;
    border-top-color: #4a5568;
}

body.dark-theme .chatbot-input {
    background: #1a202c;
    border-color: #4a5568;
    color: #e5e7eb;
}

body.dark-theme .suggestion-btn {
    background: #374151;
    border-color: #4a5568;
    color: #858585;
}

body.dark-theme .welcome-message {
    color: #cbd5e0;
}

body.dark-theme .welcome-message h4 {
    color: #f7fafc;
}

body.dark-theme .typing-dots {
    background: #374151;
}
