/* Task Tracker — Component styles
 * Depends on tokens.css. Vanilla CSS for a PHP/jQuery server-rendered admin panel.
 */

/* ============================ App shell ============================ */
.app-shell { display: grid; grid-template-columns: var(--sidebar-width) 1fr; min-height: 100vh; }
.app-shell.is-collapsed { grid-template-columns: var(--sidebar-collapsed) 1fr; }
.main { display: flex; flex-direction: column; min-width: 0; }
.content { padding: var(--space-xl); max-width: var(--content-max); width: 100%; margin: 0 auto; }

/* ============================ Sidebar ============================ */
.sidebar {
  position: sticky; top: 0; align-self: start; height: 100vh;
  background: var(--ink); color: var(--n-300);
  display: flex; flex-direction: column; z-index: var(--z-sidebar);
}
.sidebar__brand {
  display: flex; align-items: center; gap: var(--space-sm);
  height: var(--topbar-height); padding: 0 var(--space-base);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar__brand img { width: 30px; height: 30px; object-fit: contain;
  /* W logo is black-on-white; invert so it reads on the dark rail */
  filter: invert(1); border-radius: var(--radius-xs); }
.sidebar__brand-name { font-family: var(--font-display); font-weight: var(--fw-bold);
  font-size: var(--fs-lg); color: #fff; letter-spacing: -0.02em; }
.sidebar__nav { padding: var(--space-md) var(--space-sm); overflow-y: auto; flex: 1; }
.sidebar__section { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--n-500); padding: var(--space-md) var(--space-sm) var(--space-xs); }
.nav-item {
  display: flex; align-items: center; gap: var(--space-md);
  padding: 9px var(--space-md); border-radius: var(--radius-md);
  color: var(--n-300); font-size: var(--fs-sm); font-weight: var(--fw-medium);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  position: relative;
}
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; text-decoration: none; }
.nav-item.is-active { background: rgba(255,255,255,0.10); color: #fff; }
.nav-item.is-active::before {
  content: ""; position: absolute; left: -8px; top: 8px; bottom: 8px; width: 3px;
  background: var(--accent); border-radius: var(--radius-pill);
}

/* ============================ Topbar ============================ */
.topbar {
  position: sticky; top: 0; z-index: var(--z-topbar);
  height: var(--topbar-height); background: rgba(251,250,248,0.85);
  backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--space-base);
  padding: 0 var(--space-xl);
}
.topbar__title { font-family: var(--font-display); font-weight: var(--fw-semibold); font-size: var(--fs-lg); }
.topbar__spacer { flex: 1; }
.topbar__user { display: flex; align-items: center; gap: var(--space-sm); }

/* ---- Persistent timer widget (lives in topbar, on every screen) ---- */
.timer-widget {
  display: flex; align-items: center; gap: var(--space-md);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-pill); padding: 5px 6px 5px var(--space-base);
  box-shadow: var(--elev-1);
}
.timer-widget__desc { font-size: var(--fs-sm); color: var(--on-surface-muted);
  max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer-widget__elapsed {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-weight: var(--fw-semibold); font-size: var(--fs-md); letter-spacing: 0.02em;
  color: var(--ink); min-width: 76px; text-align: right;
}
.timer-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius-pill); border: none;
  transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.timer-btn svg { width: 16px; height: 16px; }
.timer-btn--start { background: var(--success); color: #fff; }
.timer-btn--start:hover { background: #128a3f; }
.timer-btn--stop { background: var(--danger); color: #fff; }
.timer-btn--stop:hover { background: #bb1f1f; }
.timer-btn:active { transform: scale(0.94); }
/* Pulsing dot when running */
.timer-widget.is-running { border-color: var(--success); }
.timer-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.timer-widget.is-running .timer-dot { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; box-shadow: 0 0 0 0 rgba(21,163,74,0.4);} 50% { opacity:.6; box-shadow: 0 0 0 5px rgba(21,163,74,0);} }

/* ============================ Page header ============================ */
.page-header { display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--space-base); margin-bottom: var(--space-xl); flex-wrap: wrap; }
.page-title { font-family: var(--font-display); font-size: var(--fs-2xl); font-weight: var(--fw-bold);
  letter-spacing: -0.02em; }
.page-subtitle { color: var(--on-surface-muted); font-size: var(--fs-sm); margin-top: 2px; }
.breadcrumb { display: flex; gap: var(--space-xs); font-size: var(--fs-xs); color: var(--on-surface-faint); margin-bottom: var(--space-sm); }
.breadcrumb a { color: var(--on-surface-faint); }
.breadcrumb span::after { content: "/"; margin-left: var(--space-xs); color: var(--border-strong); }

/* ============================ Cards ============================ */
.card { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--elev-1); }
.card__header { display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-base) var(--card-padding); border-bottom: 1px solid var(--border); }
.card__title { font-family: var(--font-display); font-size: var(--fs-md); font-weight: var(--fw-semibold); }
.card__body { padding: var(--card-padding); }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--grid-gap); }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: var(--space-lg); box-shadow: var(--elev-1);
  transition: box-shadow var(--t-base) var(--ease), border-color var(--t-base) var(--ease);
}
.kpi:hover { box-shadow: var(--elev-2); border-color: var(--border-strong); }
.kpi__label { font-size: var(--fs-xs); color: var(--on-surface-muted); text-transform: uppercase;
  letter-spacing: 0.05em; font-weight: var(--fw-medium); display: flex; align-items: center; gap: var(--space-xs); }
