/* ── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:       #6366f1;
  --primary-dark:  #4f46e5;
  --primary-light: #e0e7ff;
  --danger:        #ef4444;
  --danger-light:  #fee2e2;
  --success:       #22c55e;
  --success-light: #dcfce7;
  --warning:       #f59e0b;
  --sidebar-bg:    #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active:#1e3a5f;
  --sidebar-text:  #94a3b8;
  --sidebar-title: #f1f5f9;
  --bg:            #f1f5f9;
  --surface:       #ffffff;
  --border:        #e2e8f0;
  --text:          #1e293b;
  --text-muted:    #64748b;
  --shadow:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:     0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:     0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
  --radius:        10px;
  --radius-sm:     6px;
  --sidebar-w:     260px;
  --topbar-h:      64px;
  --transition:    .18s ease;
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
input, textarea, select { font-family: inherit; font-size: inherit; }
button { cursor: pointer; font-family: inherit; }

/* ── LOGIN PAGE ────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
}

.login-container { width: 100%; max-width: 400px; padding: 16px; }

.login-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
}

.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo h1 { font-size: 24px; font-weight: 700; color: var(--text); margin: 12px 0 6px; }
.login-logo p { color: var(--text-muted); font-size: 14px; }

.logo-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  border-radius: 16px;
  color: #fff; font-size: 24px; font-weight: 800;
  box-shadow: 0 4px 12px rgba(99,102,241,.4);
}

/* ── FORMS ─────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--text); margin-bottom: 6px;
}
.form-group label small { font-weight: 400; color: var(--text-muted); }

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

.input-with-toggle { position: relative; }
.input-with-toggle input { padding-right: 44px; }
.toggle-password {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-muted); padding: 4px;
  display: flex; align-items: center;
}
.toggle-password svg { width: 18px; height: 18px; }
.toggle-password:hover { color: var(--text); }

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

/* ── BUTTONS ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border: none; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; transition: all var(--transition);
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(99,102,241,.35); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-ghost   { background: transparent; color: var(--text); border: 1.5px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--bg); border-color: #cbd5e1; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-full { width: 100%; }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0;
  background: none; border: none; border-radius: var(--radius-sm);
  color: var(--text-muted); transition: all var(--transition);
}
.btn-icon:hover { background: var(--bg); color: var(--text); }
.btn-icon svg { width: 18px; height: 18px; }

/* ── MESSAGES ──────────────────────────────────────────── */
.error-message {
  background: var(--danger-light); color: #991b1b;
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 13px; margin-bottom: 16px;
  border-left: 3px solid var(--danger);
}
.success-message {
  background: var(--success-light); color: #166534;
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 13px; margin-bottom: 16px;
  border-left: 3px solid var(--success);
}
.form-message { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 14px; }
.form-message.error { background: var(--danger-light); color: #991b1b; border-left: 3px solid var(--danger); }
.form-message.success { background: var(--success-light); color: #166534; border-left: 3px solid var(--success); }

/* ── SPINNER ───────────────────────────────────────────── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── APP LAYOUT ────────────────────────────────────────── */
.app-page { display: flex; min-height: 100vh; }

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; z-index: 100;
  transition: width var(--transition);
  overflow: hidden;
}

.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  min-height: 72px;
}
.sidebar-logo { display: flex; align-items: center; gap: 12px; }
.sidebar-logo .logo-icon { width: 36px; height: 36px; font-size: 16px; border-radius: 10px; flex-shrink: 0; }
.sidebar-logo .logo-img  { width: 36px; height: 36px; border-radius: 10px; object-fit: contain; flex-shrink: 0; }
.sidebar-title { color: var(--sidebar-title); font-weight: 700; font-size: 16px; white-space: nowrap; transition: opacity var(--transition); }

.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; overflow-x: hidden; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }

.nav-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: #475569; padding: 8px 12px 4px;
  white-space: nowrap; overflow: hidden;
  transition: opacity var(--transition);
}
.sidebar.collapsed .nav-section-label { opacity: 0; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 8px; margin-bottom: 2px;
  color: var(--sidebar-text); font-weight: 500;
  cursor: pointer; transition: all var(--transition);
  border: none; background: none; width: 100%; text-align: left;
  white-space: nowrap; overflow: hidden;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-title); }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item.active .nav-icon { filter: none; }

