/* ==========================================================================
   Nexus Websystems — Adminpage
   Design-System angelehnt an nexuswebsystems.de: dunkles Navy, Blau/Lila-Akzente,
   abgerundete Karten, kräftige Headlines.
   ========================================================================== */

:root {
  --bg: #0a0f1e;
  --bg-soft: #0d1426;
  --bg-elevated: #111a30;
  --card: rgba(255, 255, 255, 0.035);
  --card-border: rgba(255, 255, 255, 0.08);
  --card-border-hover: rgba(96, 165, 250, 0.35);
  --text: #f2f5fb;
  --text-muted: #94a3b8;
  --text-faint: #5b6779;
  --blue: #3b6ff0;
  --blue-light: #5b8def;
  --purple: #8b6cf6;
  --gradient: linear-gradient(120deg, #5b8def 0%, #8b6cf6 100%);
  --success: #22c55e;
  --warning: #f5a524;
  --danger: #f0554b;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --shadow-soft: 0 20px 60px -20px rgba(0, 0, 0, 0.6);
  font-family: "Poppins", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 15% -10%, rgba(91, 141, 239, 0.16), transparent 60%),
              radial-gradient(1000px 500px at 100% 0%, rgba(139, 108, 246, 0.12), transparent 55%),
              var(--bg);
  color: var(--text);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
ul { list-style: none; margin: 0; padding: 0; }
h1, h2, h3, h4, p { margin: 0; }

.background-orbit {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.background-orbit::before,
.background-orbit::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.background-orbit::before { width: 900px; height: 900px; top: -300px; right: -250px; }
.background-orbit::after { width: 1400px; height: 1400px; top: -500px; right: -450px; }

/* ---------------- Login ---------------- */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  z-index: 1;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-elevated);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: var(--shadow-soft);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}
.login-logo img { width: 40px; height: 40px; border-radius: 10px; }
.login-logo .brand {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.02em;
}
.login-logo .brand .accent { color: var(--blue-light); }

.login-card h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
}
.login-card .subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 28px;
}

.field {
  margin-bottom: 18px;
}
.field label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 7px;
  font-weight: 500;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--blue-light);
  background: rgba(255, 255, 255, 0.06);
}
.field textarea { resize: vertical; min-height: 80px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--gradient);
  color: white;
  box-shadow: 0 10px 25px -8px rgba(91, 141, 239, 0.55);
}
.btn-primary:hover { opacity: 0.92; }
.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid var(--card-border);
}
.btn-secondary:hover { border-color: var(--card-border-hover); }
.btn-danger {
  background: rgba(240, 85, 75, 0.12);
  color: #ff8b82;
  border: 1px solid rgba(240, 85, 75, 0.3);
}
.btn-danger:hover { background: rgba(240, 85, 75, 0.2); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-icon { padding: 8px; border-radius: 10px; }

.form-error {
  background: rgba(240, 85, 75, 0.1);
  border: 1px solid rgba(240, 85, 75, 0.3);
  color: #ff8b82;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  display: none;
}
.form-error.visible { display: block; }

/* ---------------- App-Shell ---------------- */

.app-shell {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-soft);
  border-right: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 24px;
}
.sidebar .brand-row img { width: 32px; height: 32px; border-radius: 8px; }
.sidebar .brand-row .brand { font-weight: 700; font-size: 15px; }
.sidebar .brand-row .brand .accent { color: var(--blue-light); }

