/* =============================================================
   GfD Rezertifizierungs-Manager – Stylesheet
   ============================================================= */

/* --- Variablen & Reset --- */
:root {
    --navy:       #1B365D;
    --navy-dark:  #142748;
    --navy-light: #E8EEF7;
    --teal:       #14B8A6;
    --teal-light: #CCFBF1;
    --violet:     #8B5CF6;
    --violet-light: #EDE9FE;
    --blue:       #2563EB;
    --blue-light: #DBEAFE;
    --amber:      #D97706;
    --amber-light: #FEF3C7;
    --green:      #10B981;
    --green-light: #D1FAE5;
    --orange:     #F59E0B;
    --orange-light: #FEF3C7;
    --red:        #EF4444;
    --red-light:  #FEE2E2;
    --bg:         #FAFAF8;
    --surface:    #FFFFFF;
    --border:     #E5E7EB;
    --text:       #111827;
    --text-muted: #6B7280;
    --text-light: #9CA3AF;
    --radius:     10px;
    --radius-sm:  6px;
    --shadow-sm:  0 1px 4px rgba(0,0,0,0.08);
    --shadow:     0 4px 16px rgba(0,0,0,0.1);
    --shadow-lg:  0 8px 32px rgba(0,0,0,0.14);
    --transition: all 0.15s ease;
    --sidebar-w:  220px;
    --header-h:   60px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: 'Inter', Calibri, Arial, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; min-width: 1024px; }
h1, h2, h3, h4, h5, h6 { font-family: 'Inter Tight', 'Inter', Calibri, Arial, sans-serif; font-weight: 600; }
a { color: var(--navy); text-decoration: none; }
a:hover { color: var(--teal); }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }
img { max-width: 100%; display: block; }
ul { list-style: none; }

/* --- Layout --- */
.app-wrapper { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* Header */
.app-header {
    height: var(--header-h);
    background: var(--navy);
    color: #fff;
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    z-index: 100;
}
.header-logo { height: 36px; filter: brightness(0) invert(1); }
.header-divider { width: 1px; height: 28px; background: rgba(255,255,255,0.2); }
.header-title { font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; flex: 1; color: rgba(255,255,255,0.9); }
.header-user { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: rgba(255,255,255,0.7); }
.header-user-name { font-weight: 500; color: #fff; }
.header-user-avatar {
    width: 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,0.15);
    display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 0.8rem;
}

/* Body = Sidebar + Main */
.app-body { display: flex; flex: 1; overflow: hidden; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
    padding: 16px 0;
}
.sidebar-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 8px 20px 6px;
}
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}
.sidebar-item:hover { background: var(--bg); color: var(--navy); }
.sidebar-item.active { background: var(--navy-light); color: var(--navy); font-weight: 500; }
.sidebar-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 4px; bottom: 4px;
    width: 3px; border-radius: 0 3px 3px 0;
    background: var(--navy);
}
.sidebar-dot {
    width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.sidebar-count {
    margin-left: auto;
    font-size: 0.75rem;
    background: var(--bg);
    color: var(--text-muted);
    padding: 1px 7px;
    border-radius: 20px;
    border: 1px solid var(--border);
}
.sidebar-divider { height: 1px; background: var(--border); margin: 10px 0; }
.sidebar-bottom { margin-top: auto; padding: 16px; }
.sidebar-log-btn {
    width: 100%; text-align: left; padding: 10px 20px; font-size: 0.85rem;
    color: var(--text-muted); background: none; border: none; cursor: pointer;
    transition: var(--transition); display: flex; align-items: center; gap: 8px;
}
.sidebar-log-btn:hover { color: var(--navy); background: var(--bg); }

/* Dot colors */
.dot-fds   { background: var(--teal); }
.dot-dsa   { background: var(--blue); }
.dot-co    { background: var(--amber); }
.dot-ki    { background: var(--violet); }
.dot-isb   { background: var(--navy); }

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 28px 32px;
    background: var(--bg);
}
.main-header {
    display: flex;
    align-items: baseline;
    gap: 16px;
    margin-bottom: 24px;
}
.main-title { font-size: 1.4rem; font-weight: 600; color: var(--navy); }
.main-subtitle { font-size: 0.9rem; color: var(--text-muted); }

