/* ═══════════════════════════════════════════════════════
   Projekt-Radar PWA — Design v2 (Light-first, Notification-Feed)
   Richtung F + Atlassian Lozenges
   ═══════════════════════════════════════════════════════ */

/* ── Design Tokens ──────────────────────────────────────── */
:root {
  --accent:        #4F46E5;   /* Indigo, AA-konform auf Weiß (5.8:1) */
  --accent-weak:   #EEECFD;
  --accent-hover:  #3730A3;
  --page:          #EDEFF5;
  --surface:       #FFFFFF;
  --border:        #E1E4EE;
  --text:          #14161F;   /* 18.1:1 auf Weiß */
  --text-2:        #39404F;   /* 10.5:1 auf Weiß */
  --text-3:        #59617A;   /* 5.6:1 auf Weiß — Minimum */
  --text-4:        #59617A;   /* kein Grau heller als text-3 */

  /* Lozenges (Atlassian-Stil) */
  --lz-go-bg:      #DCFFF1;  --lz-go-text:      #216E4E;
  --lz-inv-bg:     #FFF7D6;  --lz-inv-text:     #7F5F01;
  --lz-nogo-bg:    #FFECEB;  --lz-nogo-text:    #AE2E24;
  --lz-new-bg:     #E9F2FF;  --lz-new-text:     #0055CC;
  --lz-applied-bg: #EAE6FF;  --lz-applied-text: #5E4DB2;
  --lz-meta-bg:    #F1F2F5;  --lz-meta-text:    #39404F;  /* 10.5:1 */

  /* Layout */
  --nav-h:         64px;
  --header-h:      auto;
  --radius-card:   18px;
  --radius-btn:    12px;
  --radius-nav:    24px;
  --shadow-card:   0 1px 2px rgba(20,22,31,.04);
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  background: var(--page);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.4;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font-family: inherit; }

/* ── Fokus-Sichtbarkeit (WCAG 2.2 AA) ──────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}
button:focus:not(:focus-visible),
a:focus:not(:focus-visible) { outline: none; }
a { color: inherit; text-decoration: none; }

/* ── Screen base ─────────────────────────────────────────── */
.screen { position: fixed; inset: 0; overflow: hidden; }

/* ── Login ───────────────────────────────────────────────── */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--page);
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
            env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.login-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: min(340px, calc(100vw - 48px));
  padding: 36px 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 4px 24px rgba(20,22,31,.07);
}
.login-icon { margin-bottom: 4px; }
.login-brand {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
}
.login-sub { font-size: 14px; color: var(--text-3); margin-top: -6px; margin-bottom: 8px; }
.text-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  font-size: 16px;
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.text-input:focus { border-color: var(--accent); }

/* ── Main screen layout ──────────────────────────────────── */
.main-screen {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--page);
  overflow: hidden;
}

/* ── App Header (sticky, safe-area) ─────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  /* Safe area: nothing hides under Dynamic Island */
  padding-top: max(12px, env(safe-area-inset-top));
  padding-left:  max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
  padding-bottom: 0;
}
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding-bottom: 8px;
}
.header-brand {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
}
.header-actions { display: flex; gap: 8px; align-items: center; }

/* Round icon buttons in header */
.icon-btn-round {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: opacity .15s;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn-round:active { opacity: .75; }
.icon-btn-round.ghost { background: var(--page); }
.icon-btn-round.accent { background: var(--accent); }
.push-dot {
  position: absolute;
  top: 4px; right: 4px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #EF4444;
  border: 2px solid var(--surface);
}

/* Aktiver Such-/Status-Filter: Punkt am Such-Icon (Leiste kann zu sein) */
#search-toggle-btn { position: relative; }
#search-toggle-btn.has-filter::after {
  content: '';
  position: absolute;
  top: 4px; right: 4px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
}

/* ── Sub-tabs (Go / Investigate) ────────────────────────── */
.sub-tabs {
  display: flex;
  gap: 0;
  padding-bottom: 0;
  margin-top: 2px;
}
.sub-tab {
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-3);
  cursor: pointer;
  transition: color .15s, border-color .15s;
  -webkit-tap-highlight-color: transparent;
}
.sub-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Search bar ──────────────────────────────────────────── */
.search-bar {
  display: flex;
  gap: 8px;
  padding: 10px 0 10px;
}
.search-bar input {
  flex: 1;
  padding: 9px 12px;
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  color: var(--text);
  outline: none;
}
.search-bar input:focus { border-color: var(--accent); }
.search-bar select {
  padding: 9px 10px;
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  color: var(--text-2);
  outline: none;
  min-width: 0;
}

/* ── Day label ───────────────────────────────────────────── */
.day-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-4);
  padding: 14px 20px 6px;
  padding-left: max(20px, env(safe-area-inset-left));
}

