/* ==========================================================================
   LAYOUT.CSS — Sidebar, Hauptbereich, Topbar
   Das Grundgeruest der App: Sidebar links, Hauptinhalt rechts
   ========================================================================== */

/* --------------------------------------------------------------------------
   Sidebar — Linke Navigationsleiste
   -------------------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--transition-slow);
  z-index: 100;
}

/* --------------------------------------------------------------------------
   Sidebar — Markenbereich (Logo + Untertitel)
   -------------------------------------------------------------------------- */
.sidebar-brand {
  padding: var(--space-5) var(--space-4) var(--space-4);
  /* Safe-Area oben: Platz fuer Dynamic Island im PWA-Modus */
  padding-top: max(var(--space-5), env(safe-area-inset-top));
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-brand h1 {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent);
  line-height: 1.2;
}

.sidebar-brand .subtitle,
.sidebar-brand small {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: var(--space-1);
  letter-spacing: 0.02em;
  display: block;
}

.sidebar-logo {
  max-width: 100%;
  height: auto;
  margin-bottom: var(--space-1);
  /* Weisser Hintergrund wird transparent auf dunklem BG */
  mix-blend-mode: screen;
}

/* --------------------------------------------------------------------------
   Sidebar — Sektionen (Gruppierung mit Ueberschriften)
   -------------------------------------------------------------------------- */
.sidebar-section {
  padding: var(--space-3) var(--space-3) var(--space-1);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  opacity: 0.7;
}

.sidebar-section-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  opacity: 0.7;
  padding: 0 var(--space-2) var(--space-2);
}

/* --------------------------------------------------------------------------
   Sidebar — Navigations-Eintraege
   HTML nutzt <li> Elemente direkt in .sidebar-nav (nicht .sidebar-nav-item)
   -------------------------------------------------------------------------- */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-nav li {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--text-base);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  user-select: none;
}

.sidebar-nav li:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar-nav li.active {
  background: var(--accent-subtle);
  color: var(--accent);
  font-weight: 600;
}

/* Aktiver Indikator-Balken links — mit Scale-Animation */
.sidebar-nav li.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
  animation: indicatorIn 0.2s ease;
}

@keyframes indicatorIn {
  from { transform: translateY(-50%) scaleY(0); }
  to   { transform: translateY(-50%) scaleY(1); }
}

.sidebar-nav li .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-nav li.active .nav-icon {
  opacity: 1;
}

/* Zaehler-Badge (z.B. Anzahl Tasks) */
.sidebar-nav li .count {
  margin-left: auto;
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  background: var(--bg-hover);
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

.sidebar-nav li.active .count {
  background: var(--accent-subtle);
  color: var(--accent);
}

/* --------------------------------------------------------------------------
   Sidebar — Projekt-Liste
   -------------------------------------------------------------------------- */
.project-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.project-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--text-base);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.project-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.project-item.active {
  background: var(--accent-subtle);
  color: var(--accent);
}

/* Farbiger Punkt vor dem Projektnamen */
.project-item .project-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.project-item .project-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Projekt-Phase Badge in der Sidebar */
.project-item .project-phase {
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--bg-active);
  color: var(--text-tertiary);
  white-space: nowrap;
}

/* Zaehler rechts — JS rendert .count (nicht .project-count) */
.project-item .project-count,
.project-item .count {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-left: auto;
}

/* Hover-Aktionen (Bearbeiten/Loeschen) — standardmaessig versteckt */
.project-item .project-actions {
  display: none;
  gap: var(--space-1);
  margin-left: auto;
}

.project-item:hover .project-actions {
  display: flex;
}

.project-item:hover .project-count,
.project-item:hover > .count {
  display: none;
}

.project-item .project-action-btn {
  padding: 2px;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  transition: all var(--transition-fast);
}

.project-item .project-action-btn:hover {
  color: var(--text-primary);
  background: var(--bg-active);
}

/* Klappbare Projekt-Gruppen (Linear-Style) */
.sidebar-group { margin-bottom: var(--space-1); }
.sidebar-group-header {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); cursor: pointer;
  transition: color var(--transition-fast);
  user-select: none;
}
.sidebar-group-header:hover { color: var(--text-secondary); }
.sidebar-group-arrow {
  font-size: 10px;
  transition: transform var(--transition-fast);
  display: inline-block;
}
.sidebar-group.collapsed .sidebar-group-arrow { transform: rotate(-90deg); }
.sidebar-group-count {
  margin-left: auto; color: var(--text-muted);
  font-size: 10px; font-weight: 400;
}
.sidebar-group-items {
  overflow: hidden;
  transition: max-height var(--transition-slow);
  max-height: 500px;
}
.sidebar-group.collapsed .sidebar-group-items { max-height: 0; }

