/* ============================================================
   Copilot – Styles
   Theme-Regel: ALLE Farben laufen über Custom Properties, die
   unter [data-theme="dark"] und [data-theme="light"] definiert
   sind. Niemals Farben hart in Komponenten codieren!
   ============================================================ */

/* ---------- Themes ---------- */
[data-theme="dark"] {
    --bg: #0e1117;
    --bg-gradient: radial-gradient(1200px 600px at 80% -10%, rgba(108, 140, 255, 0.10), transparent 60%),
                   radial-gradient(900px 500px at -10% 110%, rgba(165, 108, 255, 0.08), transparent 60%);
    --surface: #161b26;
    --surface-2: #1d2433;
    --surface-hover: #222b3d;
    --text: #e8ecf5;
    --text-muted: #98a3b8;
    --border: #262f42;
    --accent: #6c8cff;
    --accent-2: #a56cff;
    --accent-gradient: linear-gradient(135deg, #6c8cff, #a56cff);
    --accent-soft: rgba(108, 140, 255, 0.14);
    --positive: #4ade80;
    --positive-soft: rgba(74, 222, 128, 0.14);
    --negative: #f87171;
    --negative-soft: rgba(248, 113, 113, 0.14);
    --neutral: #93a3bd;
    --neutral-soft: rgba(147, 163, 189, 0.14);
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
}

[data-theme="light"] {
    --bg: #f3f5fa;
    --bg-gradient: radial-gradient(1200px 600px at 80% -10%, rgba(108, 140, 255, 0.10), transparent 60%),
                   radial-gradient(900px 500px at -10% 110%, rgba(165, 108, 255, 0.08), transparent 60%);
    --surface: #ffffff;
    --surface-2: #f6f8fc;
    --surface-hover: #eef1f8;
    --text: #1c2333;
    --text-muted: #64708a;
    --border: #dfe4ef;
    --accent: #5271e8;
    --accent-2: #8f56e8;
    --accent-gradient: linear-gradient(135deg, #5271e8, #8f56e8);
    --accent-soft: rgba(82, 113, 232, 0.12);
    --positive: #17903f;
    --positive-soft: rgba(23, 144, 63, 0.12);
    --negative: #d33f3f;
    --negative-soft: rgba(211, 63, 63, 0.12);
    --neutral: #64708a;
    --neutral-soft: rgba(100, 112, 138, 0.12);
    --shadow: 0 8px 24px rgba(28, 35, 51, 0.10);
    --shadow-sm: 0 2px 8px rgba(28, 35, 51, 0.08);
    color-scheme: light;
}

/* ---------- Basis ---------- */
* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    background-image: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text);
    font-size: 15px;
    line-height: 1.55;
    transition: background-color 0.25s ease, color 0.25s ease;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.6em; }
h1 { font-size: 1.5rem; display: flex; align-items: center; gap: 0.5em; flex-wrap: wrap; }
h2 { font-size: 1.05rem; display: flex; align-items: center; gap: 0.4em; }
.h-sub { font-size: 0.9rem; color: var(--text-muted); margin-top: 1.2em; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.1em 0.4em;
    font-size: 0.85em;
}

.muted { color: var(--text-muted); font-size: 0.88em; }
.t-right { text-align: right; }
.t-center { text-align: center; }

