/* DocMind AI Pro: AI Chat (AI Chat page and [docmind_chat] shortcode). Neutral, to match any theme:
   the accent color can be changed in the theme with --docmind-chat-color. */

.docmind-chat {
    --docmind-chat-color: #2271b1;
    --docmind-chat-ai-bg: #f3f4f6;
    --docmind-chat-border: #dcdcde;
    max-width: 1000px;
    margin: 1.5em auto;
    font-size: 15px;
    line-height: 1.55;
    box-sizing: border-box;
}
.docmind-chat *, .docmind-chat *::before, .docmind-chat *::after { box-sizing: inherit; }

.docmind-chat-title {
    text-align: center;
    font-weight: 400;
    margin: 0 0 .75em;
}

.docmind-chat-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Messages: the most recent one at the bottom (column-reverse) */
.docmind-chat-messages {
    display: flex;
    flex-direction: column-reverse;
    gap: 14px;
    min-height: 260px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 4px;
}

.docmind-chat-msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 10px;
    overflow-wrap: anywhere;
}
.docmind-chat-msg > div > :first-child,
.docmind-chat-msg > :first-child { margin-top: 0; }
/* Same size for paragraphs, lists and tables (the WordPress admin and many themes force the <p> size) */
.docmind-chat-msg p,
.docmind-chat-msg li,
.docmind-chat-msg td,
.docmind-chat-msg th,
.docmind-chat-msg blockquote {
    font-size: inherit;
    line-height: inherit;
}
.docmind-chat-msg p { margin: 0 0 .6em; }
.docmind-chat-msg li { margin: .15em 0; }
.docmind-chat-msg li > p { margin: 0; }
.docmind-chat-msg p:last-child { margin-bottom: 0; }
.docmind-chat-msg ul, .docmind-chat-msg ol { margin: .3em 0 .6em 1.3em; padding: 0; }

.docmind-chat-ai {
    align-self: flex-start;
    background: var(--docmind-chat-ai-bg);
    border: 1px solid #e5e7eb;
}
.docmind-chat-user {
    align-self: flex-end;
    background: var(--docmind-chat-color);
    color: #fff;
}
.docmind-chat-user a { color: #fff; }

/* Sources */
.docmind-chat-sources {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--docmind-chat-border);
    font-size: 13px;
}
.docmind-chat-sources h5 { margin: 0 0 4px; font-size: 13px; }
.docmind-chat-sources ul { list-style: none; margin: 0; padding: 0; }
.docmind-chat-sources li { margin: 2px 0; }
.docmind-chat-sources li::before { content: "📄 "; }
.docmind-chat-sources span { color: #646970; margin-left: 6px; }
.docmind-chat-sources span::before { content: "· "; }

/* "typing..." */
.docmind-chat-typing { display: flex; gap: 4px; padding-top: 6px; }
.docmind-chat-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #8c8f94;
    animation: docmind-chat-pulse 1.2s infinite ease-in-out;
}
.docmind-chat-typing span:nth-child(2) { animation-delay: .2s; }
.docmind-chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes docmind-chat-pulse {
    0%, 80%, 100% { opacity: .3; transform: scale(.8); }
    40% { opacity: 1; transform: scale(1); }
}

/* Question box */
.docmind-chat-input {
    position: relative;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
}
.docmind-chat-input textarea {
    display: block;
    width: 100%;
    min-height: 86px;
    padding: 14px 120px 14px 18px;
    border: 1px solid var(--docmind-chat-border);
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .08);
    font: inherit;
    resize: vertical;
    background: #fff;
    color: #1d2327;
}
.docmind-chat-input textarea:focus {
    outline: none;
    border-color: var(--docmind-chat-color);
    box-shadow: 0 0 0 1px var(--docmind-chat-color);
}
.docmind-chat-input button {
    position: absolute;
    right: 12px;
    bottom: 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    font: inherit;
    line-height: 1;
}
.docmind-chat-send {
    width: 40px;
    height: 40px;
    justify-content: center;
    background: var(--docmind-chat-color);
    color: #fff;
}
.docmind-chat-send:disabled { opacity: .45; cursor: default; }
.docmind-chat-stop {
    padding: 8px 12px;
    background: #fff;
    color: #b32d2e;
    border: 1px solid #b32d2e !important;
}
.docmind-chat-stop img {
    width: 22px;
    height: 22px;
    object-fit: contain;
    animation: docmind-chat-spin 1.2s linear infinite;
}
@keyframes docmind-chat-spin { to { transform: rotate(360deg); } }

@media (max-width: 600px) {
    .docmind-chat-msg { max-width: 100%; }
    .docmind-chat-input textarea { padding-right: 70px; }
    .docmind-chat-stop { font-size: 0; padding: 8px; gap: 0; }
}

/* Chat unavailable (no AI or no processed PDFs) */
.docmind-chat-notice {
    margin: 0 auto;
    width: 100%;
    max-width: 1000px;
    padding: 10px 14px;
    border-left: 4px solid #dba617;
    background: #fcf9e8;
    color: #1d2327;
}
.docmind-chat-input textarea[readonly] {
    background: #f6f7f7;
    cursor: not-allowed;
}

/* Final "Source: file.pdf" line of the answer: discreet, like a footer */
.docmind-chat-ai p:last-child > em:only-child {
    display: block;
    margin-top: .4em;
    font-size: 12px;
    color: #646970;
}
/* Bullet points with a bold title */
.docmind-chat-ai li strong { color: #1d2327; }
