/* =============================================
   SCIT Chatbot Widget
   ============================================= */

#scit-chatbot-bubble {
    position: fixed;
    right: 18px;
    bottom: 88px;
    z-index: 1050;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(180deg, #2da8ff 0%, #6c4cf6 100%);
    box-shadow: 0 14px 28px rgba(72, 87, 214, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

body.admin-bar #scit-chatbot-bubble {
    bottom: 88px;
}

#scit-chatbot-bubble:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 18px 36px rgba(72, 87, 214, 0.4);
}

#scit-chatbot-panel {
    position: fixed;
    right: 18px;
    bottom: 94px;
    z-index: 1050;
    width: 360px;
    max-height: min(620px, calc(100vh - 130px));
    display: none;
    flex-direction: column;
    padding: 18px 16px 14px;
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, #f5f4f7 100%);
    box-shadow: 0 22px 56px rgba(38, 43, 77, 0.24);
    font-family: "PFDinTextPro-Regular", sans-serif;
    overflow: hidden;
}

body.admin-bar #scit-chatbot-panel {
    bottom: 106px;
}

#scit-chatbot-panel.scit-open {
    display: flex;
}

#scit-chatbot-controls {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 2;
}

#scit-chatbot-new,
#scit-chatbot-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}

#scit-chatbot-new {
    background: rgba(112, 92, 246, 0.12);
    color: #6b55f6;
}

#scit-chatbot-close {
    background: #6f51f4;
    color: #ffffff;
    box-shadow: 0 10px 20px rgba(111, 81, 244, 0.28);
}

#scit-chatbot-new:hover,
#scit-chatbot-close:hover {
    transform: scale(1.05);
}

#scit-chatbot-messages {
    flex: 1;
    min-height: 240px;
    padding: 50px 12px 12px;
    margin-top: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: transparent;
}

.scit-message-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.scit-message-row.scit-user {
    align-items: flex-end;
}

.scit-message-row.scit-bot {
    align-items: flex-start;
}

.scit-message {
    max-width: 84%;
    padding: 14px 16px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
    box-sizing: border-box;
}

.scit-message.scit-bot {
    background: #f8f8fb;
    color: #232328;
    border: 1px solid #e6e7ee;
    box-shadow: 0 4px 10px rgba(26, 29, 52, 0.04);
}

.scit-message.scit-user {
    background: linear-gradient(180deg, #7452f6 0%, #6d3fe8 100%);
    color: #ffffff;
    box-shadow: 0 10px 22px rgba(109, 63, 232, 0.2);
}

.scit-message-meta {
    padding: 0 8px;
    font-size: 11px;
    line-height: 1;
    color: #8ea0b4;
}

.scit-sources {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e3e5ee;
    font-size: 12px;
    color: #67778a;
}

.scit-source {
    margin-bottom: 4px;
}

.scit-whatsapp-cta {
    margin-top: 12px;
    padding: 10px 14px;
    border: none;
    border-radius: 999px;
    background: linear-gradient(180deg, #25d366 0%, #1ea952 100%);
    color: #ffffff;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(30, 169, 82, 0.22);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.scit-whatsapp-cta:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(30, 169, 82, 0.28);
}

.scit-typing {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 14px;
    background: #f8f8fb;
    border: 1px solid #e6e7ee;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(26, 29, 52, 0.04);
}

.scit-typing span {
    display: block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #8d97ac;
    animation: scit-bounce 1.2s infinite ease-in-out;
}

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

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

@keyframes scit-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-5px);
    }
}

#scit-chatbot-input-area {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    padding: 12px 16px;
    border-radius: 16px 16px 0 0;
    background: #ffffff;
    border-top: 1px solid #ececf4;
    border-bottom: 1px solid #ececf4;
}

#scit-chatbot-input {
    flex: 1;
    min-width: 0;
    border: none;
    padding: 0;
    font-size: 14px;
    line-height: 1.4;
    font-family: inherit;
    color: #232328;
    outline: none;
    background: transparent;
}

#scit-chatbot-input::placeholder {
    color: #9ca6b3;
}

#scit-chatbot-send {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border: none;
    border-radius: 50%;
    background: linear-gradient(180deg, #7a55fb 0%, #6743ec 100%);
    box-shadow: 0 10px 22px rgba(103, 67, 236, 0.28);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#scit-chatbot-send:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 24px rgba(103, 67, 236, 0.34);
}

#scit-chatbot-send:disabled,
#scit-chatbot-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#scit-chatbot-whatsapp-area {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px 14px;
    background: #ffffff;
    border-radius: 0 0 16px 16px;
}

.scit-chatbot-whatsapp-text {
    margin: 0;
    flex: 1;
    font-size: 13px;
    line-height: 1.45;
    color: #4b5563;
}

.scit-whatsapp-cta-fixed {
    margin-top: 0;
    flex-shrink: 0;
    white-space: nowrap;
}

.scit-empty-state {
    margin-top: 18px;
}

.scit-error-msg {
    align-self: center;
    max-width: 90%;
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(219, 73, 73, 0.08);
    color: #c23333;
    font-size: 12px;
    text-align: center;
}

#scit-chatbot-messages::-webkit-scrollbar {
    width: 4px;
}

#scit-chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

#scit-chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(116, 122, 147, 0.3);
    border-radius: 999px;
}

@media (max-width: 480px) {
    #scit-chatbot-bubble {
        right: 16px;
        bottom: 18px;
    }

    #scit-chatbot-panel {
        right: 12px;
        bottom: 86px;
        width: min(360px, calc(100vw - 24px));
        max-height: calc(100vh - 106px);
    }

    body.admin-bar #scit-chatbot-panel {
        bottom: 98px;
    }

    #scit-chatbot-whatsapp-area {
        flex-direction: column;
        align-items: stretch;
    }

    .scit-whatsapp-cta-fixed {
        width: 100%;
    }
}
