/* ═══════════════════════════════════════════
   Support-Assistent – Global Styles
   ═══════════════════════════════════════════ */

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary: #64748b;
    --secondary-hover: #475569;
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --info: #0891b2;
    --info-light: #cffafe;

    --bg: #f1f5f9;
    --bg-card: #ffffff;
    --bg-sidebar: #1e293b;
    --bg-sidebar-hover: #334155;
    --bg-sidebar-active: #2563eb;

    --text: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --text-inverse: #ffffff;

    --border: #e2e8f0;
    --border-focus: #93c5fd;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ── App Layout ─────────────────────────── */
.app {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ────────────────────────────── */
.sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--bg-sidebar);
    color: var(--text-inverse);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.logo-icon {
    font-size: 28px;
}

.logo h1 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: none;
    background: transparent;
    color: var(--text-light);
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-family: var(--font);
}

.nav-btn:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-inverse);
}

.nav-btn.active {
    background: var(--bg-sidebar-active);
    color: var(--text-inverse);
}

.nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.version {
    font-size: 12px;
    color: var(--text-light);
}

/* ── Main Content ───────────────────────── */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 32px;
    max-width: 1400px;
}

/* ── Views ──────────────────────────────── */
.view {
    display: none;
}

.view.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.page-header {
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.page-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.page-header p {
    font-size: 14px;
    color: var(--text-muted);
}

.required {
    color: var(--danger);
    font-weight: 700;
}

.optional {
    color: var(--text-light);
    font-size: 12px;
}

/* ── Ticket Form ────────────────────────── */
.ticket-form {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 28px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

.form-col {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-col-preview {
    border-left: 1px solid var(--border);
    padding-left: 32px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: 0.01em;
}

.form-group input,
.form-group textarea,
.form-group select {
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg-card);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.fg-info {
    background: var(--primary-light);
    border: 1px solid var(--border-focus);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-top: 4px;
    font-size: 13px;
}

.fg-info-row {
    margin: 2px 0;
    color: var(--text);
}

.fg-info-row strong {
    color: var(--primary-hover);
    margin-right: 4px;
}

/* ── Analyse Preview ────────────────────── */
.analyse-card {
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: border-color 0.3s;
}

.analyse-card-header {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: var(--text-inverse);
    padding: 14px 20px;
}

.analyse-card-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.analyse-body {
    padding: 20px;
}

.analyse-row {
    margin-bottom: 16px;
}

.analyse-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.analyse-value {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
}

.analyse-fehlend {
    list-style: none;
    padding: 0;
}

.analyse-fehlend li {
    font-size: 13px;
    color: var(--warning);
    padding: 3px 0;
    padding-left: 16px;
    position: relative;
}

.analyse-fehlend li::before {
    content: "⚠";
    position: absolute;
    left: 0;
}

.antwort-preview {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: auto;
}

.analyse-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 300px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    color: var(--text-light);
    text-align: center;
    padding: 32px;
}

.placeholder-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.analyse-placeholder p {
    font-size: 14px;
    line-height: 1.5;
}

/* ── Badges ─────────────────────────────── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge-kategorie {
    background: var(--info-light);
    color: var(--info);
}

.badge-prioritaet {
    background: var(--primary-light);
    color: var(--primary-hover);
}

.badge-prioritaet.kritisch {
    background: var(--danger-light);
    color: var(--danger);
}

.badge-prioritaet.hoch {
    background: var(--warning-light);
    color: var(--warning);
}

.badge-prioritaet.mittel {
    background: #fef9c3;
    color: #a16207;
}

.badge-prioritaet.niedrig {
    background: var(--success-light);
    color: var(--success);
}

.badge-status {
    background: var(--primary-light);
    color: var(--primary-hover);
}

.badge-status.geschlossen {
    background: var(--success-light);
    color: var(--success);
}

/* ── Buttons ────────────────────────────── */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--primary);
    color: var(--text-inverse);
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: var(--shadow-md);
}

.btn-primary:disabled {
    background: var(--border);
    color: var(--text-light);
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1.5px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

.btn-success {
    background: var(--success);
    color: var(--text-inverse);
}

.btn-success:hover {
    background: #15803d;
}

.btn-danger {
    background: var(--danger);
    color: var(--text-inverse);
}

.btn-danger:hover {
    background: #b91c1c;
}

/* ── Filter Bar ─────────────────────────── */
.filter-bar {
    display: flex;
    gap: 12px;
    align-items: center;
}

.filter-select {
    padding: 8px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font);
    background: var(--bg-card);
    color: var(--text);
    cursor: pointer;
}

.filter-select:focus {
    outline: none;
    border-color: var(--border-focus);
}

/* ── Data Table ─────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.data-table th {
    background: var(--bg);
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border);
}

.data-table td {
    padding: 12px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tr:hover td {
    background: #f8fafc;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.loading-row td {
    text-align: center;
    color: var(--text-light);
    padding: 40px;
}

.ticket-table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

/* ── Modal ──────────────────────────────── */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    animation: fadeIn 0.2s ease;
}

.modal-overlay[hidden] {
    display: none;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 900px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-light);
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ── Modal Detail Content ───────────────── */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.detail-item {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
}

