/* Question box: failed-answer message and "Try again", jump to latest, advisor line,
   rating thanks and the Undo bar. Behaviour: static/js/question-box-polish.js.
   Buttons are scoped by id because base.min.css styles every button[type="button"]
   with padding, a shadow and no border. */

#dashboard-chat-container { position: relative; }

/* A failed answer is a short message, not an answer: no "Show more" clamp or fade.
   It keeps the answer's class so saved study history still reads just the message. */
#dashboard-chat-messages .chat-response-content.chat-answer-error {
    max-height: none;
    overflow: visible;
    color: var(--dashboard-danger, #b91c1c);
    line-height: 1.5;
}
#dashboard-chat-messages .chat-response-content.chat-answer-error::after { display: none; }

#dashboard-chat-messages .chat-retry-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    min-height: 40px;
    margin-top: 0.625rem;
    padding: 0.375rem 0.875rem;
    border: 1px solid var(--dashboard-primary, #2b3a7f);
    border-radius: 999px;
    background: #fff;
    color: var(--dashboard-primary, #2b3a7f);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.2;
    box-shadow: none;
    cursor: pointer;
}
#dashboard-chat-messages .chat-retry-btn:hover { background: #eef2ff; }
#dashboard-chat-messages .chat-retry-btn:disabled { opacity: 0.6; cursor: default; }
#dashboard-chat-messages .chat-retry-btn .material-icons { font-size: 18px; }

/* Shown when there is more of the conversation below what is in view. */
#dashboard-chat-container .chat-jump-latest {
    display: none;
    position: absolute;
    left: 50%;
    z-index: 5;
    width: 40px;
    height: 40px;
    padding: 0;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(43, 58, 127, 0.18);
    border-radius: 999px;
    background: #fff;
    color: var(--dashboard-primary, #2b3a7f);
    box-shadow: 0 6px 16px rgba(17, 25, 44, 0.16);
    transform: translateX(-50%);
    cursor: pointer;
}
#dashboard-chat-container .chat-jump-latest.is-visible {
    display: inline-flex;
    animation: question-box-fade-in 0.18s ease-out;
}
#dashboard-chat-container .chat-jump-latest:focus-visible { outline: 3px solid var(--dashboard-primary, #2b3a7f); outline-offset: 2px; }

/* Phones hide the advisor names, so say who is chosen under the pictures. */
.persona-selected-line {
    display: none;
    margin: 0.5rem 0 0;
    color: var(--color-secondary, #475569);
    font-size: 0.875rem;
    line-height: 1.4;
    text-align: center;
}
.persona-selected-line strong { color: var(--color-primary-dark, #11192c); }
.persona-selected-line .persona-selected-role:not(:empty)::before { content: " · "; }
@media (max-width: 768px) {
    .persona-selected-line:not([hidden]) { display: block; }
}

/* After a rating: a short thanks; after a thumbs-down, three quick reasons. */
#dashboard-chat-messages .chat-feedback-note {
    margin-top: 0.5rem;
    color: var(--color-secondary, #475569);
    font-size: 0.8125rem;
    line-height: 1.4;
}
#dashboard-chat-messages .chat-feedback-ask {
    margin: 0 0 0.375rem;
    color: var(--color-primary-dark, #11192c);
    font-weight: 600;
}
#dashboard-chat-messages .chat-feedback-reasons { display: flex; flex-wrap: wrap; gap: 0.375rem; }
#dashboard-chat-messages .chat-feedback-chip {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0.25rem 0.75rem;
    border: 1px solid rgba(43, 58, 127, 0.25);
    border-radius: 999px;
    background: #fff;
    color: var(--dashboard-primary, #2b3a7f);
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.2;
    box-shadow: none;
    cursor: pointer;
}
#dashboard-chat-messages .chat-feedback-chip:hover { background: #eef2ff; }

/* Undo bar, used for a cleared conversation and a removed saved verse. */
.bg-undo-snackbar {
    position: fixed;
    left: 50%;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    z-index: 10050;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-width: min(20rem, calc(100vw - 32px));
    max-width: calc(100vw - 32px);
    padding: 0.5rem 0.5rem 0.5rem 1rem;
    border-radius: 12px;
    background: #11192c;
    color: #fff;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.25);
    font-family: var(--font-body, inherit);
    font-size: 0.9375rem;
    line-height: 1.4;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 16px);
    /* Hidden once faded, so a keyboard or screen reader cannot reach a stale Undo. */
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s;
}
.bg-undo-snackbar.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, 0);
    visibility: visible;
    transition-delay: 0s;
}
.bg-undo-snackbar .bg-undo-snackbar__undo {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0.375rem 0.75rem;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--brand-gold, #f6c454);
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 700;
    box-shadow: none;
    cursor: pointer;
}
.bg-undo-snackbar .bg-undo-snackbar__undo:hover { background: rgba(255, 255, 255, 0.1); }
.bg-undo-snackbar .bg-undo-snackbar__undo:focus-visible { outline: 2px solid var(--brand-gold, #f6c454); outline-offset: 2px; }

@keyframes question-box-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    #dashboard-chat-container .chat-jump-latest.is-visible { animation: none; }
    .bg-undo-snackbar { transition: none; }
}

/* Under an answer that ran out of room: the words are kept and the credits returned. */
.answer-cut-short-note {
    margin: 0.75rem 0 0;
    padding: 0.625rem 0.875rem;
    border-left: 3px solid var(--brand-gold, #c9a227);
    border-radius: var(--radius-sm, 0.375rem);
    background: var(--bg-surface, #f8fafc);
    color: var(--text-primary, #1f2937);
    font-size: 0.9375rem;
    line-height: 1.5;
}
