@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg-color: #f3f4f6;
  --bg-card: #ffffff;
  --bg-header: #ffffff;
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --border-color: #e5e7eb;
  
  --primary: #01696f; 
  --primary-hover: #015055;
  --primary-light: #e0f2f3;

  --status-idea: #9ca3af;
  --status-planned: #3b82f6;
  --status-progress: #f59e0b;
  --status-waiting: #8b5cf6;
  --status-done: #10b981;
  --status-paused: #6b7280;
  --status-rejected: #ef4444;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --radius: 8px;
}

[data-theme="dark"] {
  --bg-color: #111827;
  --bg-card: #1f2937;
  --bg-header: #1f2937;
  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  --border-color: #374151;
  --primary-light: #013e42;
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.5;
  transition: background-color 0.3s, color 0.3s;
}

/* --- Layout --- */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* --- Main Header --- */
.main-header {
  background-color: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  padding: 0 2rem;
  height: 70px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: var(--shadow-sm);
}

.header-left { display: flex; align-items: center; gap: 2rem; }

.main-nav { display: flex; gap: 0.5rem; }

.main-nav .tab-btn {
  padding: 0.5rem 1.25rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius);
  transition: all 0.2s;
}

.main-nav .tab-btn:hover { background-color: var(--bg-color); color: var(--primary); }
.main-nav .tab-btn.active { background-color: var(--primary-light); color: var(--primary); }

.header-right { display: flex; align-items: center; gap: 1.5rem; }

.user-info { display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; }
.avatar { 
  width: 32px; height: 32px; background: var(--primary); color: white; 
  display: flex; align-items: center; justify-content: center; border-radius: 50%; font-weight: 600;
}

.header-actions { display: flex; align-items: center; gap: 0.75rem; }

/* --- Content Area --- */
.content-area { padding: 2rem; max-width: 1600px; margin: 0 auto; width: 100%; }

/* --- KPIs Horizontal --- */
.stats-grid { 
  display: grid; 
  grid-template-columns: repeat(4, 1fr); 
  gap: 1.5rem; 
  margin-bottom: 2rem; 
}

.stat-card {
  background-color: var(--bg-card);
  padding: 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  border-top: 4px solid var(--primary);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: var(--shadow-sm);
}

.stat-card.faellig { border-top-color: var(--status-progress); }
.stat-card.kontakte { border-top-color: var(--status-done); }
.stat-card.fortschritt { border-top-color: var(--status-waiting); }

.stat-label { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.025em; }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--text-main); }

/* --- Charts Row --- */
.charts-grid { display: flex; gap: 1.5rem; margin-bottom: 2rem; }
.chart-card { flex: 1; background-color: var(--bg-card); padding: 1.5rem; border-radius: var(--radius); border: 1px solid var(--border-color); box-shadow: var(--shadow-sm); }
.chart-card h3 { font-size: 1rem; margin-bottom: 1rem; color: var(--text-main); }
.chart-container { position: relative; height: 300px; width: 100%; }

/* --- Tables Full Width --- */
.table-card { background-color: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border-color); overflow: hidden; margin-bottom: 2rem; box-shadow: var(--shadow-sm); }
.table-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.table-header h3 { font-size: 1.1rem; }

table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 0.75rem 1.5rem; background-color: #f9fafb; font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; border-bottom: 1px solid var(--border-color); }
[data-theme="dark"] th { background-color: rgba(255,255,255,0.02); }
td { padding: 1rem 1.5rem; border-bottom: 1px solid var(--border-color); font-size: 0.9rem; }
tbody tr:hover { background-color: rgba(0,0,0,0.01); }

/* --- Buttons & UI --- */
.btn { 
  display: inline-flex; align-items: center; justify-content: center; 
  padding: 10px 20px; border-radius: 6px; font-size: 0.875rem; 
  font-weight: 500; cursor: pointer; border: none; transition: all 0.2s; 
  outline: none;
}

