/* ========================================
   AvalosCPA Chatbot Widget
   ======================================== */

/* ---------- Floating Button ---------- */
.acpa-chatbot-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #082746;
    color: #ffffff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(8, 39, 70, 0.35);
    z-index: 99998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.acpa-chatbot-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(8, 39, 70, 0.45);
}

.acpa-chatbot-toggle.acpa-hidden {
    display: none;
}

/* ---------- Chat Window ---------- */
.acpa-chatbot-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 380px;
    height: 520px;
    max-height: calc(100vh - 130px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(8, 39, 70, 0.18);
    z-index: 99999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Inter', sans-serif;
    border: 1px solid #e5e7eb;
}

.acpa-chatbot-window.acpa-open {
    display: flex;
    animation: acpa-slide-up 0.3s ease;
}

@keyframes acpa-slide-up {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Header ---------- */
.acpa-chatbot-header {
    background: #082746;
    color: #ffffff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

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

.acpa-chatbot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.acpa-chatbot-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
}

.acpa-chatbot-subtitle {
    font-size: 12px;
    opacity: 0.8;
    margin-top: 2px;
}

.acpa-chatbot-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
}

.acpa-chatbot-close svg {
    display: block;
    width: 20px;
    height: 20px;
    stroke: #ffffff;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
}

.acpa-chatbot-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ---------- Messages Area ---------- */
.acpa-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f8f9fb;
}

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

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

/* ---------- Messages ---------- */
.acpa-chatbot-message {
    display: flex;
    flex-direction: column;
    max-width: 88%;
    animation: acpa-fade-in 0.25s ease;
}

@keyframes acpa-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.acpa-chatbot-message.bot {
    align-self: flex-start;
}

.acpa-chatbot-message.user {
    align-self: flex-end;
}

.acpa-chatbot-message-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.55;
    word-wrap: break-word;
}

.acpa-chatbot-message.bot .acpa-chatbot-message-bubble {
    background: #ffffff;
    color: #333;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

.acpa-chatbot-message.user .acpa-chatbot-message-bubble {
    background: #082746;
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

/* ---------- PDF Link inside answer ---------- */
.acpa-chatbot-pdf-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 6px 12px;
    background: #c99a32;
    color: #ffffff !important;
    text-decoration: none !important;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    transition: background 0.2s;
}

.acpa-chatbot-pdf-link:hover {
    background: #b8892a;
}

.acpa-chatbot-pdf-link svg {
    flex-shrink: 0;
}

/* ---------- Category Buttons ---------- */
.acpa-chatbot-categories {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}

.acpa-chatbot-category-title {
    font-size: 11px;
    font-weight: 600;
    color: #082746;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 8px;
    margin-bottom: 2px;
}

.acpa-chatbot-category-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    font-size: 13px;
    color: #333;
    transition: border-color 0.2s, background 0.2s;
}

.acpa-chatbot-category-btn:hover {
    border-color: #c99a32;
    background: #fffbeb;
}

.acpa-chatbot-category-btn .acpa-q-icon {
    color: #c99a32;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

/* ---------- Search Results ---------- */
.acpa-chatbot-results {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}

.acpa-chatbot-result-btn {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    padding: 10px 14px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.2s, background 0.2s;
}

.acpa-chatbot-result-btn:hover {
    border-color: #c99a32;
    background: #fffbeb;
}

.acpa-chatbot-result-question {
    font-size: 13px;
    font-weight: 500;
    color: #333;
}

.acpa-chatbot-result-category {
    font-size: 11px;
    color: #999;
}

/* ---------- Typing Indicator ---------- */
.acpa-chatbot-typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.acpa-chatbot-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #c99a32;
    animation: acpa-bounce 1.2s infinite;
}

.acpa-chatbot-typing span:nth-child(2) { animation-delay: 0.2s; }
.acpa-chatbot-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes acpa-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%            { transform: translateY(-6px); }
}

/* ---------- Input Area ---------- */
.acpa-chatbot-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid #e5e7eb;
    background: #ffffff;
    flex-shrink: 0;
}

.acpa-chatbot-input {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 13.5px;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.2s;
    color: #333;
}

.acpa-chatbot-input::placeholder {
    color: #aaa;
}

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

.acpa-chatbot-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #c99a32;
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.2s;
}

.acpa-chatbot-send:hover {
    background: #b8892a;
    transform: scale(1.05);
}

/* ---------- No Results ---------- */
.acpa-chatbot-no-results {
    font-size: 13px;
    color: #888;
    text-align: center;
    padding: 12px;
}

/* ---------- PDF Result Snippet ---------- */
.acpa-chatbot-pdf-result {
    margin-bottom: 8px;
}

.acpa-chatbot-pdf-result strong {
    display: block;
    margin-bottom: 4px;
    color: #082746;
}

.acpa-chatbot-pdf-snippets {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 240px;
    overflow-y: auto;
}

.acpa-chatbot-pdf-snippet {
    font-size: 13px;
    line-height: 1.5;
    color: #555;
    background: #f0f6fc;
    border-left: 3px solid #c99a32;
    padding: 8px 12px;
    border-radius: 0 8px 8px 0;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* ---------- Back Button ---------- */
.acpa-chatbot-back-btn {
    display: block;
    width: 100%;
    margin: 8px 0;
    padding: 8px 12px;
    background: #f0f6fc;
    border: 1px solid #c99a32;
    border-radius: 8px;
    color: #082746;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s, color 0.2s;
}

.acpa-chatbot-back-btn:hover {
    background: #082746;
    color: #fff;
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
    .acpa-chatbot-window {
        width: calc(100vw - 16px);
        right: 8px;
        bottom: 80px;
        height: calc(100vh - 100px);
        border-radius: 12px;
    }

    .acpa-chatbot-toggle {
        bottom: 16px;
        right: 16px;
        width: 54px;
        height: 54px;
    }
}
