/* =============================================================================
   KI-Chat Streaming UI – /ai/chat
   Schriftgrößen: CSS-Variablen aus app.css (--oo-fs-*)
   ============================================================================= */

.ki-chat {
    display: flex;
    height: calc(100vh - 60px);
    overflow: hidden;
}

/* ── Sidebar ── */

.ki-chat-sidebar {
    width: 260px;
    min-width: 200px;
    border-right: 1px solid var(--rz-base-300, #e0e0e0);
    display: flex;
    flex-direction: column;
    background: var(--rz-base-100, #f5f5f5);
}

.ki-chat-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--rz-base-300, #e0e0e0);
    font-weight: 600;
}

.ki-chat-sidebar-liste {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.ki-chat-sidebar-eintrag {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 0.5rem 0.75rem;
    margin-bottom: 2px;
    border: none;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
}

.ki-chat-sidebar-eintrag:hover {
    background: var(--rz-base-200, #eeeeee);
}

.ki-chat-sidebar-eintrag.aktiv {
    background: var(--rz-primary-lighter, #e3f2fd);
    font-weight: 500;
}

.ki-chat-sidebar-eintrag-titel {
    font-size: var(--oo-fs-sekundaer);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ki-chat-sidebar-eintrag-datum {
    font-size: var(--oo-fs-klein);
    color: var(--rz-text-tertiary-color, #999);
    margin-top: 2px;
}

/* ── Main Area ── */

.ki-chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ── Nachrichten ── */

.ki-chat-nachrichten {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ki-chat-willkommen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: var(--rz-text-secondary-color, #666);
    text-align: center;
}

.ki-chat-willkommen h2 {
    margin: 0 0 0.5rem;
    font-size: 1.4rem;
}

.ki-chat-willkommen p {
    margin: 0;
    font-size: var(--oo-fs-fliesstext);
}

.ki-chat-nachricht {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    line-height: 1.5;
}

.ki-chat-nachricht.benutzer {
    align-self: flex-end;
    background: var(--rz-primary-lighter, #e3f2fd);
    border-bottom-right-radius: 2px;
}

.ki-chat-nachricht.assistent {
    align-self: flex-start;
    background: var(--rz-base-200, #f0f0f0);
    border-bottom-left-radius: 2px;
}

.ki-chat-rolle {
    font-size: var(--oo-fs-klein);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
    color: var(--rz-text-tertiary-color, #999);
}

.ki-chat-text {
    font-size: var(--oo-fs-fliesstext);
    word-break: break-word;
}

.ki-chat-status {
    font-style: italic;
    color: var(--rz-text-secondary-color, #888);
}

/* ── Eingabe ── */

.ki-chat-eingabe {
    border-top: 1px solid var(--rz-base-300, #e0e0e0);
    padding: 0.75rem 1.5rem;
    background: var(--rz-base-background-color, #fff);
}

.ki-chat-eingabe-controls {
    margin-bottom: 0.5rem;
}

.ki-chat-service-select {
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--rz-base-300, #ccc);
    border-radius: 6px;
    font-size: var(--oo-fs-pre);
    background: var(--rz-base-background-color, #fff);
}

.ki-chat-eingabe-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.ki-chat-eingabe-row textarea {
    flex: 1;
    resize: none;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--rz-base-300, #ccc);
    border-radius: 8px;
    font-size: var(--oo-fs-fliesstext);
    font-family: inherit;
    line-height: 1.4;
    min-height: 2.5rem;
    max-height: 10rem;
    overflow-y: auto;
}

.ki-chat-eingabe-row textarea:focus {
    outline: none;
    border-color: var(--rz-primary, #1976d2);
    box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.15);
}

/* ── Buttons ── */

.ki-chat-btn-icon {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: var(--oo-fs-sekundaer);
    font-weight: 600;
    color: var(--rz-primary, #1976d2);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: background 0.15s;
}

.ki-chat-btn-icon:hover {
    background: var(--rz-base-200, #eee);
}

.ki-chat-btn-senden,
.ki-chat-btn-abbrechen {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: var(--oo-fs-sekundaer);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
}

.ki-chat-btn-senden {
    background: var(--rz-primary, #1976d2);
    color: #fff;
}

.ki-chat-btn-senden:hover:not(:disabled) {
    background: var(--rz-primary-dark, #1565c0);
}

.ki-chat-btn-senden:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ki-chat-btn-abbrechen {
    background: var(--rz-danger, #d32f2f);
    color: #fff;
}

.ki-chat-btn-abbrechen:hover {
    background: var(--rz-danger-dark, #c62828);
}

/* ── Fehler ── */

.ki-chat-fehler {
    padding: 0.5rem 1rem;
    margin: 0 1.5rem 0.75rem;
    background: #fdecea;
    color: #b71c1c;
    border-radius: 6px;
    font-size: var(--oo-fs-sekundaer);
}

/* ── Responsive: Sidebar ausblenden bei schmalen Screens ── */

@media (max-width: 768px) {
    .ki-chat-sidebar {
        display: none;
    }

    .ki-chat-nachricht {
        max-width: 95%;
    }
}