/* project-click — war vorher Inline-Style */
.project-click {
  display: flex; align-items: center; gap: 0.5rem;
  flex: 1; cursor: pointer;
}

/* --------------------------------------------------------------------------
   Sidebar — Projekt hinzufuegen Button
   HTML nutzt class="sidebar-add" (nicht .add-project-btn)
   -------------------------------------------------------------------------- */
.sidebar-add {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  margin: var(--space-1) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-default);
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.sidebar-add:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-subtle);
}

/* --------------------------------------------------------------------------
   Sidebar — Unterer Bereich (Spacer drueckt nach unten)
   -------------------------------------------------------------------------- */
.sidebar-spacer {
  flex: 1;
}

.sidebar-footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Hauptbereich — Rechte Seite
   -------------------------------------------------------------------------- */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* --------------------------------------------------------------------------
   Topbar — Obere Leiste mit Schnell-Eingabe und Aktionen
   -------------------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  /* Safe-Area oben: Platz fuer Dynamic Island / Notch im PWA-Standalone-Modus */
  padding-top: max(var(--space-3), env(safe-area-inset-top));
  background: var(--bg-surface);
  border-bottom: 2px solid var(--accent);
  flex-shrink: 0;
  min-height: 56px;
}

/* Hamburger-Button — nur auf Mobile sichtbar */
/* HTML nutzt class="hamburger" (nicht .hamburger-btn) */
.hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  transition: all var(--transition-fast);
  flex-shrink: 0;
  font-size: 1.4rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.hamburger:hover,
.hamburger:active {
  background: var(--bg-active);
  color: var(--accent);
}

/* Quick-Add Bar — Schnelle Task-Erstellung in der Topbar */
.quick-add-bar {
  flex: 1;
  min-width: 0;
}

.quick-add-input {
  width: 100%;
  height: 36px;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  transition: border-color var(--transition-fast);
}

.quick-add-input::placeholder {
  color: var(--text-muted);
}

.quick-add-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-surface);
}

/* Theme-Toggle Button */
.btn-theme {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  flex-shrink: 0;
  font-size: var(--text-md);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
}

.btn-theme:hover {
  background: var(--bg-hover);
  border-color: var(--border-default);
}

/* --------------------------------------------------------------------------
   Topbar — Aktions-Buttons (Mikrofon, Hinzufuegen)
   HTML nutzt .btn-mic und .btn-add-main direkt (nicht .topbar-btn)
   -------------------------------------------------------------------------- */

/* Mikrofon-Button — runder Button */
.btn-mic {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-active);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  flex-shrink: 0;
  font-size: var(--text-md);
  border: 1px solid var(--border-subtle);
}

.btn-mic:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.btn-mic:active {
  transform: scale(0.96);
}

/* Hinzufuegen-Button — rund, Akzentfarbe */
.btn-add-main {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-lg);
  background: var(--accent);
  color: #fff;
  font-size: var(--text-xl);
  font-weight: 600;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  border: none;
  box-shadow: 0 2px 8px rgba(44, 182, 125, 0.25);
}

.btn-add-main:hover {
  background: var(--accent-hover);
}

.btn-add-main:active {
  transform: scale(0.96);
}

/* Statsbar entfernt — Zaehler sind in der Sidebar */

/* --------------------------------------------------------------------------
   Timer-Bar — Sichtbar wenn Timer laeuft
   -------------------------------------------------------------------------- */
.timer-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-5);
  background: var(--accent-subtle);
  border-bottom: 1px solid var(--accent);
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.timer-bar-icon {
  color: var(--accent);
  font-size: var(--text-xs);
  animation: timer-pulse 1.5s ease infinite;
}

@keyframes timer-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.timer-bar-desc {
  flex: 1;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timer-bar-time {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent);
  font-size: var(--text-base);
}

.timer-bar-stop {
  background: var(--color-danger);
  color: #fff;
  border: none;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.timer-bar-stop:hover {
  background: #c0392b;
}

/* --------------------------------------------------------------------------
   Projekt-Detail-Header — Ueber Task-Grid wenn Projekt gefiltert
   -------------------------------------------------------------------------- */
.project-header {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
}

.ph-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.ph-title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
}

.ph-client {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  margin-top: var(--space-1);
}

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

.ph-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-bottom: var(--space-3);
}

.ph-meta-item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.ph-meta-item.overdue {
  color: var(--color-danger);
  font-weight: 600;
}

.ph-meta-item.soon {
  color: var(--color-warning);
}

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

