/* WORKLOG -- the work-log popover (js/clock/worklog.js).
   Everything for the popover lives here; dialogs.css keeps the 44px clock
   squares (.timer-wrap, .sq-*) that open it. Uses the app's tokens:
   --surface, --surface-alt, --border, --text, --text-muted. */

.log-pop {
  --wl-run: #c0392b;                         /* the timer's red, as on the square */
  --wl-run-bg: rgba(192, 57, 43, .1);
  --wl-new: #2f6fb0;
  --wl-new-bg: rgba(47, 111, 176, .1);
  position: absolute; top: 64px; right: 0; z-index: 60; width: 290px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px;
  box-shadow: 0 3px 12px rgba(0,0,0,.16);
}

/* flex/grid rules below would otherwise beat the hidden attribute */
.log-pop [hidden] { display: none; }

/* ---- mode strip ---- */
.log-mode { display: flex; align-items: center; gap: 6px; font-size: 11px;
  padding: 5px 7px; margin-bottom: 8px; border-radius: 5px;
  background: var(--surface-alt); color: var(--text-muted); }
.log-mode.running { background: var(--wl-run-bg); color: var(--wl-run); font-weight: 500; }
.log-mode i { font-size: 12px; }
.log-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--wl-run);
  flex: 0 0 auto; animation: logPulse 1.6s ease-in-out infinite; }
@keyframes logPulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .log-dot { animation: none; } }

/* ---- the three boxes share one frame ---- */
.log-box { border: 1px solid var(--border); border-radius: 6px; padding: 6px 7px; margin-bottom: 7px; }
.log-box.running { border-color: var(--wl-run); }
.box-head { display: flex; align-items: center; gap: 6px; min-height: 16px; margin-bottom: 5px; }
.box-label { flex: 1; font-size: 9px; color: var(--text-muted); }
.log-box.running .box-label { color: var(--wl-run); }
.box-reset { appearance: none; background: none; border: none; padding: 0 2px; cursor: pointer;
  color: var(--text-muted); line-height: 1; display: flex; align-items: center; }
.box-reset i { font-size: 13px; }
.box-reset:hover { color: var(--text); }
.box-err { font-size: 9px; color: var(--wl-run); min-height: 0; text-align: center; }
.box-err:not(:empty) { padding-top: 4px; }

/* ---- Tracked ---- */
.box-total { display: flex; align-items: baseline; gap: 4px; font-size: 11px; color: var(--text); }
.box-total i { font-size: 10px; color: var(--text-muted); }
.tot-was { color: var(--text-muted); }
.tot-now { font-weight: 500; }
.log-vs { font-size: 9px; color: var(--text-muted); font-weight: 400; }

.log-rows { max-height: 150px; overflow-y: auto; }
.log-row { display: flex; align-items: center; gap: 6px; padding: 3px 4px;
  font-size: 10px; color: var(--text); border-radius: 4px; }
.log-row + .log-row { margin-top: 1px; }
.log-when { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-dur { flex: 0 0 auto; color: var(--text-muted); }
.log-row.running .log-when { color: var(--wl-run); font-style: italic; }
.log-row.new, .log-row.edit { background: var(--wl-new-bg); }
.log-row.new .log-dur, .log-row.edit .log-dur { color: var(--wl-new); }
.log-row.gone .log-when, .log-row.gone .log-dur { color: var(--text-muted); text-decoration: line-through; }
.row-tag { flex: 0 0 auto; width: 30px; text-align: right; font-size: 9px; color: var(--wl-new); }
.row-x, .row-undo { appearance: none; background: none; border: none; padding: 0; cursor: pointer;
  flex: 0 0 auto; width: 30px; text-align: right; font: inherit; font-size: 10px; color: var(--text-muted); }
.row-x:hover { color: var(--wl-run); }
.row-undo { font-size: 9px; text-decoration: underline dashed; text-underline-offset: 2px; }
.row-undo:hover { color: var(--text); }
.row-sp { width: 30px; flex: 0 0 auto; }
.log-more { font-size: 9px; color: var(--text-muted); padding: 4px 0 1px; text-align: center; }

/* ---- the add box: tabs ---- */
.seg { flex: 1; display: flex; padding: 2px; gap: 2px; border-radius: 6px; background: var(--surface-alt); }
.seg-btn { flex: 1; appearance: none; cursor: pointer; font: inherit; font-size: 10px;
  padding: 4px 0; border: 1px solid transparent; border-radius: 4px;
  background: transparent; color: var(--text-muted); white-space: nowrap; }
.seg-btn:hover { color: var(--text); }
.seg-btn.on { background: var(--surface); border-color: var(--border); color: var(--text); font-weight: 500; }
.log-box.running .seg-btn.on { color: var(--wl-run); border-color: var(--wl-run); }
#boxAdd .box-head { margin-bottom: 7px; }

/* ---- Time spent / Adjust start (stepper) ---- */
.log-stepper { display: flex; align-items: center; gap: 6px; }
.step-btn { width: 32px; height: 32px; flex: 0 0 auto; cursor: pointer;
  border: 1px solid var(--border); border-radius: 5px; background: transparent;
  color: var(--text); display: flex; align-items: center; justify-content: center;
  user-select: none; touch-action: none; }
.step-btn i { font-size: 15px; }
.step-btn:hover:not(:disabled) { background: var(--surface-alt); }
.step-btn.pressing { background: var(--surface-alt); border-color: var(--text); }
.step-btn:disabled { opacity: .35; cursor: default; }
.step-val { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 1px; }
.step-num { font-size: 15px; font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; }
.log-box.running .step-num { color: var(--wl-run); }
.step-sub { font-size: 9px; color: var(--text-muted); max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- Exact times ---- */
.sess-row { display: flex; align-items: center; gap: 6px; }
.sess-time { flex: 0 0 auto; font: inherit; font-size: 10px; padding: 5px 3px; min-width: 0;
  border: 1px solid var(--border); border-radius: 5px; background: transparent; color: var(--text); }
.sess-endwrap { display: flex; align-items: flex-start; gap: 1px; flex: 0 0 auto; }
.sess-plus { font-size: 8px; font-weight: 500; color: var(--text-muted); line-height: 1; }
.sess-mid { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column;
  align-items: center; gap: 2px; }
.sess-day { appearance: none; background: none; border: none; padding: 0 1px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 3px; font: inherit; font-size: 9px;
  color: var(--text-muted); border-bottom: 1px dashed var(--border); }
.sess-day i { font-size: 11px; }
.sess-day:hover { color: var(--text); border-bottom-color: var(--text-muted); }
.sess-dayin { position: absolute; left: 50%; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.sess-mid.manual-day .sess-dayin { position: static; width: auto; height: auto; opacity: 1;
  pointer-events: auto; font: inherit; font-size: 9px; }
.sess-mid.manual-day .sess-day { display: none; }

/* ---- footer ---- */
.foot-err { padding: 0 0 4px; }
.log-foot { display: flex; align-items: center; gap: 6px; padding-top: 2px; }
.foot-count { flex: 1; font-size: 9px; color: var(--text-muted); }
.log-foot .btn { font-size: 10px; padding: 4px 12px; }
.log-foot .btn.primary { background: var(--text); color: var(--surface); border-color: var(--text); }

/* ---- focus, everywhere in the popover ---- */
.log-pop button:focus-visible, .log-pop input:focus-visible {
  outline: 2px solid var(--text); outline-offset: 1px; }
