/* ═══════════════════════════════════════════════════════════
   K-Workx Design System
   ═══════════════════════════════════════════════════════════ */

:root {
  --primary: #1D4ED8;
  --primary-dark: #1E3A8A;
  --primary-light: #3B82F6;
  --accent: #0EA5E9;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --purple: #8B5CF6;

  --sidebar-bg: #0F172A;
  --sidebar-hover: #1E293B;
  --sidebar-active: #1D4ED8;
  --sidebar-text: #94A3B8;
  --sidebar-text-active: #FFFFFF;
  --sidebar-width: 240px;

  --bg: #F8FAFC;
  --bg-card: #FFFFFF;
  --border: #E2E8F0;
  --border-light: #F1F5F9;

  --text: #0F172A;
  --text-muted: #64748B;
  --text-light: #94A3B8;

  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);

  --topbar-height: 56px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ───────────────────────────────────────────────── */

#app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-logo {
  padding: 20px 16px;
  border-bottom: 1px solid #1E293B;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo-icon {
  width: 34px; height: 34px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.sidebar-logo-text { color: #fff; font-weight: 700; font-size: 15px; }
.sidebar-logo-sub { color: var(--sidebar-text); font-size: 11px; }

.sidebar-section {
  padding: 8px 0;
  border-bottom: 1px solid #1E293B;
}
.sidebar-section-label {
  color: #475569;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 8px 16px 4px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px;
  color: var(--sidebar-text);
  cursor: pointer;
  border-radius: 6px;
  margin: 1px 8px;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
  border: none; background: none; width: calc(100% - 16px); text-align: left;
}
.nav-item:hover { background: var(--sidebar-hover); color: #E2E8F0; }
.nav-item.active { background: var(--sidebar-active); color: #fff; }
.nav-item .icon { font-size: 16px; width: 20px; text-align: center; }

/* ── Sidebar Untermenü ── */
.nav-group-toggle { display: flex; align-items: center; }
.nav-chevron {
  font-size: 14px;
  color: #475569;
  transition: transform 0.2s ease;
  display: inline-block;
  margin-left: 4px;
}
.nav-chevron.open { transform: rotate(90deg); }

.nav-sub {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.22s ease;
}
.nav-sub.open { max-height: 200px; }

.nav-sub-item {
  padding: 7px 16px 7px 42px;
  font-size: 12.5px;
  color: #64748B;
  margin: 0px 8px;
}
.nav-sub-item:hover { background: var(--sidebar-hover); color: #CBD5E1; }
.nav-sub-item.active {
  background: #1E3A5F;
  color: #93C5FD;
  font-weight: 600;
}
.nav-sub-item .icon { font-size: 13px; width: 16px; }
.nav-item .badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: var(--topbar-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
}
.topbar-title { font-size: 16px; font-weight: 700; color: var(--text); flex: 1; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ── Cards ────────────────────────────────────────────────── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title { font-size: 14px; font-weight: 700; color: var(--text); }
.card-body { padding: 20px; }

/* ── Stats Cards ─────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex; align-items: center; gap: 16px;
  box-shadow: var(--shadow);
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.stat-icon.blue { background: #EFF6FF; }
.stat-icon.green { background: #F0FDF4; }
.stat-icon.yellow { background: #FFFBEB; }
.stat-icon.purple { background: #F5F3FF; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--text); line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Buttons ──────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  border: none; outline: none;
  transition: all 0.15s;
  font-family: var(--font);
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--border-light); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--border-light); color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 7px; }

/* ── Tables ───────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--bg);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
thead th:hover { color: var(--text); }
tbody tr { border-bottom: 1px solid var(--border-light); transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #F8FAFC; }
tbody td { padding: 11px 16px; font-size: 13.5px; vertical-align: middle; }

/* ── Forms ────────────────────────────────────────────────── */

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
input, select, textarea {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
textarea { resize: vertical; min-height: 80px; }
select { cursor: pointer; }

/* ── Search + Filter Bar ─────────────────────────────────── */

.filter-bar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-box {
  position: relative; flex: 1; min-width: 200px; max-width: 320px;
}
.search-box input {
  width: 100%; padding-left: 34px;
}
.search-box::before {
  content: '🔍';
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  font-size: 12px; pointer-events: none;
}

/* ── Alpha Filter ─────────────────────────────────────────── */

.alpha-filter {
  display: flex; flex-wrap: wrap; gap: 2px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
}
.alpha-btn {
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 5px;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  border: 1px solid transparent;
  transition: all 0.1s;
  background: none;
  font-family: var(--font);
}
.alpha-btn:hover { background: var(--border-light); color: var(--text); }
.alpha-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Badges / Chips ───────────────────────────────────────── */

.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-aktiv { background: #D1FAE5; color: #065F46; }
.badge-inaktiv { background: #FEF3C7; color: #92400E; }
.badge-exit { background: #F3F4F6; color: #6B7280; }
.badge-bewerber { background: #E0E7FF; color: #3730A3; }
.badge-ausgeschieden { background: #F3F4F6; color: #6B7280; }
.badge-offen { background: #D1FAE5; color: #065F46; }
.badge-forecast { background: #FEF3C7; color: #92400E; }
.badge-bestellung { background: #FFF7ED; color: #C2410C; border: 1px solid #FED7AA; }
.badge-bestätigt { background: #D1FAE5; color: #065F46; }
.badge-geplant { background: #E0E7FF; color: #3730A3; }
.badge-abgeschlossen { background: #F3F4F6; color: #6B7280; }
.badge-storniert { background: #FEE2E2; color: #991B1B; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  background: #EFF6FF;
  color: var(--primary);
  font-weight: 500;
}

/* ── Modal ────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 24px;
  animation: fadeIn 0.15s ease;
}
.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 680px;
  max-height: calc(100vh - 48px);
  display: flex; flex-direction: column;
  animation: slideUp 0.2s ease;
}
.modal-lg { max-width: 900px; }
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
  flex-shrink: 0;
}

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

/* ── Loading ──────────────────────────────────────────────── */

.loading {
  display: flex; align-items: center; justify-content: center;
  padding: 60px;
  color: var(--text-muted);
  flex-direction: column; gap: 12px;
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center; padding: 60px 24px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; color: var(--text); margin-bottom: 8px; }

/* ── Toast ────────────────────────────────────────────────── */

#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: #1E293B;
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px;
  animation: slideRight 0.25s ease;
  min-width: 260px; max-width: 380px;
}
.toast.success { background: #065F46; }
.toast.error { background: #991B1B; }
.toast.warning { background: #92400E; }
@keyframes slideRight { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Pagination ───────────────────────────────────────────── */

.pagination {
  display: flex; align-items: center; gap: 6px;
  padding: 14px 16px;
  border-top: 1px solid var(--border-light);
  justify-content: space-between;
}
.pagination-info { font-size: 12px; color: var(--text-muted); }
.pagination-btns { display: flex; gap: 4px; }
.page-btn {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: none; color: var(--text-muted);
  transition: all 0.1s;
  font-family: var(--font);
}
.page-btn:hover { background: var(--border-light); color: var(--text); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Dashboard ────────────────────────────────────────────── */

.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.dashboard-grid-wide { grid-column: 1 / -1; }

/* ── Besetzung Bars ───────────────────────────────────────── */

.besetzung {
  display: flex; align-items: center; gap: 8px;
}
.besetzung-bar {
  flex: 1; height: 6px; background: var(--border);
  border-radius: 3px; overflow: hidden;
}
.besetzung-fill {
  height: 100%; border-radius: 3px;
  transition: width 0.3s;
}
.besetzung-text { font-size: 12px; font-weight: 600; white-space: nowrap; }

/* ── Utility ──────────────────────────────────────────────── */

.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.font-bold { font-weight: 700; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 10px; }

/* ── Avatar ───────────────────────────────────────────────── */
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}

/* ── Color dots ───────────────────────────────────────────── */
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ── Divider ──────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .content { padding: 16px; }
}

/* ── Tab-System (Firma, Kunden etc.) ──────────────────────── */
.tab-bar {
  display: flex; gap: 4px;
  border-bottom: 2px solid var(--border);
  padding: 0 0 0 0;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.tab-btn {
  background: none; border: none; cursor: pointer;
  padding: 8px 16px; font-size: 13px; font-weight: 500;
  color: var(--text-light); border-bottom: 2px solid transparent;
  margin-bottom: -2px; transition: all .15s; border-radius: 4px 4px 0 0;
}
.tab-btn:hover { color: var(--text); background: var(--bg-card); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); background: var(--bg-card); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Form Grid 2 mit span ─────────────────────────────────── */
.form-grid-2 {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.form-grid-2 .span-2 { grid-column: 1 / -1; }

@media (max-width: 600px) {
  .form-grid-2 { grid-template-columns: 1fr; }
  .form-grid-2 .span-2 { grid-column: 1; }
}
