/* ============================================================
   FlowKater — Responsives Layout
   ============================================================ */

/* ── App-Shell ── */
#app {
  display: flex;
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

/* ── Sidebar ── */
#sidebar {
  width: var(--sidebar-width);
  height: 100dvh;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 200;
  transition: transform var(--transition-normal), width var(--transition-normal);
}

/* ── Haupt-Inhaltsbereich ── */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: margin-right var(--transition-normal);
}

/* ── Top-Bar (Mobile/Tablet) ── */
#topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  gap: var(--space-3);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

#topbar-title {
  font-size: var(--text-lg);
  font-weight: 600;
  flex: 1;
}

/* ── Inhalts-Scrollbereich ── */
#content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-4);
}

/* ── Detail-Panel ── */
#detail-panel {
  width: var(--detail-panel-width);
  height: 100dvh;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  z-index: 300;
  transform: translateX(100%);
  transition: transform var(--transition-normal);
  position: fixed;
  right: 0;
  top: 0;
}

#detail-panel.open {
  transform: translateX(0);
}

/* ── Tab-Bar (Mobile) ── */
#tab-bar {
  height: var(--tab-bar-height);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: none;
  align-items: stretch;
  flex-shrink: 0;
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: var(--space-2) 0;
  color: var(--color-text-dim);
  font-size: 10px;
  font-weight: 500;
  transition: color var(--transition-fast);
  cursor: pointer;
}

.tab-item svg { width: 22px; height: 22px; }
.tab-item.active { color: var(--color-primary-light); }

/* ── FAB Speed-Dial ── */
#fab-container {
  position: fixed;
  bottom: calc(var(--tab-bar-height) + var(--space-4));
  right: var(--space-4);
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-3);
}

#fab-menu {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
  pointer-events: none;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity var(--transition-normal), transform var(--transition-normal);
}

#fab-menu.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.fab-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: var(--space-2) var(--space-3) var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.fab-option:hover {
  background: var(--color-primary);
  color: white;
  transform: translateX(-3px);
}

.fab-option-label { flex: 1; }

.fab-option-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: white;
}

.fab-option:hover .fab-option-icon { background: rgba(255,255,255,0.2); }

#fab {
  width: var(--fab-size);
  height: var(--fab-size);
  background: var(--color-primary);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}

#fab:hover { background: var(--color-primary-hover); box-shadow: var(--shadow-xl); transform: scale(1.06); }
#fab:active { transform: scale(0.95); }
#fab.open { transform: rotate(45deg) scale(1.06); }
#fab svg { width: 26px; height: 26px; fill: white; }

/* ── Log-Panel ── */
#log-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 350;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  font-size: var(--text-sm);
}

#log-panel-bar {
  height: 32px;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-4);
  cursor: pointer;
  user-select: none;
  transition: background var(--transition-fast);
}

#log-panel-bar:hover { background: var(--color-surface-hover); }

.log-status-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background: transparent;
  flex-shrink: 0;
  transition: background var(--transition-fast);
}

.log-status-dot.success { background: var(--color-success); }
.log-status-dot.error   { background: var(--color-danger); }
.log-status-dot.info    { background: var(--color-primary-light); }

#log-panel-title {
  flex: 1;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#log-panel-title[data-type="error"]   { color: var(--color-danger); }
#log-panel-title[data-type="success"] { color: var(--color-success); }
#log-panel-title[data-type="info"]    { color: var(--color-primary-light); }

#log-panel-chevron {
  flex-shrink: 0;
  color: var(--color-text-dim);
  transition: transform var(--transition-normal);
}

#log-panel-body {
  display: none;
  flex-direction: column;
  max-height: 180px;
  overflow-y: auto;
  padding: var(--space-2) var(--space-4);
  gap: 2px;
  border-top: 1px solid var(--color-border);
}

