/* ── Timesheet ────────────────────────────────────────────────
   Page-specific components for the time-tracking feature.
   All selectors namespaced with ts- to avoid collisions.
   ─────────────────────────────────────────────────────────── */

/* ── Form panel ── */

.ts-form-panel {
  background: #ffffff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 24px 28px;
  margin-top: 28px;
  margin-bottom: 28px;
}

/* ── Entry input row — single flex row ── */

.ts-input-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.ts-field-description {
  flex: 1 1 220px;
}

.ts-field-project {
  flex: 0 0 160px;
}

.ts-field-tags {
  flex: 0 0 140px;
}

.ts-field-time {
  flex: 0 0 96px;
}

/* Time separator — aligned with inputs */
.ts-time-sep {
  color: var(--ink-soft);
  font-size: 14px;
  flex-shrink: 0;
  align-self: flex-end;
  padding-bottom: 10px;
}

/* Date + Add column */
.ts-field-date-add {
  flex: 0 0 auto;
}

.ts-date-add-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ts-form-panel input[type="date"] {
  width: 148px;
}

/* ── Input styling within the form panel ── */

.ts-form-panel input[type="text"],
.ts-form-panel input[type="time"],
.ts-form-panel input[type="date"],
.ts-form-panel select {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--blue-200);
  background: #ffffff;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  transition: border-color 140ms ease, box-shadow 140ms ease;
  box-sizing: border-box;
}

.ts-form-panel input[type="text"]:focus,
.ts-form-panel input[type="time"]:focus,
.ts-form-panel input[type="date"]:focus,
.ts-form-panel select:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.16);
}

.ts-field-description > label,
.ts-field-project > label,
.ts-field-tags > label,
.ts-field-time > label,
.ts-field-date-add > label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--blue-700);
  margin-bottom: 5px;
}

/* ── Tag dropdown ── */

.ts-tag-dropdown {
  position: relative;
}

.ts-tag-dropdown__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--blue-200);
  background: #ffffff;
  font-size: 14px;
  color: var(--ink-soft);
  cursor: pointer;
  list-style: none;
  user-select: none;
  white-space: nowrap;
  min-width: 150px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.ts-tag-dropdown__trigger::-webkit-details-marker {
  display: none;
}

.ts-tag-dropdown[open] .ts-tag-dropdown__trigger {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.16);
}

.ts-tag-dropdown__panel {
  display: none;
  flex-direction: column;
  gap: 2px;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 250px;
  background: #ffffff;
  border: 1px solid var(--blue-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: 1000;
  max-height: 220px;
  overflow-y: auto;
}

.ts-tag-dropdown[open] .ts-tag-dropdown__panel {
  display: flex;
}

/* Tag search input inside the panel */
.ts-tag-search {
  display: block;
  width: 100%;
  padding: 7px 10px !important;
  font-size: 13px !important;
  border-radius: var(--radius-sm) !important;
  border: 1px solid var(--blue-100) !important;
  background: var(--blue-50) !important;
  margin-bottom: 4px;
  box-sizing: border-box;
}

.ts-tag-search:focus {
  outline: none;
  border-color: var(--blue-400) !important;
  box-shadow: none !important;
  background: #fff !important;
}

.ts-tag-options {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.ts-tag-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  transition: background 100ms ease;
  line-height: 1.4;
}

.ts-tag-option:hover {
  background: var(--blue-50);
}

.ts-tag-option input[type="checkbox"] {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  margin: 0;
  accent-color: var(--blue-600);
  cursor: pointer;
  position: relative;
  top: 0;
}

.ts-tag-option span {
  line-height: 1;
}

.ts-tag-dropdown__empty {
  font-size: 12px;
  color: var(--ink-soft);
  padding: 6px 8px;
  font-style: italic;
}

/* ── Add button ── */

.ts-btn-add {
  background: var(--blue-600);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.2);
  transition: background 140ms ease, transform 100ms ease;
  white-space: nowrap;
}

.ts-btn-add:hover {
  background: var(--blue-700);
  transform: translateY(-1px);
}

/* ── Week section card ── */

.ts-week-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  margin-bottom: 20px;
}

.ts-week-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: var(--blue-50);
  border-bottom: 1px solid var(--blue-100);
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
}

.ts-week-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--blue-700);
  margin: 0;
}

.ts-week-total {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--blue-700);
}

.ts-week-body {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Day group subsection ── */

.ts-day-group {
  border: 1px solid var(--blue-100);
  border-radius: var(--radius-md);
}

.ts-day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--blue-100);
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
}

