/* AAC CRM - Design System */
:root {
  --navy: #1a3a5c;
  --navy-dark: #0f2540;
  --navy-light: #2a5280;
  --orange: #e8820a;
  --orange-light: #f5a030;
  --orange-pale: #fff3e0;
  --white: #ffffff;
  --gray-50: #f8f9fa;
  --gray-100: #f1f3f5;
  --gray-200: #e9ecef;
  --gray-300: #dee2e6;
  --gray-400: #ced4da;
  --gray-500: #adb5bd;
  --gray-600: #6c757d;
  --gray-700: #495057;
  --gray-800: #343a40;
  --gray-900: #212529;
  --success: #2e7d32;
  --success-bg: #e8f5e9;
  --warning: #f57c00;
  --warning-bg: #fff3e0;
  --danger: #c62828;
  --danger-bg: #ffebee;
  --info: #0277bd;
  --info-bg: #e1f5fe;

  --radius: 6px;
  --radius-sm: 4px;
  --shadow: 0 1px 4px rgba(0,0,0,0.1);
  --shadow-md: 0 2px 12px rgba(0,0,0,0.12);
  --transition: 150ms ease;

  --sidebar-width: 220px;
  --header-height: 56px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--gray-800);
  background: var(--gray-100);
  line-height: 1.5;
}

/* ---- LOGIN ---- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 60%, var(--navy-light) 100%);
}

.login-card {
  background: var(--white);
  border-radius: 12px;
  padding: 40px;
  width: 380px;
  box-shadow: var(--shadow-md);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo h1 {
  font-size: 26px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.5px;
}

.login-logo span {
  color: var(--orange);
}

.login-logo p {
  color: var(--gray-600);
  font-size: 13px;
  margin-top: 4px;
}

/* ---- LAYOUT ---- */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--navy-dark);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-logo {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--white);
}

.sidebar-logo span {
  color: var(--orange);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 13.5px;
  transition: all var(--transition);
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
  background: rgba(255,255,255,0.06);
  color: var(--white);
}

.sidebar-nav a.active {
  color: var(--white);
  background: rgba(232,130,10,0.15);
  border-left-color: var(--orange);
}

.sidebar-nav .nav-icon {
  font-size: 16px;
  width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,0.75);
  font-size: 13px;
}

.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--orange);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--white);
  flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11px; color: rgba(255,255,255,0.45); }

.logout-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: color var(--transition);
}
.logout-btn:hover { color: var(--white); }

/* ---- MAIN CONTENT ---- */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: var(--header-height);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--navy);
  flex: 1;
}

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

/* ---- CARDS ---- */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--navy);
}

.card-body { padding: 20px; }

/* ---- FORMULAR ---- */
.form-section {
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}

.form-section-header {
  padding: 10px 16px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-300);
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

.form-section-body {
  padding: 16px;
}

.form-section-body.collapsed { display: none; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.form-grid-2 { grid-template-columns: repeat(2, 1fr); }
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }
.col-span-4 { grid-column: span 4; }

.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-600);
}

.form-field label.required::after {
  content: " *";
  color: var(--orange);
}

.form-field input,
.form-field select,
.form-field textarea {
  padding: 8px 10px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--gray-800);
  background: var(--white);
  transition: border-color var(--transition);
  width: 100%;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--orange);
}

.form-field input.error,
.form-field select.error {
  border-color: var(--danger);
}

.form-field .error-msg {
  font-size: 11px;
  color: var(--danger);
}

.form-field textarea { resize: vertical; min-height: 72px; }

.form-field-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
}

.form-field-check input[type=checkbox] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--orange);
}

.form-field-check label {
  font-size: 13px;
  color: var(--gray-700);
  cursor: pointer;
}

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--orange);
  color: var(--white);
}
.btn-primary:hover { background: var(--orange-light); }

.btn-secondary {
  background: var(--navy);
  color: var(--white);
}
.btn-secondary:hover { background: var(--navy-light); }

.btn-outline {
  background: transparent;
  color: var(--navy);
  border: 1px solid var(--gray-300);
}
.btn-outline:hover { background: var(--gray-100); }

.btn-danger {
  background: var(--danger);
  color: var(--white);
}
.btn-danger:hover { background: #b71c1c; }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }

/* ---- TABELLE ---- */
.table-wrap {
  overflow-x: auto;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead th {
  padding: 10px 12px;
  background: var(--navy);
  color: var(--white);
  font-weight: 500;
  font-size: 12px;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.data-table thead th:hover { background: var(--navy-light); }

.data-table thead th.sort-asc::after { content: " ↑"; }
.data-table thead th.sort-desc::after { content: " ↓"; }

.data-table tbody tr {
  border-bottom: 1px solid var(--gray-200);
  transition: background var(--transition);
}

.data-table tbody tr:hover { background: var(--gray-50); cursor: pointer; }

.data-table tbody td {
  padding: 9px 12px;
  color: var(--gray-700);
}

/* ---- STATUS BADGES ---- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.badge-interessent { background: var(--info-bg); color: var(--info); }
.badge-kunde { background: var(--success-bg); color: var(--success); }
.badge-inaktiv { background: var(--gray-200); color: var(--gray-600); }

/* ---- FILTER BAR ---- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
}

.filter-bar input[type=text] {
  padding: 7px 10px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 13px;
  width: 240px;
}

.filter-bar select {
  padding: 7px 10px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--white);
}

/* ---- MODAL ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal {
  background: var(--white);
  border-radius: var(--radius);
  width: 100%;
  max-width: 880px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
}

.modal-lg { max-width: 1100px; }
.modal-sm { max-width: 480px; }

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--gray-500);
  line-height: 1;
  padding: 2px 6px;
}
.modal-close:hover { color: var(--gray-800); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

/* ---- TABS ---- */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 20px;
  gap: 0;
}

.tab-btn {
  padding: 10px 18px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
}

.tab-btn:hover { color: var(--navy); }
.tab-btn.active { color: var(--orange); border-bottom-color: var(--orange); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---- AKTIVITAETEN ---- */
.aktivitaet-list { display: flex; flex-direction: column; gap: 10px; }

.aktivitaet-item {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.aktivitaet-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.aktivitaet-typ {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--navy);
  color: var(--white);
}

.aktivitaet-date { font-size: 11px; color: var(--gray-500); }
.aktivitaet-user { font-size: 11px; color: var(--gray-600); margin-left: auto; }
.aktivitaet-betreff { font-weight: 600; font-size: 13px; margin-bottom: 3px; }
.aktivitaet-inhalt { font-size: 12px; color: var(--gray-600); white-space: pre-wrap; }

/* ---- TOAST ---- */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--white);
  box-shadow: var(--shadow-md);
  animation: slideIn 200ms ease;
  max-width: 360px;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--navy); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ---- UTILS ---- */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-orange { color: var(--orange); }
.text-navy { color: var(--navy); }
.fw-600 { font-weight: 600; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }

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

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--gray-500);
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--orange);
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--gray-500);
  margin-bottom: 6px;
}

.stat-card .stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
}