/* ---------- App-Grundgerüst ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 232px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 16px 12px;
    position: sticky;
    top: 0;
    height: 100vh;
    transition: transform 0.25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 18px;
    font-weight: 700;
    font-size: 1.1rem;
}

.logo-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--accent-gradient);
    color: #fff;
    font-weight: 800;
    box-shadow: var(--shadow-sm);
}

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 8px; display: flex; flex-direction: column; gap: 2px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    color: var(--text-muted);
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
}
.nav-link:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }
.nav-link span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    position: sticky;
    top: 0;
    z-index: 10;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: blur(8px);
}
.topbar-spacer { flex: 1; }
.topbar .nav-toggle { display: none; }

.content { padding: 8px 24px 40px; max-width: 1200px; width: 100%; margin: 0 auto; }

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin: 12px 0 20px;
}
.page-head h1 { margin: 0; }

/* ---------- Karten ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: background-color 0.25s ease, border-color 0.25s ease;
}
.card-narrow { max-width: 640px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-head h2 { margin: 0; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: 1fr 1fr; align-items: start; }
.grid-sidebar { grid-template-columns: 2fr 1fr; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 20px; }

/* ---------- Dashboard ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.stat-card {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--text);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); text-decoration: none; }
.stat-value { font-size: 1.5rem; display: block; line-height: 1.1; }
.stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    flex-shrink: 0;
}
.stat-icon.accent-1 { background: var(--accent-soft); color: var(--accent); }
.stat-icon.accent-2 { background: var(--positive-soft); color: var(--positive); }
.stat-icon.accent-3 { background: var(--neutral-soft); color: var(--neutral); }
.stat-icon.accent-4 { background: var(--accent-soft); color: var(--accent-2); }

.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.tile {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 16px;
    border-radius: 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.tile:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--accent);
    text-decoration: none;
}
.tile-icon { color: var(--accent); }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; margin-top: 8px; }
.table { width: 100%; border-collapse: collapse; }
.table th {
    text-align: left;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}
.table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tbody tr { transition: background 0.12s ease; }
.table tbody tr:hover { background: var(--surface-hover); }
.table-click tbody tr { cursor: pointer; }
.row-muted { opacity: 0.55; }

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--accent-gradient);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    margin-right: 8px;
    vertical-align: middle;
    flex-shrink: 0;
}
.avatar-lg { width: 42px; height: 42px; font-size: 0.95rem; }

/* ---------- Badges ---------- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-positive, .badge-status-active { background: var(--positive-soft); color: var(--positive); }
.badge-negative, .badge-status-left { background: var(--negative-soft); color: var(--negative); }
.badge-neutral { background: var(--neutral-soft); color: var(--neutral); }
.badge-status-hired, .badge-role { background: var(--accent-soft); color: var(--accent); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 16px;
    border-radius: 10px;
    border: 1px solid transparent;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    background: none;
    color: var(--text);
    transition: transform 0.1s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.98); }

.btn-primary {
    background: var(--accent-gradient);
    color: #fff;
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover { box-shadow: var(--shadow); filter: brightness(1.06); }

.btn-ghost { border-color: var(--border); color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }

.btn-danger-ghost:hover { background: var(--negative-soft); color: var(--negative); border-color: transparent; }

.btn-sm { padding: 5px 10px; font-size: 0.82rem; border-radius: 8px; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { padding: 8px; }

.action-row { display: inline-flex; gap: 4px; align-items: center; }
.action-row form { display: inline-flex; margin: 0; }

/* ---------- Formulare ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form-tight { gap: 10px; margin-bottom: 18px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 0.86rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

input, select, textarea {
    font-family: inherit;
    font-size: 0.92rem;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 9px 12px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    width: 100%;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; }

input:disabled { opacity: 0.6; cursor: not-allowed; }

/* Segmented Control (Pflicht-Bewertung bei Anmerkungen) */
.seg-label { display: block; font-weight: 600; font-size: 0.86rem; margin-bottom: 6px; }
.seg { display: flex; gap: 8px; }
.seg input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }
.seg label {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.seg label:hover { background: var(--surface-hover); }
.seg input:focus-visible + label { box-shadow: 0 0 0 3px var(--accent-soft); }
.seg input:checked + label.seg-positive { background: var(--positive-soft); color: var(--positive); border-color: var(--positive); }
.seg input:checked + label.seg-neutral { background: var(--neutral-soft); color: var(--neutral); border-color: var(--neutral); }
.seg input:checked + label.seg-negative { background: var(--negative-soft); color: var(--negative); border-color: var(--negative); }

.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.filter-bar select { width: auto; }
.input-icon { position: relative; flex: 1; min-width: 200px; }
.input-icon svg {
    position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); pointer-events: none;
}
.input-icon input { padding-left: 36px; }