.kpi__value { font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: var(--fs-3xl); font-weight: var(--fw-bold); color: var(--ink); margin-top: var(--space-sm); line-height: 1; }
.kpi__delta { font-size: var(--fs-xs); margin-top: var(--space-sm); display: inline-flex; gap: 3px; align-items: center; }
.kpi__delta.is-up { color: var(--success); }
.kpi__delta.is-down { color: var(--danger); }

/* ============================ Buttons ============================ */
.btn {
  display: inline-flex; align-items: center; gap: var(--space-sm);
  height: 38px; padding: 0 var(--space-base); border-radius: var(--radius-md);
  font-size: var(--fs-sm); font-weight: var(--fw-semibold); border: 1px solid transparent;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn--primary { background: var(--ink); color: var(--on-ink); }
.btn--primary:hover { background: var(--ink-soft); text-decoration: none; }
.btn--primary:active { background: var(--ink-press); }
.btn--accent { background: var(--accent); color: var(--on-accent); }
.btn--accent:hover { background: var(--accent-hover); text-decoration: none; }
.btn--secondary { background: var(--surface); color: var(--on-surface); border-color: var(--border-strong); }
.btn--secondary:hover { background: var(--surface-hover); text-decoration: none; }
.btn--ghost { background: transparent; color: var(--on-surface-muted); }
.btn--ghost:hover { background: var(--surface-sunken); color: var(--on-surface); text-decoration: none; }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: #bb1f1f; text-decoration: none; }
.btn--sm { height: 30px; padding: 0 var(--space-md); font-size: var(--fs-xs); }
.btn--icon { width: 38px; padding: 0; justify-content: center; }
.btn[disabled], .btn.is-loading { opacity: 0.6; cursor: not-allowed; pointer-events: none; }
.btn.is-loading::after { content: ""; width: 14px; height: 14px; border: 2px solid currentColor;
  border-right-color: transparent; border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================ Chips / badges ============================ */
.chip { display: inline-flex; align-items: center; gap: var(--space-xs);
  padding: 2px var(--space-sm); border-radius: var(--radius-pill);
  font-size: var(--fs-xs); font-weight: var(--fw-medium); line-height: 1.6; white-space: nowrap; }
.chip--success { background: var(--success-soft); color: #0f7a37; }
.chip--danger  { background: var(--danger-soft);  color: #a51d1d; }
.chip--warning { background: var(--warning-soft); color: #92560a; }
.chip--info    { background: var(--info-soft);    color: var(--accent-hover); }
.chip--neutral { background: var(--surface-sunken); color: var(--on-surface-muted); }
.chip--dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Role badges */
.badge-role { font-size: var(--fs-2xs); font-weight: var(--fw-semibold); text-transform: uppercase;
  letter-spacing: 0.04em; padding: 2px var(--space-sm); border-radius: var(--radius-sm); }
.badge-role--admin  { background: var(--role-admin-soft);  color: var(--role-admin); }
.badge-role--rm     { background: var(--role-rm-soft);     color: var(--role-rm); }
.badge-role--member { background: var(--role-member-soft); color: var(--role-member); }

/* Project color dot */
.proj-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }

/* Avatar */
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft);
  color: var(--accent-hover); display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--fs-xs); font-weight: var(--fw-semibold); }

/* Overlapping avatar stack */
.avatar-stack { display: inline-flex; align-items: center; }
.avatar-stack .avatar, .avatar-stack img.avatar { border: 2px solid var(--surface); margin-left: -8px; }
.avatar-stack .avatar:first-child, .avatar-stack img.avatar:first-child { margin-left: 0; }
.avatar-stack .avatar-more { width: 26px; height: 26px; border-radius: 50%; margin-left: -8px;
  border: 2px solid var(--surface); background: var(--surface-sunken); color: var(--on-surface-muted);
  display: inline-flex; align-items: center; justify-content: center; font-size: var(--fs-2xs); font-weight: var(--fw-semibold); }

/* ============================ Tables (DataTables-friendly) ============================ */
.data-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.data-table thead th {
  position: sticky; top: 0; background: var(--surface-sunken); z-index: var(--z-sticky);
  text-align: left; font-size: var(--fs-xs); font-weight: var(--fw-semibold);
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--on-surface-muted);
  padding: var(--space-md) var(--card-padding); border-bottom: 1px solid var(--border);
}
.data-table tbody td { padding: 0 var(--card-padding); height: var(--table-row-height);
  border-bottom: 1px solid var(--border); color: var(--on-surface); vertical-align: middle; }