.log-entry {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  padding: 3px 0;
  font-size: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.log-entry:last-child { border-bottom: none; }

.log-time {
  font-size: 11px;
  color: var(--color-text-dim);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.log-msg { flex: 1; color: var(--color-text-muted); }
.log-entry.success .log-msg { color: var(--color-success); }
.log-entry.error   .log-msg { color: var(--color-danger); }

/* ── Sidebar Drawer-Overlay (Mobile) ── */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 190;
}

#sidebar-overlay.show { display: block; }

/* ============================================================
   MOBILE (< 768px)
   ============================================================ */
@media (max-width: 767px) {
  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    width: min(var(--sidebar-width), 85vw);
    z-index: 200;
  }

  #sidebar.open { transform: translateX(0); }

  #topbar { display: flex; }

  #tab-bar { display: flex; }

  #content { padding: var(--space-3); padding-bottom: calc(var(--tab-bar-height) + 32px + var(--space-10)); }

  #fab-container { bottom: calc(var(--tab-bar-height) + var(--space-3)); }

  #log-panel { bottom: var(--tab-bar-height); }

  #detail-panel {
    position: fixed;
    inset: auto 0 0 0;
    top: auto;
    height: 92dvh;
    width: 100%;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    border-left: none;
    border-top: 1px solid var(--color-border);
    transform: translateY(100%);
  }

  #detail-panel.open { transform: translateY(0); }

  /* Bottom-Sheet Griffbalken */
  #detail-panel::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: var(--color-border);
    border-radius: var(--radius-full);
    margin: var(--space-3) auto var(--space-2);
    flex-shrink: 0;
  }

  /* Kanban horizontal scrollbar */
  .kanban-board {
    display: flex;
    gap: var(--space-3);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--space-3);
  }

  .kanban-column {
    scroll-snap-align: start;
    min-width: calc(100vw - var(--space-8));
    flex-shrink: 0;
  }
}

/* ============================================================
   TABLET (768px – 1199px)
   ============================================================ */
@media (min-width: 768px) and (max-width: 1199px) {
  #sidebar {
    width: var(--sidebar-rail-width);
    overflow: visible;
    position: relative;
    flex-shrink: 0;
  }

  #sidebar.expanded { width: var(--sidebar-width); }

  #sidebar .sidebar-label { display: none; }
  #sidebar.expanded .sidebar-label { display: block; }
  #sidebar .sidebar-section-title { display: none; }
  #sidebar.expanded .sidebar-section-title { display: block; }

  #sidebar:not(.expanded) .sidebar-area-group { border: none; margin: 0; }
  #sidebar:not(.expanded) .sidebar-area-header { display: none; }

  #topbar { display: flex; }

  #content { padding: var(--space-4); }

  #detail-panel {
    position: fixed;
    width: 50vw;
    max-width: 480px;
  }

  #main.detail-open { margin-right: min(50vw, 480px); }

  /* Kartenraster: 2 Spalten */
  .task-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
  }
}

/* ============================================================
   DESKTOP (≥ 1200px)
   ============================================================ */
@media (min-width: 1200px) {
  #sidebar {
    width: var(--sidebar-width);
    position: relative;
    flex-shrink: 0;
  }

  #topbar { display: none; }

  #tab-bar { display: none; }

  #fab-container { bottom: calc(32px + var(--space-5)); right: var(--space-6); }

  #detail-panel {
    position: relative;
    transform: translateX(100%);
    flex-shrink: 0;
  }

  #detail-panel.open {
    transform: translateX(0);
  }

  #main.detail-open {
    /* Inhalt wird nach links gedrückt wenn Panel offen */
  }

  /* Kartenraster: 3-4 Spalten */
  .task-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-4);
  }

  /* Kanban: mehrere Spalten nebeneinander */
  .kanban-board {
    display: flex;
    gap: var(--space-4);
    overflow-x: auto;
    align-items: flex-start;
    padding-bottom: var(--space-4);
    height: 100%;
  }

  .kanban-column {
    min-width: 280px;
    max-width: 320px;
    flex-shrink: 0;
  }
}

/* ============================================================
   Sidebar-Inhalt
   ============================================================ */
#sidebar-header {
  padding: var(--space-5) var(--space-4) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.sidebar-logo img {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-primary-light);
  letter-spacing: -0.02em;
}

#sidebar-nav {
  flex: 1;
  padding: 0 var(--space-2) var(--space-4);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-dim);
  padding: var(--space-4) var(--space-3) var(--space-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  user-select: none;
  white-space: nowrap;
  min-height: 38px;
}

.nav-item:hover { background: var(--color-surface-hover); color: var(--color-text); }
.nav-item.active { background: rgba(27, 79, 204, 0.2); color: var(--color-primary-light); }

.nav-item-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-item svg { width: 18px; height: 18px; }

.nav-item-count {
  margin-left: auto;
  font-size: 11px;
  background: var(--color-surface-raised);
  border-radius: var(--radius-full);
  padding: 1px 6px;
  min-width: 20px;
  text-align: center;
}

