/* ============================================================
   Task Manager — Design tokens
   Palette:
     --ink:      #14181F  (near-black, structure/text)
     --paper:    #F6F5F2  (warm off-white background)
     --panel:    #FFFFFF  (card surface)
     --line:     #DEDAD2  (hairline borders)
     --accent:   #2F5D50  (deep pine — brand/action)
   Status colors (the signature system — every task always shows one):
     --overdue:  #C1443C  (rust red)
     --due:      #C98A2E  (amber)
     --notdue:   #3E7A5B  (moss green)
     --done:     #8A8578  (stone grey)
   Type: "Space Grotesk" for headings/labels (utility, technical),
         system sans for body/data (fast, reliable on any host).
   ============================================================ */

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

:root {
  --ink: #14181F;
  --ink-soft: #4B5160;
  --paper: #F6F5F2;
  --panel: #FFFFFF;
  --line: #DEDAD2;
  --accent: #2F5D50;
  --accent-ink: #FFFFFF;
  --overdue: #C1443C;
  --overdue-bg: #FBEAE8;
  --due: #C98A2E;
  --due-bg: #FCF2E2;
  --notdue: #3E7A5B;
  --notdue-bg: #EAF3ED;
  --done: #8A8578;
  --done-bg: #F0EEE9;
  --radius: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}
h1, h2, h3, .brand, label, th, .btn, .tab {
  font-family: 'Space Grotesk', -apple-system, sans-serif;
}
a { color: var(--accent); text-decoration: none; }