.btn-primary { 
  background-color: #10b981; /* Sattes Grün */
  color: white; 
}
.btn-primary:hover { background-color: #059669; transform: translateY(-1px); }

.btn-danger { 
  background-color: #374151; /* Dezent Grau */
  color: #f9fafb; 
}
.btn-danger:hover { background-color: #ef4444; color: white; }

.btn-outline { 
  background: transparent; border: 1px solid #3f3f46; color: var(--text-muted); 
}
.btn-outline:hover { background: #374151; color: white; border-color: #374151; }

/* Aufgabe Modal: Bereich (nicht mit Kontakt-Kategorie verwechseln) */
.task-bereich-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.4rem;
  margin-bottom: 1.35rem;
}

.task-bereich-btn-edit {
  font-size: 0.75rem !important;
  padding: 0.35rem 0.65rem !important;
  border: 2px solid #38bdf8 !important;
  color: var(--text-main) !important;
}
.task-bereich-btn-edit:hover {
  background: rgba(56, 189, 248, 0.14) !important;
  border-color: #38bdf8 !important;
  color: var(--text-main) !important;
}

.task-bereich-btn-del {
  font-size: 0.75rem !important;
  padding: 0.35rem 0.65rem !important;
  border: 2px solid #ef4444 !important;
  color: var(--text-main) !important;
}
.task-bereich-btn-del:hover {
  background: rgba(239, 68, 68, 0.12) !important;
  border-color: #ef4444 !important;
  color: var(--text-main) !important;
}

.btn-dashed {
  background: transparent;
  border: 1px dashed #4b5563;
  color: #9ca3af;
  font-size: 0.75rem;
  padding: 5px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-dashed:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(16, 185, 129, 0.05);
}

.tab-content { display: none; animation: fadeIn 0.3s ease; }
.tab-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* --- Modals & More --- */
.modal-overlay, .modal-backdrop { 
  position: fixed; inset: 0; 
  background-color: rgba(0,0,0,0.6) !important;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 1040 !important; display: none; 
  justify-content: center; align-items: center;
  padding: 1rem; 
}
.modal-overlay.active { display: flex; }

.modal { 
  background: #111827; /* Anthrazit-Blau */
  width: 90%; max-width: 950px; min-width: 850px;
  max-height: 90vh;
  display: flex; flex-direction: column; 
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5); 
  z-index: 1050 !important; border: none;
  border-radius: 14px;
  overflow: hidden;
  animation: modalPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (max-width: 900px) {
  .modal { min-width: auto; width: 95%; }
}

@keyframes modalPop {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

[data-theme="dark"] .modal {
  background: #0f172a;
}
.modal-header { 
  padding: 1.25rem 1.5rem; 
  background-color: #0d9488; /* Teal Branding */
  border-bottom: 1px solid rgba(255,255,255,0.1); 
  display: flex; justify-content: space-between; align-items: center; 
}
.modal-context-switch {
  display: flex;
  gap: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.35);
}
.modal-context-btn {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  border: none;
  padding: 0.45rem 1rem;
  cursor: pointer;
  font-size: 0.95rem;
  min-width: 120px;
}
.modal-context-btn.active {
  background: rgba(255, 255, 255, 0.35);
  font-weight: 700;
}
.modal-header h2, .modal-header h3 {
  color: white;
  font-weight: 700;
  font-size: 1.25rem;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.75rem;
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  line-height: 1;
  transition: all 0.2s;
}
.modal-close:hover { color: white; transform: rotate(90deg); }
.modal-body { 
  padding: 1.5rem; 
  overflow-y: auto; 
  flex-grow: 1; 
  height: 600px; /* Feste Höhe für absolute Stabilität */
}
.modal-footer { 
  padding: 1.25rem 1.5rem; border-top: 1px solid var(--border-color); 
  display: flex; justify-content: space-between; background: var(--bg-card);
  position: sticky; bottom: 0; z-index: 10;
}

/* Form Styling in Modals */
.modal-body label, .modal-body h4 {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #71717a;
  font-size: 0.75rem;
}

.modal-body input, 
.modal-body select, 
.modal-body textarea {
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 18px;
  background-color: rgba(255,255,255,0.05);
  border: 1px solid #4b5563; /* Feiner sichtbarer Rand */
  border-radius: 10px;
  color: white;
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: all 0.2s ease;
}

.modal-body input:focus, 
.modal-body select:focus, 
.modal-body textarea:focus {
  border-color: rgba(16, 185, 129, 0.5); /* Feine Linie bei Fokus */
  background: #09090b;
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.2);
  outline: none;
}

.modal-body select option {
  background-color: #2a2e35;
  color: white;
}

/* List Items (Attachments & Contacts) */
.attachment-item, .list-item-flex {
  background: #1f2937 !important; /* Anthrazit abgesetzt */
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  border-radius: 12px !important;
  padding: 12px 16px !important;
  margin-bottom: 10px !important;
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  list-style: none !important;
  transition: transform 0.2s, background 0.2s;
}
.attachment-item:hover, .list-item-flex:hover {
  background: #2d3748 !important;
  transform: translateY(-2px);
}
.attachment-item:hover, .list-item-flex:hover {
  background: rgba(255, 255, 255, 0.05) !important;
}

.attachment-item .btn-icon, .list-item-flex .btn-icon {
  opacity: 0; /* Standardmäßig unsichtbar */
  transition: opacity 0.2s;
}
.attachment-item:hover .btn-icon, .list-item-flex:hover .btn-icon {
  opacity: 1; /* Sichtbar bei Hover */
}

/* File Badges */
.file-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  margin-left: 8px;
}
.badge-pdf { background: rgba(239, 68, 68, 0.2); color: #f87171; }
.badge-img { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
.badge-doc { background: rgba(139, 92, 246, 0.2); color: #a78bfa; }
.badge-other { background: rgba(113, 113, 122, 0.2); color: #a1a1aa; }

.attachment-item a, .list-item-flex div {
  color: #f3f4f6 !important;
  text-decoration: none !important;
  font-size: 0.85rem !important;
  display: flex !important;
  align-items: center !important;
}

.attachment-item a::before {
  content: '📎';
  margin-right: 10px;
  font-size: 1.1rem;
  color: #3b82f6; /* Blaues Icon */
}

.list-item-flex::before {
  content: '👤';
  margin-right: 10px;
  font-size: 1rem;
  opacity: 0.7;
}

.btn-icon {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px;
  transition: color 0.2s;
}
.btn-icon:hover {
  color: #ef4444;
}

/* Form Grid */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1rem;
}
.form-group.full-width {
  grid-column: span 2;
}

/* Date Picker Styling */
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  opacity: 0.5;
  cursor: pointer;
}
[data-theme="dark"] input[type="date"] {
  color-scheme: dark;
}

/* Modal Tabs (Nature Style) */
.modal-tabs { 
  display: flex; 
  padding: 0 1.5rem; 
  background: rgba(0,0,0,0.05); 
  border-bottom: 2px solid #76c043; /* Durchgehende grüne Linie */
  gap: 5px;
  align-items: flex-end;
}
[data-theme="dark"] .modal-tabs { background: rgba(255,255,255,0.03); }

.nav-link { 
  padding: 0.6rem 1.25rem; 
  border: none; 
  background: transparent; 
  color: #9ca3af; 
  font-size: 0.85rem; 
  font-weight: 600; 
  cursor: pointer; 
  border-radius: 8px 8px 0 0; /* Oben abgerundet */
  transition: all 0.2s;
  margin-bottom: -2px; /* Auf der Linie sitzen */
}

.nav-link:hover { color: #76c043; }

.nav-link.active { 
  background-color: #76c043 !important; 
  color: #111827 !important; /* Dunkle Schrift auf Grün */
  border-bottom: none;
}
#modal-task .modal-header { background-color: #d97706; }
#modal-contact .modal-header { background-color: #0d9488; }

#modal-task .modal-tabs { border-bottom-color: #d97706; }
#modal-task .nav-link:hover { color: #d97706; }
#modal-task .nav-link.active {
  background-color: #d97706 !important;
  color: #ffffff !important;
}

#modal-contact .modal-tabs { border-bottom-color: #76c043; }
#modal-contact .nav-link:hover { color: #76c043; }
#modal-contact .nav-link.active {
  background-color: #76c043 !important;
  color: #111827 !important;
}

.tab-pane { 
  display: none; 
  height: 100%; /* Nutzt die volle Höhe des modal-body */
}
.tab-pane.active { 
  display: block; 
  animation: fadeIn 0.2s ease; 
}

/* Google Picker */
.picker-dialog { z-index: 3000 !important; }

/* Toast */
.toast-container { position: fixed; bottom: 2rem; right: 2rem; z-index: 3000; display: flex; flex-direction: column; gap: 0.5rem; }
.toast { background: var(--bg-card); border-left: 4px solid var(--primary); padding: 1rem; border-radius: 4px; box-shadow: var(--shadow-md); transform: translateX(120%); transition: transform 0.3s; }
.toast.show { transform: translateX(0); }

/* Theme Toggle */
.theme-toggle { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 5px; }

#loading-overlay { position: fixed; inset: 0; background: var(--bg-color); z-index: 9999; display: flex; justify-content: center; align-items: center; }
.loader { width: 40px; height: 40px; border: 4px solid var(--border-color); border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Calendar --- */
.calendar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.calendar-nav { display: flex; align-items: center; gap: 1rem; }
.calendar-title { font-size: 1.25rem; font-weight: 700; min-width: 150px; text-align: center; }

.calendar-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); border-bottom: 1px solid var(--border-color); }
.calendar-weekday { padding: 0.75rem; text-align: center; font-size: 0.8rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; }

