/* Ausgabe Phase (v4.5) */

.phase-ausgabe-layout {
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100%;
    padding: 20px;
}

.ausgabe-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.ausgabe-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
}

.ausgabe-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ausgabe-controls .model-select {
    min-width: 200px;
}

/* Prompt Preview (collapsed by default) */
.ausgabe-prompt-preview {
    border-radius: 10px;
    background: var(--bg-hover);
    overflow: hidden;
}

.ausgabe-prompt-preview summary {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.ausgabe-prompt-text {
    padding: 12px 14px;
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 200px;
    overflow-y: auto;
    border-top: 1px solid var(--border-color);
}

/* Output Container */
.ausgabe-output {
    flex: 1;
    min-height: 300px;
    max-height: calc(100vh - 380px);
    overflow-y: auto;
    border-radius: 12px;
    background: var(--bg-card, var(--bg-main));
    border: 1px solid var(--border-color);
    padding: 20px 24px;
}

/* Rendered Markdown Output */
.ausgabe-rendered {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-primary);
}

.ausgabe-rendered h1 {
    font-size: 24px;
    font-weight: 700;
    margin: 24px 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border-color);
}

.ausgabe-rendered h1:first-child {
    margin-top: 0;
}

.ausgabe-rendered h2 {
    font-size: 20px;
    font-weight: 700;
    margin: 20px 0 10px 0;
    color: var(--color-orange, #ff6b35);
}

.ausgabe-rendered h3 {
    font-size: 17px;
    font-weight: 600;
    margin: 16px 0 8px 0;
}

.ausgabe-rendered h4 {
    font-size: 15px;
    font-weight: 600;
    margin: 14px 0 6px 0;
    color: var(--text-secondary);
}

.ausgabe-rendered p {
    margin: 8px 0;
}

.ausgabe-rendered strong {
    font-weight: 700;
}

.ausgabe-rendered em {
    font-style: italic;
}

.ausgabe-rendered a {
    color: var(--color-orange, #ff6b35);
    text-decoration: none;
}

.ausgabe-rendered a:hover {
    text-decoration: underline;
}

/* Lists */
.ausgabe-rendered ul,
.ausgabe-rendered ol {
    padding-left: 24px;
    margin: 8px 0;
}

.ausgabe-rendered li {
    margin: 4px 0;
    line-height: 1.6;
}

/* Tables */
.ausgabe-rendered .table-wrapper {
    overflow-x: auto;
    margin: 12px 0;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.ausgabe-rendered table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.ausgabe-rendered th {
    background: var(--bg-hover);
    font-weight: 600;
    text-align: left;
    padding: 10px 12px;
    border-bottom: 2px solid var(--border-color);
}

.ausgabe-rendered td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
}

.ausgabe-rendered tr:nth-child(even) td {
    background: rgba(0, 0, 0, 0.02);
}

.ausgabe-rendered tr:last-child td {
    border-bottom: none;
}

/* Code */
.ausgabe-rendered code {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.9em;
    background: var(--bg-hover);
    padding: 2px 6px;
    border-radius: 4px;
}

.ausgabe-rendered pre {
    background: var(--bg-hover);
    border-radius: 8px;
    padding: 14px 16px;
    overflow-x: auto;
    margin: 12px 0;
}

.ausgabe-rendered pre code {
    background: none;
    padding: 0;
    font-size: 13px;
    line-height: 1.5;
}

/* Blockquote */
.ausgabe-rendered blockquote {
    border-left: 4px solid var(--color-orange, #ff6b35);
    padding: 8px 16px;
    margin: 12px 0;
    color: var(--text-secondary);
    background: rgba(255, 107, 53, 0.04);
    border-radius: 0 8px 8px 0;
}

/* Horizontal Rule */
.ausgabe-rendered hr {
    border: none;
    border-top: 2px solid var(--border-color);
    margin: 20px 0;
}

/* Streaming Cursor */
.ausgabe-cursor-blink {
    display: inline-block;
    animation: cursor-blink 1s step-end infinite;
    color: var(--color-orange, #ff6b35);
    font-weight: 700;
}

@keyframes cursor-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Error State */
.ausgabe-error {
    padding: 16px;
    background: rgba(231, 76, 60, 0.08);
    border-radius: 10px;
    color: #e74c3c;
    text-align: center;
}

/* Actions Bar */
.ausgabe-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

/* ─── Coaching Client Badge ─────────────────────────────────────────────── */

.ausgabe-client-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(255, 107, 53, 0.08);
    border: 1px solid rgba(255, 107, 53, 0.25);
    border-radius: 20px;
    font-size: 13px;
    color: var(--color-orange, #ff6b35);
    font-weight: 500;
    width: fit-content;
}

.ausgabe-badge-dismiss {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-orange, #ff6b35);
    font-size: 16px;
    padding: 0;
    line-height: 1;
    opacity: 0.7;
}

.ausgabe-badge-dismiss:hover {
    opacity: 1;
}

/* ─── Context Panel (Allgemein Mode) ────────────────────────────────────── */

.ausgabe-context-panel {
    border-radius: 10px;
    background: var(--bg-hover);
    padding: 12px 14px;
    border: 1px solid var(--border-color);
}

.ausgabe-context-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.ausgabe-context-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ausgabe-context-field input {
    width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-input, var(--bg-main));
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    transition: border-color 0.2s;
}

.ausgabe-context-field input:focus {
    outline: none;
    border-color: var(--color-orange, #ff6b35);
}

.ausgabe-context-field input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

@media (max-width: 768px) {
    .ausgabe-context-grid {
        grid-template-columns: 1fr;
    }
}

/* ─── System Message ────────────────────────────────────────────────────── */

.ausgabe-msg--system {
    align-self: center;
    max-width: 95%;
}

.ausgabe-msg--system .ausgabe-msg-content {
    background: rgba(231, 76, 60, 0.06);
    border: 1px solid rgba(231, 76, 60, 0.2);
    border-radius: 8px;
    font-size: 13px;
    text-align: center;
}

/* ─── Chat History ───────────────────────────────────────────────────────── */

.ausgabe-chat-history {
    flex: 1;
    min-height: 200px;
    max-height: calc(100vh - 420px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 4px 0;
}

.ausgabe-empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 120px;
    color: var(--text-secondary);
    font-size: 14px;
    text-align: center;
    padding: 20px;
}

/* Message bubbles */
.ausgabe-msg {
    display: flex;
    flex-direction: column;
    max-width: 88%;
}

.ausgabe-msg--user {
    align-self: flex-end;
    align-items: flex-end;
}

.ausgabe-msg--ai {
    align-self: flex-start;
    align-items: flex-start;
}

.ausgabe-msg-content {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
}

.ausgabe-msg--user .ausgabe-msg-content {
    background: var(--color-orange, #ff6b35);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.ausgabe-msg--ai .ausgabe-msg-content {
    background: var(--bg-card, var(--bg-hover));
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

/* Markdown inside AI bubbles */
.ausgabe-msg--ai .ausgabe-msg-content h1,
.ausgabe-msg--ai .ausgabe-msg-content h2,
.ausgabe-msg--ai .ausgabe-msg-content h3 {
    margin: 8px 0 4px 0;
    font-size: inherit;
    font-weight: 700;
}

.ausgabe-msg--ai .ausgabe-msg-content p { margin: 4px 0; }
.ausgabe-msg--ai .ausgabe-msg-content ul,
.ausgabe-msg--ai .ausgabe-msg-content ol { padding-left: 20px; margin: 4px 0; }
.ausgabe-msg--ai .ausgabe-msg-content li { margin: 2px 0; }
.ausgabe-msg--ai .ausgabe-msg-content code {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.88em;
    background: rgba(0,0,0,0.08);
    padding: 1px 5px;
    border-radius: 3px;
}
.ausgabe-msg--ai .ausgabe-msg-content pre {
    background: rgba(0,0,0,0.06);
    border-radius: 6px;
    padding: 10px 12px;
    overflow-x: auto;
    margin: 6px 0;
}

.ausgabe-error-inline {
    color: #e74c3c;
}

/* ─── Reply Input Row ────────────────────────────────────────────────────── */

.ausgabe-reply-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.ausgabe-reply-input {
    flex: 1;
    resize: none;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-input, var(--bg-hover));
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    min-height: 42px;
    max-height: 120px;
    overflow-y: auto;
    transition: border-color 0.2s;
}

.ausgabe-reply-input:focus {
    outline: none;
    border-color: var(--color-orange, #ff6b35);
}

.ausgabe-reply-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ─── Finale Ausgabe Button ──────────────────────────────────────────────── */

.ausgabe-finale-btn {
    background: var(--color-orange, #ff6b35) !important;
    color: #fff !important;
    font-weight: 700;
    gap: 6px;
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .phase-ausgabe-layout {
        padding: 12px;
    }

    .ausgabe-header {
        flex-direction: column;
        align-items: stretch;
    }

    .ausgabe-controls {
        flex-direction: column;
    }

    .ausgabe-controls .model-select {
        min-width: unset;
        width: 100%;
    }

    .ausgabe-output {
        max-height: calc(100vh - 420px);
        padding: 14px 16px;
    }

    .ausgabe-actions {
        flex-direction: column;
    }
}
