/* ============================================================
   Chatbot layout — loaded after the frontend theme. The site header
   sits on top and the chat fills the rest of the screen.
   ============================================================ */

body.chatbot-page {
    display: flex;
    flex-direction: column;
    height: 100vh;          /* fallback */
    height: 100dvh;         /* dynamic viewport height on mobile */
    overflow: hidden;
}

/* ── Chatbot shell: everything below the site header ── */
.chatbot-shell {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Top bar ── */
.chatbot-topbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: .875rem;
    padding: .75rem 1.25rem;
    border-bottom: 1px solid var(--bs-border-color);
    background: var(--bs-body-bg);
    z-index: 10;
}

.chatbot-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(135deg, #3b2bd1, #0d6efd);
    flex-shrink: 0;
}

.chatbot-meta {
    min-width: 0;
    flex: 1;
}

.chatbot-name {
    font-size: .95rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chatbot-tagline {
    font-size: .75rem;
    color: var(--bs-secondary-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chatbot-topbar-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-left: auto;
    flex-shrink: 0;
}

/* ── Body: log area ── */
.chatbot-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: .75rem;
    background: var(--bs-tertiary-bg);
    /* smooth overscroll on iOS */
    -webkit-overflow-scrolling: touch;
}

/* ── Footer: suggestions + input ── */
.chatbot-footer {
    flex-shrink: 0;
    border-top: 1px solid var(--bs-border-color);
    background: var(--bs-body-bg);
    padding: .625rem 1.25rem .75rem;
}

.chatbot-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-bottom: .5rem;
    min-height: 0; /* collapses when empty */
}

.chatbot-suggestions:empty {
    display: none;
}

.chatbot-input-row {
    display: flex;
    gap: .5rem;
    align-items: center;
}

.chatbot-input-row .form-control {
    border-radius: 2rem;
    padding-left: 1.1rem;
    font-size: .9rem;
}

.chatbot-input-row .btn {
    border-radius: 50%;
    width: 2.6rem;
    height: 2.6rem;
    padding: 0;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ── Chat bubbles (shared with frontend theme but self-contained here) ── */
.chat-row {
    display: flex;
}

.chat-row-user {
    justify-content: flex-end;
}

.chat-bubble {
    max-width: 82%;
    padding: .6rem .9rem;
    border-radius: 1rem;
    word-wrap: break-word;
    font-size: .9rem;
    line-height: 1.5;
}

.chat-bubble-bot {
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color-translucent);
    border-bottom-left-radius: .25rem;
}

.chat-bubble-user {
    color: #fff;
    background: var(--bs-primary);
    border-bottom-right-radius: .25rem;
}

/* ── Result cards inside bot bubbles ── */
.chat-result {
    display: block;
    background: var(--bs-tertiary-bg);
    border-radius: .5rem;
    text-decoration: none;
    color: var(--bs-body-color);
    transition: background-color .15s ease;
}

.chat-result:hover {
    background: var(--bs-secondary-bg);
    color: var(--bs-body-color);
}

.chat-thumb {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    flex-shrink: 0;
    overflow: hidden;
    border-radius: .5rem;
    color: var(--bs-secondary-color);
    background: var(--bs-secondary-bg);
    font-size: 1rem;
}

.chat-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ── Typing dots ── */
.chat-dots,
.chat-dots::before,
.chat-dots::after {
    display: inline-block;
    width: .45rem;
    height: .45rem;
    border-radius: 50%;
    background: var(--bs-secondary-color);
    animation: chatDot 1s infinite ease-in-out;
}

.chat-dots {
    position: relative;
    margin: 0 .9rem;
    animation-delay: .15s;
}

.chat-dots::before,
.chat-dots::after {
    content: '';
    position: absolute;
    top: 0;
}

.chat-dots::before { left: -.7rem; animation-delay: 0s; }
.chat-dots::after  { left:  .7rem; animation-delay: .3s; }

@keyframes chatDot {
    0%, 80%, 100% { opacity: .3; transform: translateY(0); }
    40%           { opacity: 1;  transform: translateY(-3px); }
}

@media (prefers-reduced-motion: reduce) {
    .chat-dots,
    .chat-dots::before,
    .chat-dots::after { animation: none; }
}

/* ── Utilities ── */
.min-w-0 { min-width: 0; }

/* ── Responsive tweaks ── */
@media (max-width: 575.98px) {
    .chatbot-topbar    { padding: .6rem .875rem; }
    .chatbot-body      { padding: .75rem .875rem; }
    .chatbot-footer    { padding: .5rem .875rem .6rem; }
    .chat-bubble       { max-width: 92%; }
}