.data-table tbody tr { transition: background var(--t-fast) var(--ease); }
.data-table tbody tr:hover { background: var(--surface-hover); }
.data-table tbody tr.is-selected { background: var(--accent-soft); }
.data-table td.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }

/* ============================ Forms ============================ */
.field { margin-bottom: var(--space-base); }
.field label { display: block; font-size: var(--fs-xs); font-weight: var(--fw-semibold);
  color: var(--on-surface-muted); margin-bottom: var(--space-xs); }
.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 var(--space-md);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-md); color: var(--on-surface); font-size: var(--fs-sm);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.textarea { height: auto; min-height: 84px; padding: var(--space-sm) var(--space-md); line-height: var(--lh-base); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--elev-focus); }
.input::placeholder { color: var(--on-surface-faint); }
.field__hint { font-size: var(--fs-xs); color: var(--on-surface-faint); margin-top: var(--space-xs); }
.field__error { font-size: var(--fs-xs); color: var(--danger); margin-top: var(--space-xs); }
.field.has-error .input, .field.has-error .select { border-color: var(--danger); }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-base); }

/* ============================ Weekly timesheet grid ============================ */
.timesheet { border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; background: var(--surface); }
.ts-toolbar { display: flex; align-items: center; gap: var(--space-md);
  padding: var(--space-md) var(--card-padding); border-bottom: 1px solid var(--border); }
.ts-week { font-family: var(--font-display); font-weight: var(--fw-semibold); }
.ts-grid { display: grid; grid-template-columns: minmax(220px, 1.4fr) repeat(7, 1fr) 96px; }
.ts-grid > div { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border);
  padding: var(--space-sm) var(--space-md); min-height: 44px; display: flex; align-items: center; font-size: var(--fs-sm); }
.ts-head { background: var(--surface-sunken); font-size: var(--fs-xs); font-weight: var(--fw-semibold);
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--on-surface-muted); justify-content: center; }
.ts-head.is-today { color: var(--accent); background: var(--accent-soft); }
.ts-head.is-weekend { color: var(--on-surface-faint); }
.ts-task { font-weight: var(--fw-medium); gap: var(--space-sm); }
.ts-cell { justify-content: center; font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  color: var(--on-surface); cursor: text; transition: background var(--t-fast) var(--ease); }
.ts-cell:hover { background: var(--accent-soft); }
.ts-cell.is-empty { color: var(--on-surface-faint); }
.ts-cell input { width: 100%; border: none; background: transparent; text-align: center;
  font-family: var(--font-mono); font-size: var(--fs-sm); }
.ts-cell input:focus { outline: none; box-shadow: var(--elev-focus); border-radius: var(--radius-sm); }
.ts-total { justify-content: flex-end; font-family: var(--font-mono); font-weight: var(--fw-semibold); }
.ts-grid .ts-foot { background: var(--surface-sunken); font-weight: var(--fw-bold); }

/* ============================ Charts ============================ */
.chart-card { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--card-padding); box-shadow: var(--elev-1); }
.chart-card__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-base); }
.chart-canvas-wrap { position: relative; height: 280px; }