.detail-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.detail-value {
    font-size: 14px;
    color: var(--text);
}

.detail-section {
    margin-bottom: 20px;
}

.detail-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.detail-section p, .detail-section pre {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
}

.detail-section pre {
    background: var(--bg);
    padding: 12px;
    border-radius: var(--radius-sm);
    white-space: pre-wrap;
    font-family: var(--font);
}

.history-table {
    width: 100%;
    font-size: 13px;
}

.history-table th {
    text-align: left;
    padding: 8px;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

.history-table td {
    padding: 8px;
    border-bottom: 1px solid var(--border);
}

/* ── Wissensdatenbank Cards ─────────────── */
.wd-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
}

.wd-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    border-left: 4px solid var(--primary);
    transition: box-shadow 0.2s;
}

.wd-card:hover {
    box-shadow: var(--shadow-md);
}

.wd-card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.wd-card-kategorie {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.wd-card-problem {
    font-size: 13px;
    color: var(--text);
    margin-bottom: 12px;
    line-height: 1.5;
}

.wd-card-loesung {
    font-size: 13px;
    color: var(--text);
    background: var(--success-light);
    border-radius: var(--radius-sm);
    padding: 12px;
    white-space: pre-wrap;
    line-height: 1.5;
    max-height: 150px;
    overflow-y: auto;
}

.wd-card-keywords {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.wd-keyword {
    background: var(--bg);
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 11px;
    color: var(--text-muted);
}

/* ── Toast Notifications ────────────────── */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 300;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    font-weight: 500;
    max-width: 420px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}

.toast-success {
    background: var(--success);
    color: var(--text-inverse);
}

.toast-error {
    background: var(--danger);
    color: var(--text-inverse);
}

.toast-info {
    background: var(--primary);
    color: var(--text-inverse);
}

/* ── Loading Spinner ────────────────────── */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
    font-size: 14px;
}

/* ── Responsive ─────────────────────────── */
@media (max-width: 1024px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-col-preview {
        border-left: none;
        border-top: 1px solid var(--border);
        padding-left: 0;
        padding-top: 24px;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 64px;
        min-width: 64px;
    }

    .logo h1, .nav-btn span:not(.nav-icon), .sidebar-footer .version {
        display: none;
    }

    .logo {
        justify-content: center;
        padding: 20px 8px;
    }

    .nav-btn {
        justify-content: center;
        padding: 14px;
    }

    .main-content {
        margin-left: 64px;
        padding: 20px;
    }

    .page-header {
        flex-direction: column;
        gap: 12px;
    }
}

/* ═══════════════════════════════════════════
   Wissensdatenbank Treffer (Live Analyse)
   ═══════════════════════════════════════════ */

.wd-treffer-container {
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.wd-hit {
    background: var(--bg-card, #f8fafc);
    border: 1px solid var(--border, #e2e8f0);
    border-left: 4px solid var(--accent, #2563eb);
    border-radius: 8px;
    padding: 12px 14px;
}

.wd-hit-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.wd-hit-header strong {
    font-size: 0.95rem;
    color: var(--text, #1e293b);
}

.wd-hit-problem {
    font-size: 0.88rem;
    color: var(--text-muted, #64748b);
    margin-bottom: 6px;
    line-height: 1.4;
}

.wd-hit-loesung {
    font-size: 0.88rem;
    color: var(--text, #1e293b);
    line-height: 1.5;
    background: rgba(34, 197, 94, 0.06);
    border-radius: 6px;
    padding: 8px 10px;
}

.wd-loading,
.wd-no-hit,
.wd-error {
    font-size: 0.88rem;
    color: var(--text-muted, #64748b);
    font-style: italic;
    padding: 8px 0;
}

.wd-error {
    color: #dc2626;
}

/* ═══════════════════════════════════════════
   Voice Agent (Mikrofon + Vorlesen)
   ═══════════════════════════════════════════ */

.mic-btn {
    margin-left: 8px;
    padding: 4px 10px;
    font-size: 0.8rem;
    background: var(--bg-card, #f1f5f9);
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 16px;
    cursor: pointer;
    color: var(--text, #334155);
    transition: all 0.2s;
    vertical-align: middle;
}

.mic-btn:hover {
    background: #e2e8f0;
}

.mic-btn.listening {
    background: #dcfce7;
    border-color: #22c55e;
    color: #166534;
    animation: mic-pulse 1.5s infinite;
}

@keyframes mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
}

.mic-status {
    margin-top: 8px;
    padding: 8px 12px;
    font-size: 0.85rem;
    background: #eff6ff;
    border: 1px solid #93c5fd;
    border-radius: 6px;
    color: #1e40af;
}

.mic-status.mic-error {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #991b1b;
}

.voice-read-btn {
    margin-left: auto;
    padding: 4px 12px;
    font-size: 0.8rem;
    background: var(--bg-card, #f1f5f9);
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 16px;
    cursor: pointer;
    color: var(--text, #334155);
    transition: all 0.2s;
}

.voice-read-btn:hover {
    background: #dbeafe;
    border-color: #3b82f6;
}

.voice-read-btn.speaking {
    background: #dbeafe;
    border-color: #3b82f6;
    color: #1d4ed8;
}
