/* ===========================================================
   NURSY IA — ESTILOS COMPLETO DEL CHATBOT REESTILIZADO
   =========================================================== */

/* --- FAB (botón flotante) --- */
#nursy-fab {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 99999;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    color: #fff;
    font-size: 26px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.35);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    animation: nursyBounce 3s ease-in-out infinite;
}
#nursy-fab::after {
    content: '';
    position: absolute;
    inset: -5px;
    border-radius: 50%;
    border: 2.5px solid rgba(37, 99, 235, 0.3);
    animation: nursyRing 2.2s ease-out infinite;
}
#nursy-fab:hover {
    transform: scale(1.1) translateY(-5px) !important;
    box-shadow: 0 14px 32px rgba(37, 99, 235, 0.5);
}
@keyframes nursyBounce {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-8px); }
}
@keyframes nursyRing {
    0%   { transform: scale(1);   opacity: 0.85; }
    100% { transform: scale(1.6); opacity: 0; }
}

/* --- Ventana del chat --- */
#nursy-window {
    position: fixed;
    bottom: 104px;
    right: 28px;
    z-index: 99998;
    width: 380px;
    height: 560px;
    display: flex;
    flex-direction: column;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.15);
    border: 1px solid rgba(226, 232, 240, 0.8);
    background: #f8fafc;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    /* Oculto por defecto */
    transform: scale(0.85) translateY(24px);
    transform-origin: bottom right;
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.22s ease;
}
[data-theme="dark"] #nursy-window {
    background: #0f172a;
    border-color: rgba(51, 65, 85, 0.5);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}
#nursy-window.nursy-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* --- Cabecera --- */
#nursy-header {
    background: linear-gradient(135deg, #1e3a8a 0%, #1e293b 100%);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.nursy-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    color: #fff;
    flex-shrink: 0;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}
.nursy-avatar::after {
    content: '';
    position: absolute;
    bottom: 2px; 
    right: 2px;
    width: 9px; 
    height: 9px;
    border-radius: 50%;
    background: #10b981; /* Green status dot */
    border: 2px solid #1e3a8a;
    animation: blink 2.5s infinite;
}
@keyframes blink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.4; }
}
.nursy-info { 
    flex: 1; 
}
.nursy-info strong { 
    display: block; 
    font-size: 15px; 
    color: #fff; 
    font-weight: 600;
    letter-spacing: -0.01em;
}
.nursy-info small { 
    font-size: 11.5px; 
    color: rgba(255, 255, 255, 0.7); 
}
#nursy-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 15px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
#nursy-close:hover { 
    background: rgba(255, 255, 255, 0.2);
    color: #fff; 
    transform: rotate(90deg);
}

/* --- Chips de sugerencias --- */
#nursy-suggestions {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: #f1f5f9;
    overflow-x: auto;
    scrollbar-width: none; /* Ocultar scrollbar en Firefox */
    flex-shrink: 0;
    border-bottom: 1px solid rgba(226, 232, 240, 0.6);
}
#nursy-suggestions::-webkit-scrollbar {
    display: none; /* Ocultar scrollbar en Chrome/Safari */
}
[data-theme="dark"] #nursy-suggestions { 
    background: #1e293b; 
    border-bottom-color: rgba(51, 65, 85, 0.3);
}
.nursy-chip {
    background: #ffffff;
    color: #334155;
    border: 1px solid #e2e8f0;
    border-radius: 100px;
    padding: 6px 14px;
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    font-family: inherit;
}
[data-theme="dark"] .nursy-chip {
    background: #0f172a;
    color: #cbd5e1;
    border-color: #334155;
}
.nursy-chip:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #2563eb;
    transform: translateY(-1px);
}
[data-theme="dark"] .nursy-chip:hover {
    background: #1e293b;
    border-color: #475569;
    color: #38bdf8;
}

/* --- Mensajes --- */
#nursy-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scrollbar-width: thin;
    scrollbar-color: rgba(203, 213, 225, 0.8) transparent;
}
#nursy-messages::-webkit-scrollbar {
    width: 5px;
}
#nursy-messages::-webkit-scrollbar-track {
    background: transparent;
}
#nursy-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 99px;
}
[data-theme="dark"] #nursy-messages::-webkit-scrollbar-thumb {
    background: #334155;
}
#nursy-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.nursy-msg {
    display: flex;
    gap: 10px;
    max-width: 86%;
    animation: msgIn 0.3s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}
