/* RWD QM-Assistent — Design-System (RWD-CI, Layout-Muster der Tool-Familie) */
/* html = RWD-Blau: verhindert weissen Flash + traegt das Fade-In beim Tool-Wechsel. */
html { background: #14375E; }

:root {
    --rwd-blue-900: #14375E;
    --rwd-blue-700: #1F4E7A;
    --rwd-teal-600: #2BA587;
    --bg: #f3f4f6;
    --border: #e5e7eb;
    --text: #1d2330;
    --text-muted: #6b7280;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: 'Inter', system-ui, -apple-system, sans-serif; color: var(--text); font-size: 14px; }
body { background: transparent; }

.app-shell { display: flex; min-height: 100vh; background: var(--bg); }

/* ── Sidebar ── */
.sidebar {
    width: 240px; background: var(--rwd-blue-900); color: #fff;
    display: flex; flex-direction: column; padding: 18px 14px;
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 200;
}
.sidebar-header { display: flex; flex-direction: column; align-items: center; padding-bottom: 14px; margin-bottom: 8px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-logo {
    max-width: 180px; max-height: 80px; width: auto; height: auto;
    object-fit: contain; display: block; margin: 0 auto 8px;
    background: #fff; border-radius: 6px; padding: 6px 8px;
}
.sidebar-brand { font-size: 14px; font-weight: 700; color: rgba(255,255,255,0.92); letter-spacing: 0.4px; text-transform: uppercase; }
.sidebar-nav { flex: 1; overflow-y: auto; }
.sidebar-divider { height: 1px; background: rgba(255,255,255,0.15); margin: 12px 12px 8px; }
.sidebar-section-label { padding: 0 14px 6px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: rgba(255,255,255,0.55); }
.nav-link {
    display: block; padding: 9px 12px; color: rgba(255,255,255,0.78);
    text-decoration: none; border-radius: 7px; margin-bottom: 2px; font-size: 13.5px;
}
.nav-link:hover { background: rgba(255,255,255,0.12); color: #fff; }
.nav-link.active { background: rgba(255,255,255,0.22); color: #fff; font-weight: 600; }
.sidebar-footer { border-top: 1px solid rgba(255,255,255,0.12); padding-top: 12px; }
.sidebar-footer .user { font-size: 12px; color: rgba(255,255,255,0.7); margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; }
.btn-logout {
    width: 100%; background: rgba(255,255,255,0.1); color: #fff; border: 1px solid rgba(255,255,255,0.2);
    padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 12px;
}
.btn-logout:hover { background: rgba(255,255,255,0.2); }

.main { margin-left: 240px; flex: 1; padding: 24px; min-width: 0; }

h1 { font-size: 22px; font-weight: 700; margin: 0 0 16px; }
h1:focus, h2:focus, h3:focus { outline: none; }
h2 { font-size: 18px; font-weight: 700; margin: 0 0 14px; }
h3 { font-size: 15px; font-weight: 600; margin: 0 0 10px; }

/* ── Cards ── */
.card { background: #fff; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 14px; }
.card-header { padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 13.5px; }
.card-body { padding: 16px; }

/* ── Text / Utility ── */
.text-muted { color: var(--text-muted); }
.small { font-size: 12px; }
.mt-3 { margin-top: 14px; }
.mb-3 { margin-bottom: 14px; }
.w-100 { width: 100%; }
.fw-bold { font-weight: 700; }

/* ── Buttons ── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 16px; border-radius: 7px; border: 1px solid transparent;
    cursor: pointer; font-size: 14px; font-weight: 500; text-decoration: none;
    transition: all .15s; line-height: 1.2;
}
.btn-primary { background: var(--rwd-blue-700); color: #fff; }
.btn-primary:hover { background: var(--rwd-blue-900); color: #fff; }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-lg { padding: 12px 20px; font-size: 15px; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
button:disabled, .btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Formulare ── */
.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.form-row input, .form-row select, .form-row textarea {
    width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
    font-size: 13.5px; font-family: inherit; background: #fff; color: var(--text);
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
    outline: none; border-color: var(--rwd-blue-700); box-shadow: 0 0 0 3px rgba(31,78,122,0.12);
}
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

/* ── Tabellen ── */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
    padding: 9px 12px; text-align: left; font-weight: 600; font-size: 11.5px;
    color: var(--text-muted); background: #f9fafb; border-bottom: 1px solid var(--border);
    text-transform: uppercase; letter-spacing: 0.3px; white-space: nowrap;
}
.table td { padding: 9px 12px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
.table tbody tr:hover { background: #fafafa; }
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── Badges / Ampel ── */
.badge {
    display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px;
    font-size: 11px; font-weight: 700; line-height: 1.5; white-space: nowrap;
}
.badge-ok { background: #d1fae5; color: #065f46; }
.badge-bald { background: #fef3c7; color: #92400e; }
.badge-ueberfaellig { background: #fee2e2; color: #b91c1c; }
.badge-neutral { background: #e5e7eb; color: #374151; }

/* ── KPI-Ampel-Kacheln (Dashboard) ── */
.kpi-grid {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px; margin-bottom: 20px;
}
@media (max-width: 1199px) { .kpi-grid { grid-template-columns: 1fr; } }
.kpi-card {
    position: relative; background: #fff; border: 1px solid var(--border);
    border-radius: 14px; padding: 20px 20px 18px; overflow: hidden;
}
.kpi-card::before {
    content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px;
    background: var(--accent, var(--rwd-blue-700));
}
.kpi-card--primary { --accent: #1F4E7A; }
.kpi-card--teal    { --accent: #2BA587; }
.kpi-card--orange  { --accent: #f97316; }
.kpi-card__icon {
    position: absolute; top: 16px; right: 18px; width: 40px; height: 40px;
    border-radius: 10px; display: flex; align-items: center; justify-content: center;
    font-size: 20px; background: var(--bg);
}
.kpi-card__label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 8px; }
.kpi-card__value { font-size: 28px; font-weight: 800; line-height: 1.1; margin-bottom: 4px; }
.kpi-card__sub { font-size: 12.5px; color: var(--text-muted); }

/* ── Modal ── */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 400;
    display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
    background: #fff; border-radius: 12px; padding: 20px;
    max-width: 560px; width: 100%; max-height: 88vh; overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.modal h3 { margin-top: 0; }

/* ── Toasts ── */
.toast-wrap { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 500; display: flex; flex-direction: column; gap: 8px; }
.toast {
    background: rgba(20,55,94,0.94); color: #fff; padding: 10px 18px; border-radius: 8px;
    font-size: 13px; font-weight: 500; box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    animation: fadeIn .2s ease;
}
.toast.warn { background: rgba(180,83,9,0.95); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Login ── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--rwd-blue-900); padding: 20px; }
.login-card { background: #fff; padding: 32px; border-radius: 14px; max-width: 420px; width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,0.3); border-top: 4px solid var(--rwd-teal-600); }
.login-card h2 { margin-top: 0; }

/* ── Anleitung ── */
.anl-section { margin-bottom: 20px; }

/* ── KI-Chat ── */
.chat-layout {
    display: flex; gap: 16px;
    height: calc(100vh - 100px);
    min-height: 420px;
}
.chat-sessions {
    flex: 0 0 230px;
    overflow-y: auto;
    padding-right: 4px;
}
.chat-session-item {
    display: flex; flex-direction: column; gap: 2px;
    width: 100%; text-align: left;
    background: #fff; border: 1px solid var(--border); border-radius: 8px;
    padding: 9px 11px; margin-bottom: 6px; cursor: pointer;
    transition: border-color .15s, background .15s;
}
.chat-session-item:hover { border-color: var(--rwd-blue-700); }
.chat-session-item.active { border-color: var(--rwd-blue-700); background: #eef4fa; }
.chat-session-titel {
    font-size: 12.5px; font-weight: 600;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-session-zeit { font-size: 10.5px; color: var(--text-muted); }

.chat-main {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column;
    background: #fff; border: 1px solid var(--border); border-radius: 12px;
    overflow: hidden;
}
.chat-verlauf {
    flex: 1; overflow-y: auto;
    padding: 18px 18px 8px;
    display: flex; flex-direction: column; gap: 12px;
    scroll-behavior: smooth;
}
.chat-msg { display: flex; flex-direction: column; max-width: 82%; }
.chat-msg.user { align-self: flex-end; align-items: flex-end; }
.chat-msg.assistant { align-self: flex-start; align-items: flex-start; }
.chat-bubble {
    padding: 10px 14px; border-radius: 14px;
    font-size: 14px; line-height: 1.55;
    word-break: break-word;
}
.chat-msg.user .chat-bubble {
    background: var(--rwd-blue-700); color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-msg.assistant .chat-bubble {
    background: #f3f4f6; color: var(--text);
    border-bottom-left-radius: 4px;
}
.chat-denkt { color: var(--text-muted); font-style: italic; animation: chatPulse 1.4s ease infinite; }
@keyframes chatPulse { 0%,100% { opacity: 0.55; } 50% { opacity: 1; } }
.chat-cursor { animation: chatPulse 1s ease infinite; color: var(--rwd-teal-600); }
.chat-tools { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 5px; }
.chat-tool-chip {
    font-size: 11px; font-weight: 600;
    background: #e6f4f0; color: #0f766e;
    border: 1px solid #b8e0d5; border-radius: 999px;
    padding: 2px 10px;
}
.chat-eingabe {
    display: flex; gap: 8px; align-items: flex-end;
    padding: 12px; border-top: 1px solid var(--border);
    background: #fafafa;
}
.chat-eingabe textarea {
    flex: 1; resize: none;
    padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
    font-family: inherit; font-size: 14px; line-height: 1.4;
}
.chat-eingabe textarea:focus { outline: none; border-color: var(--rwd-blue-700); }
.chat-senden { min-width: 48px; height: 44px; border-radius: 10px; font-size: 17px; }
.chat-mikro {
    min-width: 48px; height: 44px; border-radius: 10px; font-size: 17px;
    background: #fff; border: 1px solid var(--border);
}
.chat-mikro:hover { border-color: var(--rwd-blue-700); }
.chat-mikro.aufnahme {
    background: #fee2e2; border-color: #dc2626; color: #b91c1c;
    animation: mikroPuls 1.1s ease infinite;
}
@keyframes mikroPuls {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0.35); }
    50% { box-shadow: 0 0 0 7px rgba(220,38,38,0); }
}
.chat-intro {
    text-align: center; margin: auto; max-width: 460px; padding: 20px;
}
.chat-intro-icon { font-size: 42px; margin-bottom: 8px; }
.chat-beispiele { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }
.chat-beispiel {
    background: #fff; border: 1px solid var(--border); border-radius: 999px;
    padding: 7px 14px; font-size: 12.5px; cursor: pointer; color: var(--rwd-blue-700);
    transition: all .15s;
}
.chat-beispiel:hover { border-color: var(--rwd-blue-700); background: #eef4fa; }

/* ── Floating "Zum Dashboard"-Button (Tool-Konvention) ── */
.back-to-dashboard {
    position: fixed; right: 22px; bottom: 22px; z-index: 1500;
    display: inline-flex; align-items: center; gap: 8px;
    padding: 11px 18px 11px 16px;
    background: var(--rwd-blue-700); color: #fff !important;
    border: none; border-radius: 999px; text-decoration: none;
    font-size: 13px; font-weight: 600; letter-spacing: 0.2px;
    box-shadow: 0 10px 24px rgba(20,55,94,0.28), 0 2px 4px rgba(0,0,0,0.06);
    opacity: 0.95; transition: all .18s ease;
}
.back-to-dashboard svg { display: block; flex-shrink: 0; }
.back-to-dashboard:hover {
    opacity: 1; background: var(--rwd-teal-600);
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 14px 32px rgba(20,55,94,0.32), 0 2px 4px rgba(0,0,0,0.08);
}

/* ── Fade-In/Out fuer Tool-Wechsel (RWD-Konvention) ── */
@keyframes rwdPageEnter { from { opacity: 0; } to { opacity: 1; } }
@keyframes rwdPageLeave { from { opacity: 1; } to { opacity: 0; } }
body { animation: rwdPageEnter 0.28s ease-out both; }
body.rwd-leaving { animation: rwdPageLeave 0.18s ease-in both; }

/* Blazor-Error-UI dezent */
#blazor-error-ui { display: none; }