.nav-item.active .nav-item-count {
  background: rgba(27, 79, 204, 0.35);
}

/* ── Bereich-Gruppe: Rahmen in Area-Farbe ── */
.sidebar-area-group {
  border: 1.5px solid var(--area-color, var(--color-border));
  border-radius: var(--radius-lg);
  margin: var(--space-2) 0;
  overflow: hidden;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.sidebar-orphan-group {
  --area-color: var(--color-border);
}

/* Projekt-Drag-Feedback auf Bereich-Gruppen */
.sidebar-area-group.area-drop-ready {
  border-style: dashed;
}

.sidebar-area-group.project-drag-over {
  background: rgba(27, 79, 204, 0.07);
  border-color: var(--color-primary) !important;
  border-style: solid;
}

/* ── Logbuch ── */
.logbook-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-dim);
  padding: var(--space-3) 0 var(--space-2);
  margin-top: var(--space-2);
}

.logbook-projects {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.logbook-project-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  gap: var(--space-3);
}

.logbook-project-name {
  font-size: var(--text-sm);
  font-weight: 500;
  flex: 1;
}

.logbook-project-date {
  font-size: 11px;
  color: var(--color-text-dim);
  flex-shrink: 0;
}

/* ── Bereich-Header in der Sidebar ── */
.sidebar-area-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3) var(--space-1);
  cursor: default;
}

.sidebar-area-dot {
  width: 9px;
  height: 9px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.sidebar-area-name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  flex: 1;
}

.sidebar-area-btn {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1;
  color: var(--color-text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition-fast), background var(--transition-fast);
  flex-shrink: 0;
}

.sidebar-area-header:hover .sidebar-area-btn { opacity: 1; }
.sidebar-area-btn:hover { background: var(--color-surface-hover); color: var(--color-text); }
.sidebar-area-del:hover { color: var(--color-danger) !important; }

/* ── Drag-to-Sidebar Drop-Feedback ── */
.nav-item.sidebar-drop-ready {
  outline: 1px dashed var(--color-border-light);
  outline-offset: -2px;
}

.nav-item.sidebar-drop-over {
  background: rgba(27, 79, 204, 0.18) !important;
  outline: 1.5px solid var(--color-primary);
  outline-offset: -2px;
  color: var(--color-primary-light);
}

/* Sidebar-Fußzeile */
#sidebar-footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name { font-size: var(--text-sm); font-weight: 600; }
.user-role { font-size: 11px; color: var(--color-text-dim); }

.live-indicator {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--color-success);
  box-shadow: 0 0 6px var(--color-success);
  flex-shrink: 0;
  transition: background var(--transition-normal);
}

.live-indicator.offline { background: var(--color-text-dim); box-shadow: none; }

/* ============================================================
   Top-Bar Inhalte
   ============================================================ */
.hamburger-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  transition: background var(--transition-fast);
}

.hamburger-btn:hover { background: var(--color-surface-hover); }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ============================================================
   Detail-Panel-Inhalt
   ============================================================ */
#detail-panel-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

#detail-panel-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  margin-left: auto;
  transition: background var(--transition-fast);
}

#detail-panel-close:hover { background: var(--color-surface-hover); }

#detail-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

/* ============================================================
   Ansichten-Header
   ============================================================ */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  gap: var(--space-4);
}

.view-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.view-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

.view-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ============================================================
   Kanban-Board
   ============================================================ */
.kanban-column {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 160px);
}

.kanban-column-header {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.kanban-column-count {
  font-size: 11px;
  background: var(--color-surface-raised);
  border-radius: var(--radius-full);
  padding: 1px 6px;
}

.kanban-column-body {
  padding: var(--space-3);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  flex: 1;
  min-height: 60px;
}

.kanban-column-body.drag-over {
  background: rgba(27, 79, 204, 0.08);
  border-radius: var(--radius-md);
}

/* ============================================================
   Suchleiste
   ============================================================ */
.search-bar {
  display: flex;
  align-items: center;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 0 var(--space-3);
  gap: var(--space-2);
  transition: border-color var(--transition-fast);
}

.search-bar:focus-within {
  border-color: var(--color-primary);
}

.search-bar input {
  flex: 1;
  padding: var(--space-3) 0;
  font-size: var(--text-base);
}

.search-bar svg { color: var(--color-text-dim); width: 18px; height: 18px; }