.ts-day-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--blue-900);
  margin: 0;
}

.ts-day-total {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  font-weight: 600;
}

/* ── Entry list ── */

.ts-entry-list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
}

/* ── Individual entry row ── */

.ts-entry {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--blue-50);
  transition: background 120ms ease;
  position: relative;
}

.ts-entry form {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.ts-entry:last-child {
  border-bottom: none;
}

.ts-entry:hover {
  background: #f5f9ff;
}

.ts-entry:has(details[open]) {
  z-index: 50;
}

.ts-entry:hover .ts-entry__actions {
  opacity: 1;
}

/* Description column */

.ts-entry__description {
  flex: 2 1 180px;
  min-width: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ts-entry__description.is-empty {
  color: var(--ink-soft);
  font-style: italic;
}

/* Project + tags column */

.ts-entry__meta {
  flex: 2 1 160px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.ts-project-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  white-space: nowrap;
}

.ts-entry-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--blue-50);
  border: 1px solid var(--blue-100);
  color: var(--blue-700);
  font-size: 11px;
  font-weight: 600;
}

/* Time range + duration + calendar column */

.ts-entry__time {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-soft);
  white-space: nowrap;
}

.ts-entry__range-icon {
  width: 14px;
  height: 14px;
  color: var(--blue-400, #60a5fa);
  flex-shrink: 0;
}

.ts-entry__duration {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 14px;
  color: var(--blue-900);
  min-width: 72px;
  text-align: right;
}

/* Action buttons column */

.ts-entry__actions {
  flex-shrink: 0;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 150ms ease;
}

.ts-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  color: var(--ink-soft);
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.ts-action-btn form {
  display: contents;
}

.ts-action-btn:hover {
  background: var(--blue-50);
  border-color: var(--blue-200);
  color: var(--blue-700);
}

.ts-action-btn--danger:hover {
  background: #fff1f2;
  border-color: #fecdd3;
  color: var(--red-500);
}

/* ── Inline editing — ghost inputs ── */

.ts-inline-input {
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 3px 6px;
  width: 100%;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ts-inline-input.is-empty {
  color: var(--ink-soft);
  font-style: italic;
}

.ts-inline-input:hover {
  border-color: var(--blue-100);
  background: var(--blue-50);
}

.ts-inline-input:focus {
  outline: none;
  border-color: var(--blue-400);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
  font-style: normal;
  color: var(--ink);
  text-overflow: clip;
  overflow: visible;
}

/* ── Inline time input — ghost, compact ── */

.ts-inline-time {
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 3px 4px;
  font: inherit;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  box-sizing: border-box;
  width: 110px;
}

.ts-inline-time:hover {
  border-color: var(--blue-100);
  background: var(--blue-50);
}

.ts-inline-time:focus {
  outline: none;
  border-color: var(--blue-400);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
  color: var(--ink);
}

.ts-time-sep-inline {
  color: var(--ink-soft);
  font-size: 13px;
  flex-shrink: 0;
}

/* ── Inline project select — ghost badge ── */

.ts-inline-project-wrap {
  position: relative;
}

.ts-inline-project-select {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--project-bg);
  color: var(--project-color);
  border: 1px solid var(--project-border);
  border-radius: var(--radius-pill);
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  font-family: inherit;
  cursor: pointer;
  max-width: 150px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: box-shadow 120ms ease;
}

.ts-inline-project-select:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* ── Inline tag trigger — shows pills, not a text label ── */

.ts-tag-trigger--inline {
  padding: 3px 6px;
  min-width: unset;
  font-size: 13px;
  gap: 4px;
  flex-wrap: wrap;
  color: var(--ink);
  border: 1px solid transparent;
  transition: border-color 120ms ease, background 120ms ease;
}

.ts-tag-trigger--inline:hover {
  border-color: var(--blue-100);
  background: var(--blue-50);
}

.ts-no-tag-hint {
  color: var(--ink-soft);
  font-size: 12px;
}

/* ── Calendar button ── */

.ts-calendar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--blue-300, #93c5fd);
  padding: 3px;
  border-radius: var(--radius-sm);
  transition: color 120ms ease, background 120ms ease;
  flex-shrink: 0;
}

.ts-calendar-btn:hover {
  color: var(--blue-600);
  background: var(--blue-50);
}

.ts-calendar-wrap {
  position: relative;
  display: inline-flex;
}

/* Hidden date input — triggered by the calendar button via showPicker() */
.ts-hidden-date-input {
  position: absolute;
  top: 100%;
  right: 0;
  width: 0;
  height: 0;
  opacity: 0;
  border: none;
  padding: 0;
  pointer-events: none;
}