/* ── Panels ──────────────────────────────────────────────── */
.panel {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--nav-h) + 16px + max(0px, env(safe-area-inset-bottom)));
  padding-left:  max(0px, env(safe-area-inset-left));
  padding-right: max(0px, env(safe-area-inset-right));
}
.panel[hidden] { display: none; }

/* ── Project List ────────────────────────────────────────── */
.project-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 16px 8px;
}

/* ── Project Card ────────────────────────────────────────── */
.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px;
  align-items: start;
  -webkit-tap-highlight-color: transparent;
  transition: box-shadow .15s;
  min-height: 44px;
}
.project-card:active { box-shadow: 0 0 0 2px var(--accent-weak); }

/* Rezessiv: bearbeitete/veraltete Projekte. Bewusst ueber Farb-Tokens statt
   Opacity gedimmt, damit alle Texte AA-konform bleiben (Brief §6). */
.project-card.muted {
  background: transparent;
  box-shadow: none;
}
.project-card.muted .card-title { color: var(--text-2); font-weight: 600; }
.project-card.muted .card-fit   { color: var(--text-3); }
.project-card.muted .card-icon-circle { opacity: .55; }
.project-card.muted .lz { filter: saturate(.55); }

/* Plattform-Chip (Meta-Lozenge-Stil: bg #F1F2F5 / text 10.5:1, AA) */
.src-chip {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--lz-meta-text);
  background: var(--lz-meta-bg);
  border-radius: 4px;
  padding: 2px 6px;
  flex-shrink: 0;
  white-space: nowrap;
}

/* Sortier-Umschalter rechts in der Sub-Tab-Zeile */
.sort-toggle {
  margin-left: auto;
  padding: 10px 16px;
  min-height: 44px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.sort-toggle:active { color: var(--accent); }

/* Dubletten-Hinweis: dieselbe Rolle auf weiteren Kanaelen (kein Merge) */
.also-on {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);           /* 5.6:1 auf Weiss — AA */
  margin-top: 3px;
}
.detail-body .also-on { font-size: 14px; margin-top: 6px; }

/* Zeit-Trenner im Feed (Heute / Gestern / Diese Woche / Aelter) */
.feed-divider {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-3);
  padding: 10px 4px 0;
}
.feed-divider:first-child { padding-top: 0; }

/* Netzwerk-Fehlerzustand im Feed */
.feed-error {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-2);
  font-size: 16px;
}
.feed-error p { margin-bottom: 16px; }
.feed-error-detail { font-size: 13px; color: var(--text-3); }
.feed-error .btn-primary { width: auto; padding: 12px 24px; }

/* Pull-to-Refresh-Indikator */
.ptr {
  height: var(--pull, 0px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
  transition: height .18s ease;
}
.ptr-spinner {
  width: 24px;
  height: 24px;
  margin-bottom: 12px;
  border-radius: 50%;
  border: 2.5px solid var(--accent-weak);
  border-top-color: var(--accent);
  opacity: 0;
  transform: rotate(calc(var(--pull, 0px) / 1px * 3deg));
  transition: opacity .12s;
}
.ptr.visible .ptr-spinner { opacity: .55; }
.ptr.armed .ptr-spinner   { opacity: 1; }
.ptr.refreshing .ptr-spinner {
  opacity: 1;
  animation: ptr-spin .7s linear infinite;
}
@keyframes ptr-spin { to { transform: rotate(360deg); } }

/* Left: Icon circle */
.card-icon-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-weak);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.card-icon-circle svg { display: block; }

/* Right: Content */
.card-content { min-width: 0; }
.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 3px;
}
.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  flex: 1;
  min-width: 0;
}
.card-sub {
  font-size: 14px;
  color: var(--text-3);
  line-height: 1.35;
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.card-meta-left {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--text-4);
  min-width: 0;
  overflow: hidden;
}
.card-meta-left svg { flex-shrink: 0; }
.card-fit-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex-shrink: 0;
  gap: 1px;
}
.card-fit-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-3);
  line-height: 1;
}
.card-fit {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}

/* ── Lozenges ────────────────────────────────────────────── */
.lz {
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 3px 8px;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
}
.lz-go      { background: var(--lz-go-bg);      color: var(--lz-go-text); }
.lz-inv     { background: var(--lz-inv-bg);      color: var(--lz-inv-text); }
.lz-nogo    { background: var(--lz-nogo-bg);     color: var(--lz-nogo-text); }
.lz-new     { background: var(--lz-new-bg);      color: var(--lz-new-text); }
.lz-applied { background: var(--lz-applied-bg);  color: var(--lz-applied-text); }
.lz-meta    { background: var(--lz-meta-bg);     color: var(--lz-meta-text); }