.nav-group { margin-bottom: 4px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-link:hover { background: rgba(255, 255, 255, 0.04); color: var(--text); }
.nav-link.active {
  background: linear-gradient(120deg, rgba(91, 141, 239, 0.18), rgba(139, 108, 246, 0.12));
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.25);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--card-border);
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
}
.user-chip .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.user-chip .name { font-size: 13px; font-weight: 600; }
.user-chip .role { font-size: 11px; color: var(--text-muted); }
.logout-link {
  display: block;
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 8px;
}
.logout-link:hover { color: #ff8b82; }

.main {
  flex: 1;
  min-width: 0;
  padding: 32px 40px 60px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 16px;
}
.topbar h1 { font-size: 24px; font-weight: 700; }
.topbar .subtitle { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

/* ---------------- Karten & Grids ---------------- */

.grid { display: grid; gap: 20px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: 2fr 1fr; }
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .grid-4, .grid-3 { grid-template-columns: 1fr; }
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 22px;
}
.card-hover:hover { border-color: var(--card-border-hover); cursor: pointer; }

.stat-card .stat-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: rgba(91, 141, 239, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.stat-card .stat-icon svg { width: 19px; height: 19px; color: var(--blue-light); }
.stat-card .stat-value { font-size: 28px; font-weight: 700; }
.stat-card .stat-label { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

.section-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ---------------- Badges ---------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-aktiv, .badge-in_arbeit { background: rgba(34, 197, 94, 0.12); color: #4ade80; }
.badge-interessent, .badge-planung { background: rgba(91, 141, 239, 0.14); color: var(--blue-light); }
.badge-inaktiv, .badge-pausiert { background: rgba(148, 163, 184, 0.14); color: var(--text-muted); }
.badge-abgeschlossen { background: rgba(139, 108, 246, 0.14); color: #b39dfb; }
.badge-review { background: rgba(245, 165, 36, 0.14); color: var(--warning); }

/* ---------------- Tabellen ---------------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  padding: 0 14px 12px;
  font-weight: 600;
}
td { padding: 14px; font-size: 14px; border-top: 1px solid var(--card-border); }
tr.row-clickable { cursor: pointer; transition: background 0.12s ease; }
tr.row-clickable:hover td { background: rgba(255, 255, 255, 0.025); }
.cell-muted { color: var(--text-muted); }
.cell-strong { font-weight: 600; }

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
}
.empty-state .emoji { font-size: 32px; margin-bottom: 12px; }

/* ---------------- Suche / Filter ---------------- */

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.search-input {
  flex: 1;
  min-width: 220px;
  position: relative;
}
.search-input input {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px 10px 38px;
  color: var(--text);
  font-size: 14px;
}
.search-input svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-faint);
}
.select-filter select {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
}

/* ---------------- Modal ---------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 15, 0.65);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 20px;
  z-index: 100;
  overflow-y: auto;
}
.modal-overlay.hidden { display: none; }
.modal {
  width: 100%;
  max-width: 520px;
  background: var(--bg-elevated);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-soft);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-header h2 { font-size: 18px; font-weight: 700; }
.modal-close {
  background: rgba(255, 255, 255, 0.06);
  border: none;
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { color: var(--text); }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 480px) { .field-row { grid-template-columns: 1fr; } }

/* ---------------- Kalender ---------------- */

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.calendar-nav { display: flex; align-items: center; gap: 10px; }
.calendar-nav .month-label { font-size: 17px; font-weight: 700; min-width: 190px; text-align: center; }
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}
.calendar-weekday {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-bottom: 6px;
}
.calendar-day {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  min-height: 96px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.calendar-day.outside { opacity: 0.35; }
.calendar-day.today { border-color: var(--blue-light); box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.3) inset; }
.calendar-day .day-num { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.calendar-day.today .day-num { color: var(--blue-light); }
.calendar-event {
  font-size: 11px;
  padding: 3px 6px;
  border-radius: 6px;
  background: rgba(91, 141, 239, 0.16);
  color: var(--blue-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.calendar-event.type-meilenstein { background: rgba(139, 108, 246, 0.18); color: #b39dfb; }
.calendar-event.type-deadline { background: rgba(240, 85, 75, 0.16); color: #ff8b82; }

.timeline-list { display: flex; flex-direction: column; gap: 10px; }
.timeline-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
}
.timeline-item .date-chip {
  flex-shrink: 0;
  width: 52px;
  text-align: center;
  background: rgba(91, 141, 239, 0.12);
  border-radius: 10px;
  padding: 8px 4px;
}
.timeline-item .date-chip .day { font-size: 17px; font-weight: 700; color: var(--blue-light); line-height: 1; }
.timeline-item .date-chip .month { font-size: 10.5px; color: var(--text-muted); text-transform: uppercase; margin-top: 2px; }
.timeline-item .content { flex: 1; min-width: 0; }
.timeline-item .content .title { font-weight: 600; font-size: 14px; }
.timeline-item .content .meta { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }

/* ---------------- Fortschrittsbalken ---------------- */

.progress-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.progress-bar > div {
  height: 100%;
  background: var(--gradient);
  border-radius: 999px;
}

/* ---------------- Toast ---------------- */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-size: 13.5px;
  box-shadow: var(--shadow-soft);
  z-index: 200;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { border-color: rgba(240, 85, 75, 0.4); color: #ff8b82; }
.toast.success { border-color: rgba(34, 197, 94, 0.35); color: #4ade80; }

/* ---------------- Task-Checkliste ---------------- */

.task-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  border-top: 1px solid var(--card-border);
}
.task-row:first-child { border-top: none; }
.task-checkbox {
  width: 19px;
  height: 19px;
  border-radius: 6px;
  border: 1.5px solid var(--card-border-hover);
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}
.task-checkbox.checked { background: var(--gradient); border-color: transparent; }
.task-checkbox svg { width: 12px; height: 12px; color: white; display: none; }
.task-checkbox.checked svg { display: block; }
.task-title { flex: 1; font-size: 14px; }
.task-title.done { text-decoration: line-through; color: var(--text-faint); }
.task-due { font-size: 12px; color: var(--text-muted); }

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  padding: 5px;
  border-radius: 7px;
  display: flex;
}
.icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.icon-btn svg { width: 15px; height: 15px; }

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 13.5px;
  margin-bottom: 14px;
  cursor: pointer;
}
.back-link:hover { color: var(--text); }
.info-row { display: flex; justify-content: space-between; padding: 9px 0; border-top: 1px solid var(--card-border); font-size: 13.5px; }
.info-row:first-child { border-top: none; }
.info-row .label { color: var(--text-muted); }

/* ---------------- Responsive: Sidebar → Topbar ---------------- */

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    padding: 14px 16px;
    overflow-x: auto;
    gap: 16px;
  }
  .sidebar .brand-row { padding: 0; margin-bottom: 0; flex-shrink: 0; }
  .nav-group { display: flex; gap: 4px; margin-bottom: 0; flex-shrink: 0; }
  .nav-link span { display: none; }
  .nav-link { padding: 10px; }
  .sidebar-footer {
    margin-top: 0;
    margin-left: auto;
    border-top: none;
    padding-top: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
  }
  .user-chip .name, .user-chip .role { display: none; }
  .logout-link { margin-top: 0; white-space: nowrap; }
  .main { padding: 20px 18px 50px; }
  .topbar h1 { font-size: 20px; }
}

.loading-spinner {
  width: 22px; height: 22px;
  border: 2.5px solid rgba(255,255,255,0.15);
  border-top-color: var(--blue-light);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