@keyframes msgIn {
    from { opacity: 0; transform: translateY(10px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.nursy-msg.bot { align-self: flex-start; }
.nursy-msg.usr { align-self: flex-end; flex-direction: row-reverse; }

.msg-ico {
    width: 30px; 
    height: 30px;
    border-radius: 50%;
    display: flex; 
    align-items: center; 
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.nursy-msg.bot .msg-ico {
    background: rgba(37, 99, 235, 0.1);
    color: #2563eb;
    border: 1px solid rgba(37, 99, 235, 0.15);
}
[data-theme="dark"] .nursy-msg.bot .msg-ico {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border-color: rgba(56, 189, 248, 0.2);
}
.nursy-msg.usr .msg-ico {
    background: #e2e8f0;
    color: #475569;
}
[data-theme="dark"] .nursy-msg.usr .msg-ico {
    background: #334155;
    color: #cbd5e1;
}

.msg-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 13.5px;
    line-height: 1.6;
    letter-spacing: -0.005em;
    word-wrap: break-word;
}
.nursy-msg.bot .msg-bubble {
    background: #ffffff;
    color: #1e293b;
    border-top-left-radius: 4px;
    border: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.03);
}
[data-theme="dark"] .nursy-msg.bot .msg-bubble {
    background: #1e293b;
    color: #e2e8f0;
    border-color: rgba(51, 65, 85, 0.4);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}
.nursy-msg.usr .msg-bubble {
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    color: #ffffff;
    border-top-right-radius: 4px;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.15);
}

/* --- Indicador "escribiendo" --- */
.typing-bubble {
    display: flex;
    gap: 4px;
    padding: 14px 18px;
    background: #ffffff;
    border-radius: 18px;
    border-top-left-radius: 4px;
    border: 1px solid rgba(226, 232, 240, 0.8);
    width: fit-content;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.03);
}
[data-theme="dark"] .typing-bubble {
    background: #1e293b;
    border-color: rgba(51, 65, 85, 0.4);
}
.typing-dot {
    width: 6px; 
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;
    animation: typeDot 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes typeDot {
    0%, 80%, 100% { transform: scale(0.4); opacity: 0.5; }
    40%            { transform: scale(1); opacity: 1; }
}

/* --- Input area --- */
#nursy-input-row {
    padding: 14px 18px;
    display: flex;
    gap: 10px;
    align-items: center;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}
[data-theme="dark"] #nursy-input-row {
    background: #0f172a;
    border-color: rgba(51, 65, 85, 0.6);
}
#nursy-input {
    flex: 1;
    padding: 11px 18px;
    border: 1px solid #cbd5e1;
    border-radius: 24px;
    font-size: 13.5px;
    font-family: inherit;
    background: #f8fafc;
    color: #0f172a;
    outline: none;
    transition: all 0.2s ease;
}
[data-theme="dark"] #nursy-input {
    background: #1e293b;
    border-color: #334155;
    color: #f8fafc;
}
#nursy-input:focus {
    border-color: #2563eb;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
[data-theme="dark"] #nursy-input:focus {
    border-color: #38bdf8;
    background: #0f172a;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}
#nursy-send {
    width: 40px; 
    height: 40px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    color: #ffffff;
    font-size: 15px;
    cursor: pointer;
    display: flex; 
    align-items: center; 
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.15);
    flex-shrink: 0;
    box-shadow: 0 3px 8px rgba(37, 99, 235, 0.2);
}
#nursy-send:hover {
    transform: scale(1.08);
    box-shadow: 0 5px 12px rgba(37, 99, 235, 0.35);
}

/* Ocultar chatbot en la pantalla de login/autenticación */
#auth-screen:not([style*="display: none"]):not([style*="display:none"]) ~ #nursy-root {
    display: none !important;
}

/* Responsividad para móviles */
@media screen and (max-width: 480px) {
    #nursy-window {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
        border: none;
        transform-origin: center;
    }
    
    #nursy-fab {
        bottom: 16px;
        right: 16px;
        width: 52px;
        height: 52px;
        font-size: 22px;
    }
}
