/* SyntaxBreakers chat UI — ported from chat_threads.html / moderator_features.html */

body {
    background: #f5f6f8;
}

/* ---------- thread list ---------- */
.thread-panel .list-group-item {
    gap: .5rem;
}

.thread-link {
    cursor: pointer;
    text-decoration: none;
    font-weight: 600;
}

.thread-id {
    color: rgb(255, 0, 242);
}

.thread-item-active {
    background: #eef4ff !important;
    border-left: 3px solid #0d6efd !important;
}

.global-badge {
    background-color: #198754;
    color: #fff;
    font-size: .65rem;
    font-weight: 600;
    margin: 0 4px;
    white-space: nowrap;
}

.mode-badge {
    font-size: .65rem;
    font-weight: 600;
    margin-left: 6px;
    white-space: nowrap;
}

.mode-badge-single { background-color: #6c757d; color: #fff; }
.mode-badge-two { background-color: #b5563a; color: #fff; }

.shared-core-choice {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: .70rem;
    color: #6c757d;
    white-space: nowrap;
}

    .shared-core-choice.shared-core-active {
        font-weight: 700;
        color: #0d6efd;
    }

    .shared-core-choice input:disabled + .shared-core-choice-label {
        opacity: .65;
    }

/* ---------- chat ---------- */
.chat-container {
    background-color: #fff;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 6px rgba(0, 0, 0, .1);
    border: 1px solid #e0e0e0;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 15px;
    overflow-y: auto;
    background-color: #f9f9f9;
    border: 1px solid #dcdcdc;
    border-radius: 10px;
    height: 70vh;
    min-height: 320px;
    margin-bottom: 15px;
}

    .chat-messages::-webkit-scrollbar { width: 6px; }
    .chat-messages::-webkit-scrollbar-track { background: #f9f9f9; }
    .chat-messages::-webkit-scrollbar-thumb { background-color: #ccc; border-radius: 5px; }

.chat-bubble {
    position: relative;
    padding: 12px 18px;
    border-radius: 20px;
    max-width: 75%;
    line-height: 1.6;
    font-size: 15px;
    display: flex;
    gap: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, .1);
    overflow-wrap: anywhere;
}

.chat-bubble-user {
    background-color: #007bff;
    color: #fff;
    margin-left: auto;
    flex-direction: row-reverse;
}

.chat-bubble-bot {
    background-color: #e8e8e8;
    color: #333;
    margin-right: auto;
}

.chat-bubble-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-icon {
    font-size: 20px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-width: 30px;
}

.turn-name {
    font-size: .72rem;
    font-weight: 700;
}

.chat-meta {
    font-size: .8rem;
    color: #6c757d;
    margin-top: .25rem;
}

.chat-bubble audio {
    width: 100%;
    min-width: 240px;
    margin-top: .5rem;
}

.chat-error {
    background: #fdecea;
    color: #8a1c13;
}

.typing-animation {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 0;
}

    .typing-animation span {
        display: inline-block;
        width: 8px;
        height: 8px;
        background-color: #007bff;
        border-radius: 50%;
        animation: typingBounce 1.5s infinite ease-in-out;
    }

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

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

.chat-input-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-input-field {
    flex-grow: 1;
    min-width: 0;
    padding: 10px 14px;
    border-radius: 20px;
    border: 1px solid #ccc;
    font-size: 15px;
}

    .chat-input-field:focus {
        outline: none;
        border-color: #86b7fe;
        box-shadow: 0 0 0 .2rem rgba(13, 110, 253, .2);
    }

.chat-send-button {
    border-radius: 20px;
    padding: 10px 22px;
}

.preferences label {
    font-weight: 500;
}

/* ---------- toast + overlay + modals ---------- */
.sb-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #facc15;
    padding: 10px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .1);
    z-index: 300000;
    font-size: 14px;
    max-width: 90vw;
}

    .sb-toast.sb-toast-error {
        background: #fdecea;
        color: #8a1c13;
        border-color: #f5c2c7;
    }

    .sb-toast.sb-toast-ok {
        background: #e8f6ee;
        color: #0f5132;
        border-color: #badbcc;
    }

.sb-overlay {
    position: fixed;
    inset: 0;
    z-index: 200000;
    background: rgba(0, 0, 0, .58);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    cursor: wait;
}

.sb-overlay-card {
    width: min(460px, 92vw);
    background: #fff;
    border-radius: 12px;
    padding: 26px 28px;
    text-align: center;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
}

.sb-spinner {
    width: 42px;
    height: 42px;
    margin: 0 auto 16px;
    border: 4px solid #d7dce1;
    border-top-color: #0d6efd;
    border-radius: 50%;
    animation: sbSpin .85s linear infinite;
}

@keyframes sbSpin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    .sb-spinner, .typing-animation span { animation: none; }
}

.sb-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 150000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    padding: 5vh 12px;
}

.sb-modal {
    background: #fff;
    border-radius: 10px;
    width: min(560px, 100%);
    box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
}

    .sb-modal.sb-modal-lg { width: min(820px, 100%); }

.sb-modal-header, .sb-modal-footer {
    padding: .9rem 1.2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
}

.sb-modal-header { border-bottom: 1px solid #dee2e6; }
.sb-modal-footer { border-top: 1px solid #dee2e6; justify-content: flex-end; }
.sb-modal-body { padding: 1.2rem; }

/* ---------- TTS / reference audio ---------- */
.tts-section fieldset {
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.tts-section legend {
    float: none;
    width: auto;
    padding: 0 .5rem;
    font-size: 1rem;
    color: #0d6efd;
}

.record-button {
    width: 64px;
    height: 64px;
    font-size: 22px;
    border-radius: 50%;
    border: none;
    background: #007bff;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    transition: background .3s, transform .2s;
}

    .record-button:hover { transform: scale(1.06); }
    .record-button.recording { background: #dc3545; }

.record-canvas {
    display: block;
    margin: 12px auto 0;
    background: #f4f4f9;
    border: 1px solid #ccc;
    border-radius: 5px;
    max-width: 100%;
}

@media (max-width: 768px) {
    .chat-bubble { max-width: 92%; }
    .chat-messages { height: 60vh; }
}

/* Bubble waiting for its turn to be typed out */
.sb-type:empty::after {
    content: "…";
    color: #999;
}