/* ---------- Definition-Listen ---------- */
.def-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; margin: 0; }
.def-list dt { color: var(--text-muted); font-size: 0.86rem; }
.def-list dd { margin: 0; }

/* ---------- Timeline (Anmerkungen) ---------- */
.timeline { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.timeline-item {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-left: 3px solid var(--neutral);
    border-radius: 12px;
    padding: 12px 14px;
    animation: fadeIn 0.25s ease;
}
.timeline-item p { margin: 6px 0 0; }
.timeline-item.note-positive { border-left-color: var(--positive); }
.timeline-item.note-negative { border-left-color: var(--negative); }
.timeline-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.timeline-head form { margin-left: auto; }
.timeline-trainee { font-weight: 600; }
.timeline-compact .timeline-item { padding: 10px 12px; }
.timeline-compact p { font-size: 0.88rem; }

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

/* ---------- Historie-Liste ---------- */
.history-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.history-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
}

.details summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--accent);
    margin: 12px 0;
    user-select: none;
}

/* ---------- Flash-Meldungen ---------- */
.flash {
    padding: 11px 16px;
    border-radius: 12px;
    margin-bottom: 14px;
    font-weight: 500;
    border: 1px solid transparent;
    animation: fadeIn 0.25s ease;
}
.flash-success { background: var(--positive-soft); color: var(--positive); border-color: color-mix(in srgb, var(--positive) 30%, transparent); }
.flash-error { background: var(--negative-soft); color: var(--negative); border-color: color-mix(in srgb, var(--negative) 30%, transparent); }

.empty-state { color: var(--text-muted); text-align: center; padding: 24px 12px; }

.error-code {
    font-size: 4rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    justify-content: center;
}

/* ---------- Theme-Toggle ---------- */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 7px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    color: var(--text-muted);
    transition: border-color 0.15s ease;
}
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-gradient);
    transition: transform 0.25s ease;
}
[data-theme="light"] .icon-moon { opacity: 0.35; }
[data-theme="dark"] .icon-sun { opacity: 0.35; }

/* ---------- Schnellsuche-Popup ---------- */
[data-theme="dark"] { --overlay: rgba(0, 0, 0, 0.55); }
[data-theme="light"] { --overlay: rgba(28, 35, 51, 0.35); }

.search-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 12vh 16px 0;
    background: var(--overlay);
    backdrop-filter: blur(3px);
}
.search-overlay.show { display: flex; }

.search-modal {
    width: 100%;
    max-width: 520px;
    padding: 14px;
    box-shadow: var(--shadow);
    animation: fadeIn 0.15s ease;
}

.search-results {
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
    max-height: 320px;
    overflow-y: auto;
}
.search-results li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 10px;
    cursor: pointer;
}
.search-results li strong { flex: 1; }
.search-results li.active { background: var(--accent-soft); }
.search-results .search-empty { cursor: default; color: var(--text-muted); justify-content: center; }
.search-results .search-empty:hover { background: none; }

.search-hint { margin-top: 10px; font-size: 0.76rem; text-align: center; }

kbd.kbd-hint {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1px 6px;
    font-size: 0.72rem;
    font-family: inherit;
    color: var(--text-muted);
}
@media (max-width: 760px) { kbd.kbd-hint { display: none; } }

/* ---------- Login / Installation ---------- */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}
.auth-card { width: 100%; max-width: 400px; padding: 32px; }
.auth-logo { text-align: center; margin-bottom: 20px; }
.auth-logo .logo-badge { width: 52px; height: 52px; font-size: 1.5rem; border-radius: 14px; margin-bottom: 10px; }
.auth-logo h1 { justify-content: center; margin-bottom: 2px; }
.auth-logo h1 small { font-size: 0.6em; color: var(--text-muted); font-weight: 500; }
.auth-logo p { margin: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .grid-2, .grid-sidebar, .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .sidebar {
        position: fixed;
        z-index: 40;
        transform: translateX(-100%);
        box-shadow: var(--shadow);
    }
    .sidebar.open { transform: translateX(0); }
    .topbar .nav-toggle { display: inline-flex; }
    .content { padding: 8px 16px 32px; }
}