.nav-icon {
  font-size: 18px; flex-shrink: 0;
  width: 24px; text-align: center; line-height: 1;
}
.nav-label { font-size: 13.5px; transition: opacity var(--transition); }

.sidebar-footer {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 12px;
  border-top: 1px solid rgba(255,255,255,.06);
}
.user-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: #fff; font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.user-details { min-width: 0; transition: opacity var(--transition); }
.user-name  { display: block; color: var(--sidebar-title); font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role  { display: block; color: var(--sidebar-text); font-size: 11px; }
.sidebar-footer .btn-icon { color: var(--sidebar-text); flex-shrink: 0; }
.sidebar-footer .btn-icon:hover { color: var(--danger); background: rgba(239,68,68,.15); }

/* MAIN CONTENT */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex; flex-direction: column;
  transition: margin-left var(--transition);
}

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.page-title { font-size: 18px; font-weight: 700; }
.mobile-menu-btn { display: none; }

.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: #fff; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: transform var(--transition), box-shadow var(--transition);
}
.profile-btn { width: auto; height: auto; padding: 0; }
.profile-btn:hover .topbar-avatar { transform: scale(1.05); box-shadow: 0 0 0 3px rgba(99,102,241,.3); }

.content-area { flex: 1; padding: 28px 28px; }

/* ── WELCOME ───────────────────────────────────────────── */
.welcome-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 400px; text-align: center; color: var(--text-muted);
}
.welcome-icon { font-size: 48px; margin-bottom: 16px; }
.welcome-screen h2 { font-size: 22px; color: var(--text); margin-bottom: 8px; }

/* ── CARDS ─────────────────────────────────────────────── */
.card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--border);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px 16px; border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 16px; font-weight: 700; }
.card-body { padding: 20px 22px; }

/* ── MODULE: User Management ───────────────────────────── */
.module-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.module-title h2 { font-size: 22px; font-weight: 700; }
.module-title p { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* ── TABLE ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-muted);
  padding: 10px 16px; background: var(--bg);
  border-bottom: 1px solid var(--border);
}
tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
tbody td { padding: 13px 16px; font-size: 13.5px; vertical-align: middle; }

