/* =============================================
   SBS Sicherheit – Internes Portal
   ============================================= */

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

:root,
[data-theme="dark"] {
    --bg: #1a1c20;
    --bg-card: #24272c;
    --bg-card-hover: #2c2f35;
    --bg-sidebar: #1e2024;
    --bg-input: #2a2d32;
    --border: rgba(255,255,255,0.08);
    --border-hover: rgba(255,255,255,0.15);
    --text: #e8eaed;
    --text-secondary: #9aa0a8;
    --text-muted: #6b7280;
    --red: #e30613;
    --red-light: rgba(227,6,19,0.15);
    --red-hover: #c70511;
    --silver: #c0c5cb;
    --green: #22c55e;
    --green-bg: rgba(34,197,94,0.12);
    --yellow: #eab308;
    --yellow-bg: rgba(234,179,8,0.12);
    --blue: #3b82f6;
    --blue-bg: rgba(59,130,246,0.12);
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.2);
    --radius: 12px;
    --radius-sm: 8px;
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --sidebar-w: 260px;
    --topbar-h: 60px;
}

[data-theme="light"] {
    --bg: #f3f4f6;
    --bg-card: #ffffff;
    --bg-card-hover: #f9fafb;
    --bg-sidebar: #ffffff;
    --bg-input: #f3f4f6;
    --border: rgba(0,0,0,0.08);
    --border-hover: rgba(0,0,0,0.15);
    --text: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --shadow: 0 4px 24px rgba(0,0,0,0.08);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.05);
}

html { font-size: 15px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; display: flex; }

/* === LOGIN === */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; width: 100%; background: var(--bg); }
.login-box { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 48px 40px; width: 100%; max-width: 420px; box-shadow: var(--shadow); text-align: center; }
.login-box img { height: 48px; margin-bottom: 8px; }
.login-box .login-badge { display: inline-block; background: var(--red-light); color: var(--red); font-size: 0.75rem; font-weight: 600; padding: 3px 10px; border-radius: 4px; margin-bottom: 24px; }
.login-box h1 { font-size: 1.3rem; margin-bottom: 24px; }
.login-error { background: rgba(227,6,19,0.1); border: 1px solid rgba(227,6,19,0.3); color: var(--red); padding: 10px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 0.9rem; }

/* === SIDEBAR === */
.sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w); background: var(--bg-sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; z-index: 100; transition: transform 0.3s ease; }
.sidebar-logo { padding: 20px 24px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); }
.sidebar-badge { background: var(--red); color: #fff; font-size: 0.65rem; font-weight: 700; padding: 2px 8px; border-radius: 4px; letter-spacing: 0.5px; }
.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.sidebar-nav a { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-radius: var(--radius-sm); color: var(--text-secondary); text-decoration: none; font-size: 0.9rem; transition: all 0.2s; }
.sidebar-nav a:hover { background: var(--bg-card-hover); color: var(--text); }
.sidebar-nav a.active { background: var(--red-light); color: var(--red); font-weight: 600; }
.nav-icon { font-size: 1.1rem; width: 24px; text-align: center; }
.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); }
.sidebar-user { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.user-avatar { width: 36px; height: 36px; background: var(--red-light); color: var(--red); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.8rem; font-weight: 700; flex-shrink: 0; }
.user-name { font-size: 0.85rem; font-weight: 600; }
.user-role { font-size: 0.75rem; color: var(--text-muted); }
.sidebar-actions { display: flex; gap: 8px; }
.theme-toggle-intern, .logout-btn { background: var(--bg-input); border: 1px solid var(--border); color: var(--text-secondary); width: 36px; height: 36px; border-radius: var(--radius-sm); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 1rem; text-decoration: none; transition: all 0.2s; }
.theme-toggle-intern:hover, .logout-btn:hover { border-color: var(--red); color: var(--red); }

/* === MAIN CONTENT === */
.main-content { margin-left: var(--sidebar-w); flex: 1; min-height: 100vh; display: flex; flex-direction: column; }
.topbar { height: var(--topbar-h); display: flex; align-items: center; gap: 16px; padding: 0 32px; border-bottom: 1px solid var(--border); background: var(--bg-card); position: sticky; top: 0; z-index: 50; }
.sidebar-toggle { display: none; background: none; border: none; color: var(--text); font-size: 1.3rem; cursor: pointer; }
.page-title { font-size: 1.15rem; font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.topbar-date { font-size: 0.85rem; color: var(--text-muted); }
.content { padding: 32px; flex: 1; }

/* === CARDS & GRID === */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 32px; }
.stat-box { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; transition: all 0.2s; }
.stat-box:hover { border-color: var(--border-hover); }
.stat-box .stat-value { font-size: 2rem; font-weight: 700; }
.stat-box .stat-label { font-size: 0.85rem; color: var(--text-secondary); margin-top: 4px; }
.stat-box.red .stat-value { color: var(--red); }
.stat-box.green .stat-value { color: var(--green); }
.stat-box.blue .stat-value { color: var(--blue); }
.stat-box.yellow .stat-value { color: var(--yellow); }

.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 24px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.card-header h2 { font-size: 1.1rem; font-weight: 600; }

/* === TABLES === */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
thead th { text-align: left; padding: 12px 16px; border-bottom: 2px solid var(--border); color: var(--text-secondary); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; }
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); }
tbody tr:hover { background: var(--bg-card-hover); }
tbody tr:last-child td { border-bottom: none; }

/* === BADGES === */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge-red { background: var(--red-light); color: var(--red); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-gray { background: rgba(107,114,128,0.12); color: var(--text-muted); }

/* === BUTTONS === */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; border-radius: var(--radius-sm); font-size: 0.9rem; font-weight: 500; cursor: pointer; border: none; text-decoration: none; transition: all 0.2s; font-family: var(--font); }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-hover); }
.btn-secondary { background: var(--bg-input); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--border-hover); }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-icon { width: 34px; height: 34px; padding: 0; justify-content: center; background: var(--bg-input); border: 1px solid var(--border); color: var(--text-secondary); border-radius: var(--radius-sm); cursor: pointer; }
.btn-icon:hover { border-color: var(--red); color: var(--red); }

/* === FORMS === */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 10px 14px; background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text); font-size: 0.9rem; font-family: var(--font);
    transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--red);
}
.form-group textarea { min-height: 100px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-actions { display: flex; gap: 12px; margin-top: 24px; }

/* === MODAL === */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 1000; display: none; align-items: center; justify-content: center; }
.modal-overlay.active { display: flex; }
.modal { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; width: 100%; max-width: 600px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.modal-header h2 { font-size: 1.15rem; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.5rem; cursor: pointer; }
.modal-close:hover { color: var(--red); }

/* === EMPTY STATE === */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state p { font-size: 0.95rem; }

/* === RESPONSIVE === */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar-toggle { display: block; }
    .main-content { margin-left: 0; }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .content { padding: 20px; }
}
@media (max-width: 768px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .topbar { padding: 0 16px; }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
}