/* --- Stat-Cards --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.stat-number { font-size: 2rem; font-weight: 700; color: var(--navy); line-height: 1; }
.stat-card.stat-green  .stat-number { color: var(--green); }
.stat-card.stat-orange .stat-number { color: var(--orange); }
.stat-card.stat-red    .stat-number { color: var(--red); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 6px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }

/* --- Requirements Box --- */
.requirements-box {
    background: var(--navy-light);
    border: 1px solid #C7D5EC;
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 24px;
    display: flex;
    gap: 24px;
    align-items: flex-start;
    flex-wrap: wrap;
}
.req-item { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--navy); }
.req-icon { font-size: 1rem; }
.req-label { font-weight: 500; }
.req-note  { color: var(--text-muted); font-size: 0.8rem; }
.req-special {
    background: var(--amber-light);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    font-size: 0.82rem;
    color: #92400E;
    border: 1px solid #FCD34D;
}

/* --- Tabelle --- */
.table-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 24px;
}
.table-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.table-toolbar-title { font-weight: 600; font-size: 0.95rem; color: var(--navy); flex: 1; }
.search-input {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 12px;
    font-size: 0.85rem;
    width: 220px;
    outline: none;
    transition: var(--transition);
    background: var(--bg);
}
.search-input:focus { border-color: var(--navy); background: #fff; }

table { width: 100%; border-collapse: collapse; }
thead { background: var(--bg); }
thead th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    padding: 10px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--navy); }
tbody tr { transition: var(--transition); }
tbody tr:hover { background: #F9FAFB; }
tbody td { padding: 12px 16px; font-size: 0.88rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
.td-name { font-weight: 500; }
.td-email { color: var(--text-muted); font-size: 0.82rem; }

/* --- Badges --- */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }
.badge-green  { background: var(--green-light);  color: #065F46; }
.badge-green::before  { background: var(--green); }
.badge-orange { background: var(--orange-light); color: #92400E; }
.badge-orange::before { background: var(--orange); }
.badge-red    { background: var(--red-light);    color: #991B1B; }
.badge-red::before    { background: var(--red); }
.badge-gray   { background: #F3F4F6; color: var(--text-muted); }
.badge-gray::before   { background: var(--text-light); }
.badge-blue   { background: var(--blue-light);   color: #1E40AF; }
.badge-teal   { background: var(--teal-light);   color: #065E55; }

/* --- Fortschrittsbalken --- */
.progress-wrap { display: flex; align-items: center; gap: 8px; min-width: 140px; }
.progress-bar { flex: 1; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; transition: width 0.3s ease; background: var(--teal); }
.progress-fill.warn  { background: var(--orange); }
.progress-fill.done  { background: var(--green); }
.progress-label { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; }

/* --- Aktions-Buttons in Tabelle --- */
.btn-icon {
    width: 30px; height: 30px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--surface);
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; transition: var(--transition); color: var(--text-muted); font-size: 0.9rem;
}
.btn-icon:hover { border-color: var(--navy); color: var(--navy); background: var(--navy-light); }
.btn-icon.danger:hover { border-color: var(--red); color: var(--red); background: var(--red-light); }

/* --- Buttons --- */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 18px; border-radius: var(--radius-sm); font-size: 0.875rem;
    font-weight: 500; border: 1px solid transparent; cursor: pointer; transition: var(--transition);
    white-space: nowrap;
}
.btn-primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-primary:hover { background: var(--navy-dark); border-color: var(--navy-dark); }
.btn-secondary { background: var(--surface); color: var(--navy); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--navy); background: var(--navy-light); }
.btn-danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn-danger:hover { background: #DC2626; }
.btn-block { width: 100%; justify-content: center; }
.btn-teal { background: var(--teal); color: #fff; border-color: var(--teal); }
.btn-teal:hover { background: #0D9488; }

/* --- Action-Bar unter Tabelle --- */
.action-bar {
    display: flex; gap: 12px; padding: 16px 20px;
    background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm);
    margin-bottom: 24px; align-items: center; flex-wrap: wrap;
}
.action-bar-title { font-weight: 600; font-size: 0.9rem; color: var(--navy); flex: 1; }

/* --- Import-Bereich --- */
.import-section {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px 24px;
    margin-bottom: 24px;
}
.import-section h3 { font-size: 0.95rem; font-weight: 600; color: var(--navy); margin-bottom: 14px; }
.dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-muted);
    font-size: 0.875rem;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--navy); background: var(--navy-light); color: var(--navy); }
.dropzone input[type=file] { display: none; }
.dropzone-icon { font-size: 2rem; margin-bottom: 8px; }

/* --- E-Mail-Vorschau --- */
.email-preview {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 24px;
}
.email-preview-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border); cursor: pointer;
}
.email-preview-header h3 { font-size: 0.95rem; font-weight: 600; color: var(--navy); }
.email-preview-body { padding: 20px; display: none; }
.email-preview-body.open { display: block; }
.email-mock {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    font-size: 0.85rem;
}
.email-mock-header { background: var(--navy); padding: 16px 20px; }
.email-mock-logo { height: 32px; filter: brightness(0) invert(1); }
.email-mock-content { padding: 20px; }
.email-mock-content h4 { color: var(--navy); margin-bottom: 12px; font-size: 1rem; }
.email-mock-content p { color: #374151; margin-bottom: 12px; line-height: 1.6; }
.email-mock-table { width: 100%; border-collapse: collapse; margin: 16px 0; }
.email-mock-table th { background: var(--navy); color: #fff; padding: 8px 12px; font-size: 0.8rem; text-align: left; }
.email-mock-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 0.82rem; }
.email-mock-table tr:nth-child(even) td { background: var(--bg); }
.email-mock-footer { background: var(--bg); border-top: 1px solid var(--border); padding: 12px 20px; font-size: 0.75rem; color: var(--text-muted); text-align: center; }

/* --- Modal --- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none; transition: opacity 0.15s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
    background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg);
    width: 100%; max-width: 540px; max-height: 90vh; overflow-y: auto;
    transform: translateY(10px); opacity: 0; transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.15s ease;
}
.modal-overlay.open .modal { transform: translateY(0); opacity: 1; }
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1.1rem; font-weight: 600; color: var(--navy); }
.modal-close { background: none; border: none; font-size: 1.4rem; color: var(--text-muted); cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* --- Formular --- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .form-group.full { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 0; }
.form-label { font-size: 0.82rem; font-weight: 500; color: var(--text-muted); }
.form-control {
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 9px 12px; font-size: 0.9rem; outline: none; transition: var(--transition);
    background: #fff; color: var(--text);
}
.form-control:focus { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(27,54,93,0.1); }
.form-control:invalid.touched { border-color: var(--red); }
.form-hint { font-size: 0.78rem; color: var(--text-muted); }
.form-check { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; cursor: pointer; }
.form-check input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--navy); cursor: pointer; }

/* --- Alerts --- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 12px; font-size: 0.88rem; border: 1px solid transparent; }
.alert-ok  { background: var(--green-light);  color: #065F46; border-color: rgba(16,185,129,0.35); }
.alert-err { background: var(--red-light);    color: #991B1B; border-color: rgba(239,68,68,0.35); }
.alert-warn{ background: var(--amber-light);  color: #92400E; border-color: rgba(217,119,6,0.35); }
.alert-info{ background: var(--blue-light);   color: #1E40AF; border-color: rgba(37,99,235,0.35); }

/* --- Toast-Notifications --- */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
    padding: 12px 18px; border-radius: var(--radius); box-shadow: var(--shadow);
    font-size: 0.88rem; font-weight: 500; min-width: 240px; max-width: 360px;
    display: flex; align-items: center; gap: 10px;
    animation: slideIn 0.2s ease forwards;
}
.toast-ok   { background: #065F46; color: #fff; }
.toast-err  { background: #991B1B; color: #fff; }
.toast-info { background: var(--navy); color: #fff; }
@keyframes slideIn { from { transform: translateX(100px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100px); opacity: 0; } }

/* --- Mail-Log-Panel --- */
.log-panel {
    position: fixed; top: var(--header-h); right: 0; bottom: 0;
    width: 480px; background: var(--surface); box-shadow: -4px 0 20px rgba(0,0,0,0.12);
    z-index: 500; transform: translateX(100%); transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex; flex-direction: column;
}
.log-panel.open { transform: translateX(0); }
.log-panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border); background: var(--navy); color: #fff;
}
.log-panel-title { font-weight: 600; font-size: 0.95rem; }
.log-panel-close { background: none; border: none; color: rgba(255,255,255,0.7); font-size: 1.4rem; cursor: pointer; }
.log-panel-close:hover { color: #fff; }
.log-panel-body { flex: 1; overflow-y: auto; padding: 16px; }
.log-entry { padding: 10px 14px 10px 34px; border-radius: var(--radius-sm); border: 1px solid var(--border); margin-bottom: 8px; font-size: 0.82rem; position: relative; }
.log-entry::before { content: ''; position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 7px; height: 7px; border-radius: 50%; background: var(--border); }
.log-entry.ok::before  { background: var(--green); }
.log-entry.err::before { background: var(--red); }
.log-entry-meta { color: var(--text-muted); font-size: 0.75rem; margin-bottom: 4px; }
.log-entry-subject { font-weight: 500; color: var(--navy); }
.log-entry-to { color: var(--text-muted); }
.log-empty { text-align: center; padding: 40px; color: var(--text-muted); font-size: 0.9rem; }

/* --- Login-Card --- */
.login-card {
    background: var(--surface);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    padding: 48px;
    width: 100%;
    max-width: 420px;
}
.login-logo-wrap { text-align: center; margin-bottom: 24px; }
.login-logo { height: 52px; margin: 0 auto; }
.login-title { font-size: 1.2rem; font-weight: 600; color: var(--navy); text-align: center; margin-bottom: 4px; }
.login-subtitle { font-size: 0.875rem; color: var(--text-muted); text-align: center; margin-bottom: 28px; }
.login-footer { text-align: center; margin-top: 28px; font-size: 0.78rem; color: var(--text-muted); }
.form-group { margin-bottom: 16px; }
.form-group .form-label { display: block; margin-bottom: 5px; }

/* --- Hilfreich: Responsive ab 1024px --- */
@media (max-width: 1200px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 1100px) {
    :root { --sidebar-w: 180px; }
    .sidebar-item { padding: 10px 14px; font-size: 0.85rem; }
    .main-content { padding: 20px 20px; }
}

/* --- Tabellen-Spalten anzeigen/ausblenden --- */
.col-audits, .col-audittage, .col-beruf { display: none; }

/* --- Spinner --- */
.spinner {
    width: 20px; height: 20px; border: 2px solid var(--border);
    border-top-color: var(--navy); border-radius: 50%;
    animation: spin 0.6s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Loading Overlay --- */
.loading-row td { text-align: center; padding: 40px; color: var(--text-muted); }

/* --- Erinnerung-Status --- */
.erinnerung-sent { color: var(--green); font-size: 0.8rem; }
.erinnerung-none { color: var(--text-muted); font-size: 0.8rem; }

/* --- Collapsible --- */
.collapse-toggle { cursor: pointer; user-select: none; }
.chevron { display: inline-block; transition: transform 0.15s; }
.chevron.open { transform: rotate(180deg); }

/* --- Focus-visible --- */
.btn:focus-visible,
.btn-icon:focus-visible,
.sidebar-item:focus-visible,
.sidebar-log-btn:focus-visible,
.modal-close:focus-visible,
.log-panel-close:focus-visible,
.search-input:focus-visible {
    outline: 2px solid var(--navy);
    outline-offset: 2px;
}
.form-control:focus-visible {
    outline: none;
    border-color: var(--navy);
    box-shadow: 0 0 0 3px rgba(27,54,93,0.12);
}

/* --- Prefers reduced motion --- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