/* ---------- Top bar ---------- */
.topbar {
  background: var(--ink);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 56px;
}
.topbar-search {
  display: flex;
  align-items: center;
  flex: 1 1 180px;
  max-width: 320px;
  background: rgba(255,255,255,0.08);
  border-radius: 8px;
  overflow: hidden;
}
.topbar-search input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: #fff;
  padding: 7px 10px;
  font-size: 0.88rem;
}
.topbar-search input::placeholder { color: #8891A3; }
.topbar-search input:focus { outline: none; }
.topbar-search button {
  background: transparent;
  border: none;
  color: #C7CCD6;
  padding: 7px 10px;
  cursor: pointer;
  font-size: 0.9rem;
}
.navlinks { margin-left: auto; }
.brand {
  color: #fff;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.2px;
}
.topbar-tenant {
  color: #9BA3B4;
  font-weight: 500;
  font-size: 0.82rem;
  align-self: center;
}
.topbar-tenant::before { content: '\00b7\0020'; } /* middle-dot separator */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
}
.navlinks {
  display: flex;
  gap: 18px;
  align-items: center;
}
.navlinks a {
  color: #D9DCE3;
  font-size: 0.92rem;
  font-weight: 500;
  white-space: nowrap;
}
.navlinks a:hover { color: #fff; }

/* ---------- Desktop: two-row top bar ----------
   Row 1: DoDid (left) ... Tenant name (right)
   Row 2: Search (left) ... Nav links (right)
   A phantom full-width flex item (::before) forces the wrap between them. */
@media (min-width: 800px) {
  .topbar-inner::before {
    content: '';
    order: 2;
    flex-basis: 100%;
    height: 0;
  }
  .brand { order: 0; }
  .topbar-tenant { order: 1; margin-left: auto; }
  .topbar-search { order: 3; flex: 0 1 340px; margin-top: 6px; }
  .navlinks { order: 4; margin-left: auto; margin-top: 6px; }
}

@media (max-width: 800px) {
  .menu-toggle { display: block; order: 2; margin-left: auto; }
  .brand { order: 1; }
  .topbar-tenant { order: 1; }
  .topbar-search { order: 3; flex-basis: 100%; max-width: none; }
  .navlinks {
    display: none;
    position: absolute;
    top: 100%; left: 0; right: 0;
    background: var(--ink);
    flex-direction: column;
    align-items: stretch;
    padding: 8px 16px 16px;
    gap: 4px;
  }
  .navlinks.open { display: flex; }
  .navlinks a { padding: 10px 4px; border-bottom: 1px solid #262c38; }
}

/* ---------- App shell / sidebar ----------
   Mobile: sidebar is a full-width block stacked above the content.
   Desktop (>=800px): sidebar becomes a real left column, and the
   Archive link pins to the visual bottom via margin-top:auto. */
.app-shell {
  display: flex;
  flex-direction: column;
  max-width: 1100px;
  margin: 0 auto;
}
.sidebar {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 16px 16px 12px;
  gap: 3px;
  border-bottom: 1px solid var(--line);
}
.sidebar a {
  display: block;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.92rem;
}
.sidebar a:hover { background: #EFEDE8; color: var(--ink); }
.sidebar a.active { background: var(--ink); color: #fff; }
.main-area { flex: 1; min-width: 0; }

.sidebar-divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 12px 4px 4px;
}

.sidebar-section-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink-soft);
  font-weight: 700;
  margin: 14px 14px 4px;
}
.tabs-vertical { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.tab-v {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.tab-v:hover { background: #EFEDE8; color: var(--ink); }
.tab-v.active { background: var(--notdue-bg); color: var(--notdue); }
.sidebar-filter-form { padding: 0 14px 6px; }
.sidebar-filter-form .form-row { margin-bottom: 10px; }
.sidebar-filter-form label { font-size: 0.76rem; }

@media (min-width: 800px) {
  .app-shell { flex-direction: row; align-items: flex-start; }
  .sidebar {
    width: 230px;
    flex-shrink: 0;
    padding: 20px 12px 20px 16px;
    margin-right: 8px;
    border-bottom: none;
    border-right: 1px solid var(--line);
    min-height: calc(100vh - 56px);
  }
}

/* ---------- Layout ---------- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}
.page-head h1 { margin: 0; font-size: 1.5rem; }
.muted { color: var(--ink-soft); font-size: 0.9rem; }

/* ---------- Cards / panels ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}

/* ---------- Status badges (the signature element) ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; }
.badge.overdue { background: var(--overdue-bg); color: var(--overdue); }
.badge.overdue::before { background: var(--overdue); }
.badge.due { background: var(--due-bg); color: var(--due); }
.badge.due::before { background: var(--due); }
.badge.not_due { background: var(--notdue-bg); color: var(--notdue); }
.badge.not_due::before { background: var(--notdue); }
.badge.completed { background: var(--done-bg); color: var(--done); }
.badge.completed::before { background: var(--done); }

/* ---------- Filter bars (Dashboard / Archive / Starred) ---------- */
.filter-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.filter-field { flex: 1; min-width: 160px; }
.filter-submit { flex: 0 0 auto; }

/* ---------- Tabs (status filter) ---------- */
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.tab {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- Task list ---------- */
.task-list { display: flex; flex-direction: column; gap: 10px; }
.task-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.task-card.overdue { border-left-color: var(--overdue); }
.task-card.due { border-left-color: var(--due); }
.task-card.not_due { border-left-color: var(--notdue); }
.task-card.completed { border-left-color: var(--done); opacity: 0.85; }

.task-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.task-desc { font-weight: 600; font-size: 1rem; }
.task-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin-top: 4px;
}
.task-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* ---------- Mobile polish ---------- */
@media (max-width: 640px) {
  .container { padding: 14px 12px 48px; }
  .panel { padding: 14px; }
  .page-head h1 { font-size: 1.25rem; }
  .filter-field { flex-basis: 100%; min-width: 0; }
  .filter-submit { flex-basis: 100%; }
  .filter-submit .btn { width: 100%; }
  .tabs { gap: 6px; }
  .tab { padding: 7px 11px; font-size: 0.8rem; }
  .task-card { padding: 12px; }
  .task-desc { font-size: 0.95rem; }
  .task-meta { font-size: 0.8rem; gap: 10px; }
  .task-actions { gap: 6px; }
  .task-actions .btn { flex: 1 1 auto; }
  .topbar-inner { padding: 12px 12px; gap: 10px 8px; }
  .topbar-search { margin-top: 2px; }
  .topbar-search input { padding: 10px 10px; font-size: 0.92rem; }
  .topbar-search button { padding: 10px 12px; }
  .brand {
    font-size: 1.05rem;
    max-width: calc(100vw - 90px);
    overflow: hidden;
    white-space: nowrap;
  }
  .topbar-tenant {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: calc(100vw - 90px);
  }
}

/* ---------- Forms ---------- */
.form-row { margin-bottom: 14px; }
label { display: block; font-size: 0.82rem; font-weight: 600; margin-bottom: 5px; color: var(--ink-soft); }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
textarea { min-height: 90px; resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Buttons ----------
   One consistent style for every button everywhere: same size, same
   background, regardless of .secondary/.danger/.small/.star-toggle. */
.btn,
.btn.secondary,
.btn.danger,
.btn.small,
.btn.star-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #EFEDE8;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.88rem;
  line-height: 1.1;
  cursor: pointer;
  text-align: center;
}
.btn:hover,
.btn.secondary:hover,
.btn.danger:hover,
.btn.small:hover,
.btn.star-toggle:hover {
  background: #E3E0D8;
}
.btn.star-toggle.starred { color: #8A6A1E; }

/* ---------- Combobox (searchable dropdown) ---------- */
.combo { position: relative; }
.combo-input {
  padding-right: 36px;
  cursor: text;
}
.combo-input:disabled { background: #F0EEE9; color: var(--ink-soft); cursor: not-allowed; }
.combo-toggle {
  position: absolute;
  right: 4px;
  top: 4px;
  bottom: 4px;
  width: 30px;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.8rem;
  cursor: pointer;
  border-radius: 6px;
}
.combo-toggle:hover { background: #EFEDE8; }
.combo-input:disabled ~ .combo-toggle { display: none; }
.combo-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(20,24,31,0.12);
  z-index: 40;
}
.combo-option {
  padding: 9px 12px;
  font-size: 0.92rem;
  cursor: pointer;
}
.combo-option:hover, .combo-option.active { background: #EFEDE8; }
.combo-empty { padding: 9px 12px; font-size: 0.88rem; color: var(--ink-soft); }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
th { color: var(--ink-soft); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.4px; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
}
.login-box {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
}
.login-box h1 { text-align: center; margin-top: 0; font-size: 1.3rem; }

/* ---------- Tags ---------- */
.tag-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #EFEDE8;
  color: var(--ink-soft);
  margin-right: 5px;
  margin-top: 6px;
}

/* ---------- Timeline ---------- */
.timeline-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.timeline-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 6px; flex-shrink: 0; }
.timeline-text { font-size: 0.92rem; }
.timeline-time { color: var(--ink-soft); font-size: 0.8rem; }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 0.9rem; }
.alert.error { background: var(--overdue-bg); color: var(--overdue); }
.alert.success { background: var(--notdue-bg); color: var(--notdue); }

/* ---------- AJAX navigation transitions ---------- */
#appShell {
  opacity: 1;
  transition: opacity 0.16s ease;
}
#appShell.ajax-fade-out { opacity: 0.35; }
#appShell.ajax-fade-in { opacity: 0; }
body.ajax-loading .main-area { cursor: progress; }
body.ajax-loading .topbar-search input { cursor: progress; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---- Added for the Projects / private-fields rework ---- */
.personal-box {
  border: 1px dashed #d8d3c4;
  border-radius: 10px;
  padding: 14px;
  background: #faf8f3;
  margin: 14px 0;
}
.personal-box-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #b6791f;
  margin-bottom: 10px;
  font-weight: 600;
}
.swatch-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.swatch {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer; display: inline-block;
}
.swatch.selected { border-color: #14161a; box-shadow: 0 0 0 2px #fff inset; }
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px; font-size: 0.72rem; font-weight: 600;
}
.pill-dot { width: 6px; height: 6px; border-radius: 50%; display:inline-block; }
.project-chip {
  background: #e5efe6; color: #3a6b46; padding: 1px 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 600;
}
.chat-thread { max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.chat-msg-author { font-size: 0.78rem; font-weight: 700; }
.chat-msg-time { font-size: 0.68rem; color: #8a8578; font-weight: 400; margin-left: 6px; }
.chat-msg-body { font-size: 0.85rem; background: #f4f1e8; padding: 7px 10px; border-radius: 8px; margin-top: 2px; }
.btn.tiny { padding: 3px 9px; font-size: 0.72rem; }
.project-select-notice { padding: 40px 20px; text-align: center; color: #8a8578; }
.color-dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.filter-bar { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }

/* ---------- Project switcher + new-project icon (top bar) ---------- */
.project-switcher {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  order: 1;
}
.project-switcher select {
  background: var(--ink);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 0.85rem;
  max-width: 220px;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.95rem;
  text-decoration: none;
  flex-shrink: 0;
}
.icon-btn:hover { opacity: 0.85; }

/* ---------- Project-level tab bar (Tasks / Members / Export / Activity) ---------- */
.project-tabbar {
  display: flex;
  gap: 4px;
  padding: 10px 20px 0;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex-wrap: wrap;
}
.project-tabbar a {
  padding: 8px 14px;
  border-radius: 8px 8px 0 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
  text-decoration: none;
}
.project-tabbar a:hover { background: #EFEDE8; }
.project-tabbar a.active { background: var(--accent); color: #fff; }

@media (min-width: 800px) {
  .brand { order: 0; }
  .project-switcher { order: 1; }
  .topbar-inner::before { content: ''; order: 2; flex-basis: 100%; height: 0; }
  .topbar-search { order: 3; flex: 0 1 340px; margin-top: 6px; }
  .navlinks { order: 4; margin-left: auto; margin-top: 6px; }
}

@media (max-width: 800px) {
  .brand { order: 1; }
  .menu-toggle { order: 2; }
  .project-switcher {
    order: 3;
    flex-basis: 100%;
    margin-left: 0;
    justify-content: space-between;
  }
  .project-switcher select { flex: 1; max-width: none; }
  .topbar-search { order: 4; }
}

@media (max-width: 640px) {
  .project-tabbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 12px 0;
  }
  .project-tabbar a { white-space: nowrap; flex-shrink: 0; font-size: 0.8rem; padding: 7px 10px; }
  /* Wide tables (Members, Settings lists) scroll horizontally instead of
     breaking the page layout. */
  .panel { overflow-x: auto; }
  .panel table { min-width: 420px; }
}