/* ── Floating Bottom Nav ─────────────────────────────────── */
.floating-nav {
  position: fixed;
  bottom: max(16px, calc(env(safe-area-inset-bottom) + 8px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-nav);
  padding: 6px 8px;
  box-shadow: 0 4px 20px rgba(20,22,31,.10);
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 18px;
  border: none;
  border-radius: 18px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: background .15s, color .15s;
  min-width: 60px;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
  justify-content: center;
}
.nav-item:active { opacity: .7; }
.nav-item.active {
  background: var(--accent-weak);
  color: var(--accent);
}
.nav-icon { display: flex; }
.nav-label { font-size: 11px; font-weight: 600; letter-spacing: .2px; }

/* ── Detail Overlay ──────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--page);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 300;
}
.detail-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  /* Safe area for back button — must be clearly below Dynamic Island */
  padding-top: max(16px, env(safe-area-inset-top));
  padding-left:  max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  padding-bottom: 12px;
}
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  padding: 0 4px;
  -webkit-tap-highlight-color: transparent;
}

.detail-body {
  padding: 20px;
  padding-left:  max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
  padding-bottom: max(40px, calc(env(safe-area-inset-bottom) + 20px));
  max-width: 640px;
  margin: 0 auto;
}

/* Fit Ring */
.detail-hero {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
}
.fit-ring {
  position: relative;
  width: 80px;
  height: 80px;
  flex-shrink: 0;
}
.fit-ring svg { display: block; }
.fit-ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.fit-ring-label .fit-num {
  font-size: 24px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}
.fit-ring-label .fit-sub {
  font-size: 10px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.fit-ring-caption {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.4;
  max-width: 200px;
}
.fit-info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--text-3);
  font-size: 10px;
  color: var(--text-3);
  font-style: normal;
  cursor: default;
  vertical-align: middle;
  margin-right: 4px;
}
.detail-hero-text { min-width: 0; }
.detail-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
  margin-bottom: 6px;
}
.detail-agency { font-size: 15px; color: var(--text-2); margin-bottom: 8px; }

/* Meta section */
.meta-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px;
}
.meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.meta-label {
  color: var(--text-3);
  min-width: 80px;
  flex-shrink: 0;
  font-size: 13px;
}
.meta-value { color: var(--text); font-weight: 500; }

/* Skills chips */
.skill-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.skill-chip {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 20px;
  background: var(--lz-meta-bg);
  color: var(--lz-meta-text);
  font-weight: 500;
}

/* Sections in detail */
.detail-section {
  margin-bottom: 20px;
}
.detail-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  margin-bottom: 10px;
}
.draft-text {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px;
  font-size: 15px;
  color: var(--text);
  line-height: 1.6;
  white-space: pre-wrap;
}
.fit-summary-text {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px;
  font-size: 15px;
  color: var(--text-2);
  line-height: 1.6;
}

/* Status segmented control */
.status-seg {
  display: flex;
  gap: 0;
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  overflow: hidden;
  margin-bottom: 16px;
}
.seg-btn {
  flex: 1;
  padding: 10px 4px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  cursor: pointer;
  transition: background .15s, color .15s;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}
.seg-btn.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(20,22,31,.08); }

/* Action buttons */
.action-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-btn);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
  transition: background .15s;
  text-decoration: none;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 20px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}
.btn-secondary:active { background: var(--page); }

/* ── Trends Panel ────────────────────────────────────────── */
.trends-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 12px 16px;
  padding-left:  max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}
.trend-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px;
  box-shadow: var(--shadow-card);
}
.trend-card-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  margin-bottom: 14px;
}
.bar-chart { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: flex; align-items: center; gap: 8px; }
.bar-label { font-size: 13px; color: var(--text-2); min-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 6px; background: var(--page); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 6px; border-radius: 3px; background: var(--accent); }
.bar-fill.gap { background: #F59E0B; }
.bar-fill.danger { background: #EF4444; }
.bar-fill.clr-go    { background: var(--lz-go-text); }
.bar-fill.clr-inv   { background: var(--lz-inv-text); }
.bar-fill.clr-nogo  { background: var(--lz-nogo-text); }
.bar-count { font-size: 12px; color: var(--text-4); min-width: 24px; text-align: right; }
.gap-tag {
  display: inline-block;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--lz-inv-bg);
  color: var(--lz-inv-text);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .3px;
  margin-left: 4px;
  vertical-align: middle;
  white-space: nowrap;
}

/* ── Misc ────────────────────────────────────────────────── */
.error-msg { color: #AE2E24; font-size: 14px; text-align: center; }
.empty-msg  { color: var(--text-4); text-align: center; padding: 48px 20px; font-size: 15px; }
.spinner    { color: var(--text-4); text-align: center; padding: 40px 20px; font-size: 14px; }

/* ── Desktop adjustment ──────────────────────────────────── */
@media (min-width: 600px) {
  .project-list { padding: 4px 20px 8px; }
  .trends-grid  { padding: 12px 20px; }
  .floating-nav { padding: 6px 12px; }
  .nav-item     { padding: 8px 24px; }
}
@media (min-width: 900px) {
  .project-list, .trends-grid { max-width: 680px; margin-left: auto; margin-right: auto; }
}