.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em; white-space: nowrap;
}
.badge-admin   { background: var(--primary-light); color: var(--primary-dark); }
.badge-user    { background: #f1f5f9; color: #475569; }
.badge-module  { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; margin: 2px; }

.table-actions { display: flex; gap: 6px; }
.modules-cell { display: flex; flex-wrap: wrap; gap: 2px; max-width: 280px; }

/* ── MODAL ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; backdrop-filter: blur(2px);
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border-radius: 14px;
  width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-lg { max-width: 680px; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 17px; font-weight: 700; }
.modal-close {
  background: none; border: none; font-size: 18px; color: var(--text-muted);
  padding: 4px 8px; border-radius: 4px; line-height: 1;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body { padding: 22px 24px; }
.modal-body hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

/* Profil-Modal */
.profile-info { display: flex; align-items: center; gap: 16px; margin-bottom: 6px; }
.profile-avatar {
  width: 52px; height: 52px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: #fff; font-weight: 700; font-size: 20px;
  display: flex; align-items: center; justify-content: center;
}
.profile-username { font-size: 17px; font-weight: 700; }
.profile-role { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ── MODULE PERMISSIONS ────────────────────────────────── */
.module-permission-list { display: flex; flex-direction: column; gap: 10px; }
.module-permission-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border: 1.5px solid var(--border); border-radius: 8px;
  transition: border-color var(--transition), background var(--transition);
}
.module-permission-item:hover { background: var(--bg); border-color: #cbd5e1; }
.module-perm-info { display: flex; align-items: center; gap: 12px; }
.module-perm-icon { font-size: 22px; }
.module-perm-name { font-weight: 600; font-size: 13.5px; }
.module-perm-desc { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

/* Toggle Switch */
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0;
  background: #cbd5e1; border-radius: 999px; cursor: pointer;
  transition: background var(--transition);
}
.toggle-track::after {
  content: ''; position: absolute;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  top: 3px; left: 3px;
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle-switch input:checked + .toggle-track { background: var(--primary); }
.toggle-switch input:checked + .toggle-track::after { transform: translateX(20px); }

/* ── RESPONSIVE ────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition);
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }
  .mobile-menu-btn { display: flex; }
  .content-area { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
}

/* ── TABS ──────────────────────────────────────────────── */
.tab-bar {
  display: flex; gap: 4px; margin-bottom: 20px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 4px; width: fit-content;
  box-shadow: var(--shadow);
}
.tab-btn {
  padding: 8px 18px; border: none; border-radius: 7px;
  background: none; font-size: 13.5px; font-weight: 600;
  color: var(--text-muted); cursor: pointer;
  transition: all var(--transition);
}
.tab-btn:hover  { background: var(--bg); color: var(--text); }
.tab-btn.active { background: var(--primary); color: #fff; }

/* ── SIDEBAR: Kategorie-Labels ─────────────────────────── */
.nav-section-label {
  display: flex; align-items: center; gap: 6px;
}
.nav-cat-icon { font-size: 13px; }

/* ── STYLE-EDIT: Farben ─────────────────────────────────── */
.color-picker-grid { display: flex; flex-direction: column; gap: 20px; }
.color-picker-item label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 8px; }
.color-preview-row { display: flex; align-items: center; gap: 10px; }
.color-preview-row input[type=color] {
  width: 44px; height: 42px; padding: 2px; border: 1.5px solid var(--border);
  border-radius: 8px; cursor: pointer; background: none;
}
.color-text-input {
  width: 100px; padding: 8px 10px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-family: monospace; font-size: 13px;
  color: var(--text); background: var(--surface);
}
.color-text-input:focus { border-color: var(--primary); outline: none; }
.color-swatch { width: 36px; height: 36px; border-radius: 8px; border: 2px solid rgba(0,0,0,.1); flex-shrink: 0; }
.color-desc { font-size: 12px; color: var(--text-muted); margin-top: 5px; }

/* ── STYLE-EDIT: Kategorien ─────────────────────────────── */
.cat-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.cat-row:last-child { border-bottom: none; }
.cat-row:hover { background: var(--bg); }
.cat-row-drag { color: var(--text-muted); cursor: grab; font-size: 16px; padding: 0 4px; user-select: none; }
.cat-row-icon {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.cat-row-info { flex: 1; min-width: 0; }
.cat-row-info strong { display: block; font-size: 14px; }
.cat-row-info span   { font-size: 11px; }
.cat-row-order { display: flex; flex-direction: column; gap: 2px; }
.cat-row-order .btn-icon { width: 24px; height: 20px; font-size: 11px; }
.cat-row-order .btn-icon:disabled { opacity: .3; cursor: not-allowed; }

/* ── PERMISSIONS BAUM ───────────────────────────────────── */
.perm-cat-block {
  border: 1.5px solid var(--border); border-radius: var(--radius);
  margin-bottom: 10px; overflow: hidden;
}
.perm-cat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.perm-cat-info { display: flex; align-items: center; gap: 12px; }
.perm-cat-icon {
  width: 36px; height: 36px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.perm-cat-name  { font-weight: 700; font-size: 14px; }
.perm-cat-count { font-size: 11px; margin-top: 1px; }

.perm-mod-list { display: flex; flex-direction: column; }
.perm-mod-disabled { opacity: .45; pointer-events: none; }
.perm-mod-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px 10px 48px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.perm-mod-item:last-child { border-bottom: none; }
.perm-mod-item:hover { background: #fafbfc; }
.perm-mod-info { display: flex; align-items: center; }

/* ── UTILITY ───────────────────────────────────────────── */
.text-muted  { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.flex        { display: flex; }
.gap-8       { gap: 8px; }
.mt-16       { margin-top: 16px; }
.empty-state {
  text-align: center; padding: 48px 24px; color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 36px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }
