/* ============================================================
   CSS Custom Properties – Dark/Light Theme
   ============================================================ */
:root,
[data-theme="dark"] {
  --bg-base:      #0f1117;
  --bg-surface:   #1a1d24;
  --bg-card:      #22262e;
  --bg-input:     #1e2229;
  --bg-hover:     #2a2f3a;
  --border:       rgba(255,255,255,.08);
  --border-focus: #6366f1;
  --text-primary: #e8eaf0;
  --text-secondary:#8b92a5;
  --text-muted:   #555e73;
  --accent:       #6366f1;
  --accent-hover: #4f46e5;
  --accent-subtle:#6366f120;
  --success:      #22c55e;
  --warning:      #f59e0b;
  --danger:       #ef4444;
  --info:         #38bdf8;
  --shadow:       0 4px 24px rgba(0,0,0,.4);
  --shadow-sm:    0 2px 8px rgba(0,0,0,.3);
  --radius:       10px;
  --radius-sm:    6px;
  --sidebar-w:    240px;
  --topbar-h:     56px;
  --transition:   .18s ease;
}

[data-theme="light"] {
  --bg-base:      #f0f2f5;
  --bg-surface:   #ffffff;
  --bg-card:      #ffffff;
  --bg-input:     #f8f9fc;
  --bg-hover:     #f0f2f7;
  --border:       rgba(0,0,0,.1);
  --border-focus: #6366f1;
  --text-primary: #111827;
  --text-secondary:#4b5563;
  --text-muted:   #9ca3af;
  --accent:       #6366f1;
  --accent-hover: #4f46e5;
  --accent-subtle:#6366f115;
  --success:      #16a34a;
  --warning:      #d97706;
  --danger:       #dc2626;
  --info:         #0284c7;
  --shadow:       0 4px 24px rgba(0,0,0,.1);
  --shadow-sm:    0 2px 8px rgba(0,0,0,.07);
}

/* ============================================================
   Reset / Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: .9375rem;
  background: var(--bg-base);
  color: var(--text-primary);
  height: 100%;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ============================================================
   Layout
   ============================================================ */
.app-wrapper {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--transition);
  z-index: 200;
}

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 199;
}
.sidebar-overlay.show { display: block; }

.sidebar-header {
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
}

.sidebar-section { display: flex; flex-direction: column; gap: 2px; }
.sidebar-section-label {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: .5rem .75rem .25rem;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .45rem .75rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: .875rem;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-item.active { background: var(--accent-subtle); color: var(--accent); font-weight: 500; }
.sidebar-item-new { color: var(--text-muted); font-style: normal; }
.sidebar-item-new:hover { color: var(--accent); }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: .5rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.project-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Top-Bar */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: .5rem;
}
.topbar-title { min-width: 0; }

/* App Content */
.app-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.5rem;
}

@media (max-width: 991px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .app-content { padding: 1rem; }
}

/* ============================================================
   Bootstrap Overrides
   ============================================================ */

/* Bootstrap text-muted / secondary ans Custom-Theme anpassen */
.text-muted   { color: var(--text-secondary) !important; }
.text-secondary { color: var(--text-secondary) !important; }

/* Bootstrap card ans Custom-Theme anpassen */
.card { color: var(--text-primary); }
.card-body { color: var(--text-primary); }
.btn { border-radius: var(--radius-sm); font-size: .875rem; }
.btn-accent {
  background: var(--accent); color: #fff; border: none;
}
.btn-accent:hover { background: var(--accent-hover); color: #fff; }
.btn-ghost {
  background: none; border: none; color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.form-control, .form-select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  font-size: .875rem;
}
.form-control:focus, .form-select:focus {
  background: var(--bg-input);
  border-color: var(--border-focus);
  color: var(--text-primary);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}
.form-control::placeholder { color: var(--text-muted); }
.form-label { font-size: .8125rem; font-weight: 500; color: var(--text-secondary); margin-bottom: .3rem; }

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.modal-header { border-bottom: 1px solid var(--border); }
.modal-footer { border-top: 1px solid var(--border); }
.modal-title { font-size: 1rem; font-weight: 600; }
.btn-close { filter: var(--btn-close-filter, invert(1) opacity(.5)); }
[data-theme="light"] .btn-close { filter: none; }

.dropdown-menu {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: .875rem;
}
.dropdown-item { color: var(--text-primary); }
.dropdown-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.dropdown-divider { border-color: var(--border); }

.nav-tabs { border-bottom: 1px solid var(--border); }
.nav-tabs .nav-link { color: var(--text-secondary); border: none; padding: .5rem 1rem; font-size: .875rem; }
.nav-tabs .nav-link:hover { color: var(--text-primary); background: var(--bg-hover); }
.nav-tabs .nav-link.active { color: var(--accent); border-bottom: 2px solid var(--accent); background: none; font-weight: 500; }

.badge { font-size: .75rem; font-weight: 500; }

.progress { background: var(--bg-hover); height: 6px; border-radius: 99px; }

hr { border-color: var(--border); opacity: 1; }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-hover:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  cursor: pointer;
}

/* ============================================================
   Dashboard — Projektkacheln
   ============================================================ */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  position: relative;
  overflow: hidden;
}
.project-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 3px;
  background: var(--project-color, var(--accent));
}
.project-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--project-color, var(--accent));
}
.project-card-title { font-weight: 600; font-size: 1.05rem; margin: .5rem 0 .25rem; }
.project-card-date { font-size: .8rem; color: var(--text-muted); }
.project-card-modules { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .75rem; }
.module-badge {
  font-size: .75rem;
  padding: .2rem .5rem;
  border-radius: 99px;
  background: var(--bg-hover);
  color: var(--text-secondary);
  display: flex; align-items: center; gap: .3rem;
}

/* ============================================================
   User Avatar
   ============================================================ */
.user-avatar {
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  line-height: 1;
}

.user-select-list { display: flex; flex-direction: column; gap: .25rem; }
.user-select-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .5rem .75rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--bg-input);
  color: var(--text-primary);
  cursor: pointer;
  font-size: .875rem;
  transition: background var(--transition);
  text-align: left; width: 100%;
}
.user-select-item:hover { background: var(--bg-hover); }
.user-select-item.active { border-color: var(--accent); background: var(--accent-subtle); }

/* ============================================================
   Kanban Board (Todos)
   ============================================================ */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  align-items: start;
}
@media (max-width: 768px) {
  .kanban-board { grid-template-columns: 1fr; }
}

.kanban-column {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 200px;
}
.kanban-header {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: .5rem;
  font-weight: 600; font-size: .875rem;
}
.kanban-header .count-badge {
  background: var(--bg-hover);
  color: var(--text-secondary);
  border-radius: 99px;
  padding: .1rem .5rem;
  font-size: .75rem;
}
.kanban-cards {
  padding: .5rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  min-height: 80px;
}

.todo-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .75rem;
  cursor: pointer;
  transition: box-shadow var(--transition), border-color var(--transition);
  position: relative;
}
.todo-card:hover { box-shadow: var(--shadow-sm); border-color: var(--accent); }
.todo-card.priority-critical {
  background: rgba(239,68,68,.08);
  border-color: rgba(239,68,68,.3);
}
.todo-card-title { font-size: .875rem; font-weight: 500; margin-bottom: .4rem; }
.todo-card-meta { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

.priority-badge {
  font-size: .7rem; padding: .15rem .45rem; border-radius: 99px; font-weight: 600;
}
.priority-low      { background: rgba(34,197,94,.15);   color: var(--success); }
.priority-medium   { background: rgba(245,158,11,.15);  color: var(--warning); }
.priority-high     { background: rgba(239,68,68,.15);   color: var(--danger); }
.priority-critical { background: rgba(239,68,68,.3);    color: var(--danger); }

/* Pulsierender Indikator für kritische Deadlines */
.deadline-pulse {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--danger);
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .5; transform: scale(1.4); }
}

/* Todo-Drawer */
.todo-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(480px, 100vw);
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 500;
  transform: translateX(100%);
  transition: transform .25s ease;
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.todo-drawer.open { transform: translateX(0); }
.drawer-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 499;
}
.drawer-overlay.show { display: block; }

/* ============================================================
   Notes & Channels
   ============================================================ */
.notes-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1rem;
  height: calc(100vh - var(--topbar-h) - 3rem);
}
@media (max-width: 768px) {
  .notes-layout { grid-template-columns: 1fr; height: auto; }
  .notes-channels { display: none; }
  .notes-channels.show-mobile { display: flex; }
}
.notes-channels {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.channel-list { flex: 1; overflow-y: auto; padding: .5rem; }
.channel-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .45rem .75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .875rem;
  color: var(--text-secondary);
  transition: background var(--transition);
}
.channel-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.channel-item.active { background: var(--accent-subtle); color: var(--accent); font-weight: 500; }
.channel-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  border-radius: 99px;
  min-width: 18px;
  height: 18px;
  font-size: .7rem;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}

.notes-list { display: flex; flex-direction: column; gap: .75rem; }
.note-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.note-card:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.note-card.pinned { border-left: 3px solid var(--warning); }
.note-pin-icon { color: var(--warning); }

/* Markdown-Vorschau */
.markdown-preview h1,h2,h3 { color: var(--text-primary); margin-top: 1rem; }
.markdown-preview code {
  background: var(--bg-hover);
  padding: .1em .35em;
  border-radius: 3px;
  font-size: .85em;
}
.markdown-preview pre {
  background: var(--bg-hover);
  padding: .75rem;
  border-radius: var(--radius-sm);
  overflow-x: auto;
}
.markdown-preview blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
  color: var(--text-secondary);
  margin: .5rem 0;
}

/* ============================================================
   Carpools
   ============================================================ */
.carpool-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.seat-visual {
  display: flex; gap: 6px; flex-wrap: wrap; margin: .5rem 0;
}
.seat-icon {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem;
}
.seat-icon.taken { background: var(--accent-subtle); color: var(--accent); }
.seat-icon.driver { background: var(--accent); color: #fff; }

/* ============================================================
   Accommodations
   ============================================================ */
.accom-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.occupancy-bar .progress-bar {
  border-radius: 99px;
  transition: width .5s ease;
}
.occupancy-low    .progress-bar { background: var(--success); }
.occupancy-medium .progress-bar { background: var(--warning); }
.occupancy-high   .progress-bar { background: var(--danger); }

/* ============================================================
   Timeline / Gantt
   ============================================================ */
.gantt-wrapper {
  overflow-x: auto;
  overflow-y: visible;
  position: relative;
}
.gantt-header {
  display: flex;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.gantt-label-col {
  width: 200px;
  min-width: 200px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: .4rem .75rem;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-surface);
  position: sticky; left: 0; z-index: 11;
}
.gantt-day-header {
  flex: 1;
  display: flex;
  min-width: 0;
}
.gantt-day-cell {
  flex-shrink: 0;
  text-align: center;
  font-size: .7rem;
  color: var(--text-muted);
  padding: .25rem 0;
  border-right: 1px solid var(--border);
}
.gantt-day-cell.today-col {
  background: rgba(239,68,68,.08);
  color: var(--danger);
  font-weight: 600;
}

.gantt-row {
  display: flex;
  border-bottom: 1px solid var(--border);
  position: relative;
  min-height: 40px;
  align-items: center;
}
.gantt-row-label {
  width: 200px; min-width: 200px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: .4rem .75rem;
  font-size: .8rem;
  background: var(--bg-surface);
  position: sticky; left: 0; z-index: 5;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gantt-row-track {
  flex: 1;
  position: relative;
  min-height: 40px;
}

.gantt-bar {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  height: 24px;
  border-radius: 4px;
  display: flex; align-items: center;
  padding: 0 .5rem;
  font-size: .7rem;
  font-weight: 500;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  transition: opacity var(--transition), box-shadow var(--transition);
  z-index: 2;
}
.gantt-bar:hover { opacity: .85; box-shadow: var(--shadow-sm); }

.gantt-milestone {
  position: absolute;
  top: 50%; transform: translate(-50%, -50%) rotate(45deg);
  width: 16px; height: 16px;
  background: var(--warning);
  cursor: pointer;
  z-index: 2;
}

.gantt-today-line {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--danger);
  opacity: .7;
  z-index: 6;
  pointer-events: none;
}
.gantt-today-line::before {
  content: 'Heute';
  position: absolute;
  top: 2px; left: 4px;
  font-size: .65rem;
  color: var(--danger);
  white-space: nowrap;
}

/* Gantt Status-Farben */
.status-planned     { background: #6b7280; }
.status-in_progress { background: #3b82f6; }
.status-completed   { background: var(--success); }
.status-overdue     { background: var(--danger); }

/* ============================================================
   Empty State
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
  min-height: 250px;
  color: var(--text-muted);
}
.empty-state i { font-size: 2.5rem; opacity: .4; }
.empty-state h5 { margin-top: .75rem; font-size: 1rem; color: var(--text-secondary); }
.empty-state p { font-size: .875rem; margin-bottom: 1rem; }

/* ============================================================
   Toast Notifications
   ============================================================ */
.toast {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-primary) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow) !important;
  font-size: .875rem;
}
.toast.toast-success { border-left: 3px solid var(--success) !important; }
.toast.toast-error   { border-left: 3px solid var(--danger)  !important; }
.toast.toast-info    { border-left: 3px solid var(--info)    !important; }

/* ============================================================
   Filter-Panel
   ============================================================ */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
  padding: .75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}
.filter-bar .form-select,
.filter-bar .form-control { font-size: .8125rem; }
.filter-chip {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .25rem .6rem;
  border-radius: 99px;
  background: var(--accent-subtle);
  color: var(--accent);
  font-size: .75rem;
  cursor: pointer;
}
.filter-chip:hover { background: var(--accent); color: #fff; }
.filter-chip.active { background: var(--accent); color: #fff; }

/* ============================================================
   Tooltip (Gantt Hover)
   ============================================================ */
.gantt-tooltip {
  position: fixed;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .5rem .75rem;
  font-size: .8rem;
  box-shadow: var(--shadow);
  pointer-events: none;
  z-index: 999;
  max-width: 220px;
  display: none;
}

/* ============================================================
   Sortable drag-and-drop
   ============================================================ */
.sortable-ghost  { opacity: .4; }
.sortable-chosen { box-shadow: var(--shadow); }
.sortable-drag   { box-shadow: var(--shadow); }

/* ============================================================
   Misc Utility
   ============================================================ */
.text-accent { color: var(--accent) !important; }
.bg-accent   { background: var(--accent) !important; }
.border-accent { border-color: var(--accent) !important; }

.section-header {
  display: flex; align-items: center; gap: .75rem;
  margin-bottom: 1rem;
}
.section-header h4 { margin: 0; font-size: 1.1rem; font-weight: 600; }

/* Scrollable horizontal container */
.scroll-x { overflow-x: auto; }

/* Flatpickr Dark Override */
[data-theme="dark"] .flatpickr-calendar {
  background: var(--bg-card);
  border-color: var(--border);
  box-shadow: var(--shadow);
  color: var(--text-primary);
}
[data-theme="dark"] .flatpickr-day { color: var(--text-primary); }
[data-theme="dark"] .flatpickr-day.selected { background: var(--accent); border-color: var(--accent); }
[data-theme="dark"] .flatpickr-day:hover { background: var(--bg-hover); }
[data-theme="dark"] .flatpickr-months,
[data-theme="dark"] .flatpickr-weekdays { background: var(--bg-surface); color: var(--text-secondary); }
[data-theme="dark"] .flatpickr-current-month input { color: var(--text-primary); }