/* ============================ Empty / loading ============================ */
.empty { text-align: center; padding: var(--space-3xl) var(--space-base); color: var(--on-surface-muted); }
.empty svg { width: 44px; height: 44px; color: var(--border-strong); margin-bottom: var(--space-md); }
.empty__title { font-family: var(--font-display); font-weight: var(--fw-semibold); color: var(--on-surface); margin-bottom: var(--space-xs); }
.skeleton { background: linear-gradient(90deg, var(--n-100) 25%, var(--n-150) 37%, var(--n-100) 63%);
  background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ============================ Approval queue (leave) ============================ */
.approval-row { display: flex; align-items: center; gap: var(--space-base);
  padding: var(--space-md) var(--card-padding); border-bottom: 1px solid var(--border); }
.approval-row__meta { flex: 1; min-width: 0; }
.approval-row__name { font-weight: var(--fw-semibold); }
.approval-row__dates { font-size: var(--fs-xs); color: var(--on-surface-muted); font-family: var(--font-mono); }
.approval-actions { display: flex; gap: var(--space-sm); }

/* ============================ Layout helpers ============================ */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--grid-gap); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--grid-gap); }
.row { display: flex; align-items: center; gap: var(--space-sm); }
.row--between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: var(--space-base); }
.muted { color: var(--on-surface-muted); }
.text-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.mt-lg { margin-top: var(--space-lg); } .mb-lg { margin-bottom: var(--space-lg); }

/* ============================ Toast ============================ */
.toast-stack { position: fixed; bottom: var(--space-lg); right: var(--space-lg); z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: var(--space-sm); }
.toast { background: var(--ink); color: #fff; padding: var(--space-md) var(--space-base);
  border-radius: var(--radius-md); box-shadow: var(--elev-3); font-size: var(--fs-sm);
  display: flex; align-items: center; gap: var(--space-sm); animation: toastin var(--t-slow) var(--ease); }
@keyframes toastin { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ============================ Modal ============================ */
.modal-overlay { position: fixed; inset: 0; background: rgba(22,22,26,.45); z-index: var(--z-modal);
  display: none; place-items: center; padding: var(--space-base); }
.modal-overlay.is-open { display: grid; animation: fadein var(--t-base) var(--ease); }
.modal-overlay .card { width: 460px; max-width: 94vw; animation: popin var(--t-base) var(--ease); }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes popin { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }

/* ============================ Timer picker popover ============================ */
.timer-pop {
  position: absolute; top: calc(var(--topbar-height) - 6px); right: var(--space-xl);
  width: 380px; max-width: 92vw; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--elev-3); z-index: var(--z-dropdown);
  display: none; overflow: hidden;
}
.timer-pop.is-open { display: block; animation: popin var(--t-base) var(--ease); }
.timer-pop__head { display: flex; gap: var(--space-sm); padding: var(--space-sm); border-bottom: 1px solid var(--border); }
.timer-pop__tabs { display: flex; gap: var(--space-xs); }
.timer-pop__tab { padding: 6px 12px; border-radius: var(--radius-md); font-size: var(--fs-xs);
  font-weight: var(--fw-semibold); color: var(--on-surface-muted); background: transparent; border: none; }
.timer-pop__tab.is-active { background: var(--ink); color: #fff; }
.timer-pop__body { max-height: 340px; overflow-y: auto; padding: var(--space-sm); }
.timer-pop__search { margin: 0 0 var(--space-sm); }
.task-pick {
  display: flex; align-items: center; gap: var(--space-sm); width: 100%;
  padding: 9px var(--space-sm); border-radius: var(--radius-md); border: none; background: transparent;
  text-align: left; font-size: var(--fs-sm); color: var(--on-surface);
  transition: background var(--t-fast) var(--ease);
}
.task-pick:hover { background: var(--surface-hover); }
.task-pick__name { font-weight: var(--fw-medium); }
.task-pick__proj { font-size: var(--fs-xs); color: var(--on-surface-muted); margin-left: auto; }
.timer-pop__empty { padding: var(--space-lg); text-align: center; color: var(--on-surface-muted); font-size: var(--fs-sm); }

/* Inline start/stop button used in task lists + popover */
.btn-timer { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; padding: 0 12px; border-radius: var(--radius-pill); font-size: var(--fs-xs);
  font-weight: var(--fw-semibold); border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--on-surface); transition: all var(--t-fast) var(--ease); }
.btn-timer svg { width: 13px; height: 13px; }
.btn-timer:hover { border-color: var(--success); color: var(--success); }
.btn-timer.is-running { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-timer.is-running:hover { background: #bb1f1f; color: #fff; }

/* ============================ Responsive ============================ */
@media (max-width: 1024px) {
  .app-shell { grid-template-columns: var(--sidebar-collapsed) 1fr; }
  .form-grid, .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .content { padding: var(--space-base); }
  .timer-widget__desc { display: none; }
  .ts-grid { font-size: var(--fs-xs); }
}