/* ── Inline error bar ── */

.ts-entry-error-bar {
  width: 100%;
  font-size: 12px;
  color: var(--red-500);
  padding: 4px 0 6px;
}

/* ── Add form error ── */

.ts-form-error {
  color: var(--red-600);
  background: var(--red-50);
  border: 1px solid var(--red-200);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 20px;
}

.ts-form-notif {
  color: var(--blue-700);
  background: var(--blue-50);
  border: 1px solid var(--blue-200);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Responsive ── */

@media (max-width: 768px) {
  .ts-input-row {
    flex-direction: column;
  }

  .ts-field-project,
  .ts-field-tags,
  .ts-field-time,
  .ts-field-date-add {
    flex: 1 1 100%;
  }

  .ts-time-sep {
    display: none;
  }

  .ts-entry {
    flex-wrap: wrap;
  }

  .ts-entry__actions {
    opacity: 1;
  }
}

/* ── Pagination ── */

.ts-pagination-wrap {
  display: flex;
  justify-content: center;
  padding: 24px 0;
  margin-top: 10px;
}

.ts-pagination-wrap nav {
  display: flex;
  gap: 6px;
}

.ts-pagination-wrap a, 
.ts-pagination-wrap span.page,
.ts-pagination-wrap span.first,
.ts-pagination-wrap span.last,
.ts-pagination-wrap span.next,
.ts-pagination-wrap span.prev {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--blue-100);
  background: #ffffff;
  color: var(--blue-700);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: all 140ms ease;
}

.ts-pagination-wrap a:hover {
  background: var(--blue-50);
  border-color: var(--blue-300);
  transform: translateY(-1px);
}

.ts-pagination-wrap .current {
  background: var(--blue-600);
  color: #ffffff;
  border-color: var(--blue-600);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.ts-pagination-wrap .gap {
  border: none;
  background: none;
  color: var(--ink-soft);
}

/* ── Mode toggle (Manual / Timer) ── */

.ts-mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--blue-50);
  border: 1px solid var(--blue-100);
  border-radius: var(--radius-pill);
  padding: 3px;
  margin-bottom: 16px;
}

.ts-mode-btn {
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  border: none;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--blue-600);
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.ts-mode-btn--active {
  background: #ffffff;
  color: var(--blue-900);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.10);
}

/* ── Start Timer button ── */

.ts-btn-start-timer {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #16a34a;
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(22, 163, 74, 0.25);
  transition: background 140ms ease, transform 100ms ease;
  white-space: nowrap;
}

.ts-btn-start-timer:hover {
  background: #15803d;
  transform: translateY(-1px);
}

/* ── Active timer panel ── */

.ts-active-timer-panel {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding: 18px 24px;
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border: 1px solid #86efac;
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 16px rgba(22, 163, 74, 0.10);
  margin-top: 28px;
  margin-bottom: 28px;
}

.ts-active-timer-header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.ts-active-timer-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #dcfce7;
  border: 1px solid #86efac;
  color: #15803d;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}

.ts-active-timer-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #16a34a;
  animation: ts-pulse 1.4s ease-in-out infinite;
}

@keyframes ts-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.85); }
}

.ts-active-timer-display {
  font-size: 28px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: #15803d;
  font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, monospace;
}

.ts-active-timer-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 200px;
  min-width: 0;
}

.ts-active-timer-desc {
  font-size: 14px;
  font-weight: 600;
  color: #166534;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ts-active-timer-sep {
  color: #86efac;
  font-size: 14px;
  flex-shrink: 0;
}

.ts-active-timer-project {
  font-size: 13px;
  color: #15803d;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Stop Timer button ── */

.ts-btn-stop-timer {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #dc2626;
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
  transition: background 140ms ease, transform 100ms ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.ts-btn-stop-timer:hover {
  background: #b91c1c;
  transform: translateY(-1px);
}

/* ── Locked entry styles ───────────────────────────────────────────── */
.ts-entry--locked {
  opacity: 0.65;
}

.ts-entry--locked .ts-entry__description-text {
  color: var(--gray-500, #6b7280);
  font-size: 0.875rem;
}

.ts-locked-project {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid;
}

.ts-locked-time {
  font-size: 0.8125rem;
  color: var(--gray-500, #6b7280);
  font-variant-numeric: tabular-nums;
}

.ts-lock-icon {
  display: inline-flex;
  align-items: center;
  color: var(--gray-400, #9ca3af);
  margin-left: 4px;
  cursor: default;
}