.ph-progress-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-active);
  border-radius: 3px;
  overflow: hidden;
}

.ph-progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width var(--transition-base);
}

.ph-progress-text {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  white-space: nowrap;
  font-weight: 500;
}

.ph-desc {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
}

/* --------------------------------------------------------------------------
   Timer-Button auf Task-Karten
   -------------------------------------------------------------------------- */
.timer-btn {
  background: none;
  border: 1px solid var(--border-default);
  color: var(--text-tertiary);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  padding: 0;
  line-height: 1;
}

.timer-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-subtle);
}

.timer-btn.active {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: #fff;
  animation: timer-pulse 1.5s ease infinite;
}

/* --------------------------------------------------------------------------
   Inhaltsbereich — Scrollbarer Hauptinhalt
   -------------------------------------------------------------------------- */
.content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5);
}

/* --------------------------------------------------------------------------
   Ansichts-Kopfzeile (z.B. "Heute / Mein Tag")
   -------------------------------------------------------------------------- */
.view-header {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

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

.view-date {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}

/* --------------------------------------------------------------------------
   Sidebar Overlay — Hintergrund-Abdunklung auf Mobile
   -------------------------------------------------------------------------- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
}

.sidebar-overlay.active,
.sidebar-overlay.open {
  display: block;
  animation: fadeIn var(--transition-slow) ease;
}

/* --------------------------------------------------------------------------
   FAB (Floating Action Button) — Nur auf Mobile sichtbar
   -------------------------------------------------------------------------- */
.fab {
  display: none;
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  z-index: 50;
  transition: all var(--transition-fast);
  animation: slideInUp var(--transition-slow) ease;
}

.fab:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-xl);
}

.fab:active {
  transform: scale(0.95);
}


/* --------------------------------------------------------------------------
   Modal-Overlay — Hintergrund fuer alle Modals
   -------------------------------------------------------------------------- */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  justify-content: center;
  align-items: center;
}

.overlay.open {
  display: flex;
}


/* --------------------------------------------------------------------------
   Voice Recording Overlay — Spracheingabe
   -------------------------------------------------------------------------- */
.voice-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 300;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

.voice-overlay.open {
  display: flex;
}

.voice-modal {
  text-align: center;
  max-width: 500px;
  width: 90%;
  padding: var(--space-8);
}

/* Voice-Mode-Toggle: Braindump vs. Task Umschalter */
.voice-mode-toggle {
  display: flex;
  gap: var(--space-1);
  justify-content: center;
  margin-bottom: var(--space-5);
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  padding: var(--space-1);
}

.voice-mode-btn {
  padding: var(--space-2) var(--space-4);
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: var(--transition-fast);
  flex: 1;
}

.voice-mode-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.voice-mode-btn.active {
  background: var(--accent);
  color: #fff;
}

.voice-mic-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--color-danger);
  color: #fff;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-5);
  animation: voicePulse 2s ease infinite;
}

@keyframes voicePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
  50% { box-shadow: 0 0 0 12px rgba(239, 68, 68, 0); }
}

.voice-timer {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--color-danger);
  font-variant-numeric: tabular-nums;
  margin-bottom: var(--space-4);
}

.voice-status {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}

.voice-transcript {
  background: var(--bg-hover);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  max-height: 200px;
  overflow-y: auto;
  text-align: left;
  font-size: var(--text-base);
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: var(--space-5);
  min-height: 60px;
}

.voice-transcript .interim {
  color: var(--text-muted);
  font-style: italic;
}

.voice-btn-stop {
  background: var(--color-danger);
  color: #fff;
  border: none;
  padding: var(--space-3) var(--space-8);
  border-radius: 25px;
  font-size: var(--text-md);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: var(--space-3);
}

.voice-btn-stop:hover {
  background: #DC2626;
}

.voice-btn-cancel {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  cursor: pointer;
  padding: var(--space-2) var(--space-4);
}

.voice-btn-cancel:hover {
  color: var(--text-secondary);
}

.voice-hint {
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  margin-top: var(--space-4);
}

/* Voice Processing Zustand */
.voice-overlay.processing .voice-mic-icon {
  animation: none;
  background: var(--color-info);
}

.voice-overlay.processing .voice-timer {
  color: var(--color-info);
}

.voice-overlay.processing .voice-btn-stop {
  display: none;
}


/* --------------------------------------------------------------------------
   Mikrofon-Button Recording-Zustand
   -------------------------------------------------------------------------- */
.btn-mic.recording {
  background: var(--color-danger);
  color: #fff;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(229, 83, 75, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(229, 83, 75, 0); }
}
