/* === Module: AI Chat (ID: 1) === */
/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex; align-items: center; justify-content: center;
    z-index: 2000;
}

.modal-content {
    background: var(--white);
    width: 90%; 
    max-width: 600px;
    height: 80vh; /* Festgelegte Höhe des Modals */
    border-radius: 12px;
    display: flex; 
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}

/* Anpassung für sehr kleine Bildschirme */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        height: 90vh; /* Mehr Platz auf Mobilgeräten */
    }
}

.modal-header {
    padding: 20px;
    background: var(--primary-color);
    color: var(--white);
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    flex-shrink: 0; /* Header darf nicht schrumpfen */
}

.modal-header h3 { color: var(--white); margin: 0; font-size: 1.2rem; }

.close-modal {
    background: none; 
    border: none; 
    color: var(--white);
    font-size: 2rem; 
    cursor: pointer; 
    line-height: 1;
}

/* Chat Container */
#chat-container {
    flex: 1; 
    display: flex; 
    flex-direction: column;
    background: #fdfdfd;
    min-height: 0; /* Wichtig für Flexbox-Scrolling */
}

#chat-history {
    flex: 1; 
    overflow-y: auto; 
    padding: 20px;
    display: flex; 
    flex-direction: column; 
    gap: 15px;
    min-height: 0; /* Verhindert, dass der Content den Container aufbläht */
    -webkit-overflow-scrolling: touch; /* Flüssiges Scrollen auf iOS */
}

/* Chat Messages */
.chat-msg {
    max-width: 85%; 
    padding: 12px 16px; 
    border-radius: 15px;
    line-height: 1.5; 
    font-size: 0.95rem;
    position: relative;
    word-wrap: break-word; /* Verhindert Überlaufen bei langen Wörtern */
}

.chat-msg.user {
    align-self: flex-end;
    background: var(--primary-color); 
    color: var(--white);
    border-bottom-right-radius: 2px;
}

.chat-msg.assistant {
    align-self: flex-start;
    background: #e9ecef; 
    color: var(--text-color);
    border-bottom-left-radius: 2px;
    border-left: 4px solid var(--secondary-color);
}

/* Thinking Bubble */
#chat-thinking { 
    padding: 10px 20px; 
    flex-shrink: 0;
}

.thinking-bubble {
    background: #fffbe6; 
    border: 1px solid #ffe58f;
    border-radius: 8px; 
    padding: 10px 15px;
    font-size: 0.85rem; 
    color: #856404;
}

/* Input Area */
#chat-input-area {
    padding: 20px; 
    border-top: 1px solid var(--border-color);
    background: var(--white);
    flex-shrink: 0; /* Eingabebereich bleibt fix unten */
}

#chat-input {
    width: 100%; 
    border: 1px solid var(--border-color);
    border-radius: 8px; 
    padding: 12px; 
    margin-bottom: 10px;
    resize: none; 
    font-family: inherit;
}

.chat-controls { display: flex; gap: 10px; }
#chat-send-btn { flex: 2; }
#chat-new-btn { flex: 1; }