.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); border-left: 1px solid var(--border-color); border-top: 1px solid var(--border-color); }
.calendar-day { 
  min-height: 120px; padding: 0.5rem; border-right: 1px solid var(--border-color); border-bottom: 1px solid var(--border-color); 
  background: var(--bg-card); transition: background 0.2s; position: relative;
}
.calendar-day:hover { background: rgba(0,0,0,0.02); }
.calendar-day.empty { background: rgba(0,0,0,0.03); }
.calendar-day.today { background: var(--primary-light); }
.calendar-day.today .calendar-date { background: var(--primary); color: white; }

.calendar-date { 
  font-size: 0.85rem; font-weight: 600; margin-bottom: 0.5rem; display: inline-flex; 
  width: 24px; height: 24px; align-items: center; justify-content: center; border-radius: 50%; 
}

.calendar-events { display: flex; flex-direction: column; gap: 4px; }
.cal-chip { 
  font-size: 0.7rem; padding: 4px 6px; border-radius: 4px; cursor: pointer; 
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 1px solid rgba(0,0,0,0.1);
  background: #f3f4f6; color: #374151;
}
.cal-chip:hover { filter: brightness(0.95); }
.cal-chip.chip-task { background: #fffbeb; border-color: #fde68a; color: #92400e; font-style: italic; }

/* Zuständig Colors for chips */
.cal-chip.bg-h { border-left: 3px solid #3b82f6; }
.cal-chip.bg-n { border-left: 3px solid #ec4899; }
.cal-chip.bg-hn { border-left: 3px solid #8b5cf6; }

/* --- Tables & Badges --- */
.table-responsive { overflow-x: auto; }
.badge { display: inline-flex; align-items: center; padding: 0.25rem 0.5rem; border-radius: 4px; font-size: 0.75rem; font-weight: 600; }
.badge-zustaendig { width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 700; color: white; }
.bg-h { background-color: #76c043; } /* Natur-Grün für H */
.bg-n { background-color: #ec4899; }
.bg-hn { background: linear-gradient(135deg, #76c043 50%, #ec4899 50%); }

.due-date {
  font-weight: 600;
}
.due-date.is-due-today,
.due-hint.is-due-today {
  color: #f59e0b;
}
.due-date.is-overdue,
.due-hint.is-overdue {
  color: #ef4444;
  font-weight: 700;
}
.due-hint {
  display: inline-block;
  margin-top: 0.15rem;
  font-size: 0.72rem;
}

.progress-wrapper { display: flex; align-items: center; gap: 0.75rem; width: 100%; min-width: 120px; }
.progress-bar-bg { flex-grow: 1; height: 6px; background: var(--border-color); border-radius: 3px; overflow: hidden; }
.progress-bar-fill {
    background-color: #10b981; /* Ein schönes Grün für den Fortschritt */
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}
.progress-text { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); min-width: 2.5rem; text-align: right; }

.clickable-row { cursor: pointer; transition: background 0.1s; }
.clickable-row:hover { background-color: rgba(0,0,0,0.03) !important; }

/* Responsive */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .charts-grid { flex-direction: column; }
}

@media (max-width: 768px) {
  .stats-grid { grid-template-columns: 1fr; }
  .calendar-weekday { font-size: 0.7rem; padding: 0.5rem 0.25rem; }
  .calendar-day { min-height: 80px; }
}
