/* ─────────────────────────────────────────────────────────────────────────
 * Components — Cards, Tasks, Forms, Buttons, Badges, etc.
 * ───────────────────────────────────────────────────────────────────────── */

/* ── Card ── */
.card {
  background: var(--bg2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 12px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: .5px solid var(--separator);
  cursor: pointer;
  user-select: none;
}
.card-header:hover { background: var(--fill3); }
.card-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--label);
}
.card-count {
  font-size: 13px;
  color: var(--secondary-label);
}
.card-action {
  font-size: 13px;
  color: var(--blue);
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}
.card-action:hover { text-decoration: underline; }

.chevron {
  width: 14px;
  height: 14px;
  color: var(--gray3);
  transition: transform .2s;
  flex-shrink: 0;
}
.chevron.open { transform: rotate(90deg); }
.card-header[aria-expanded="true"] .chevron { transform: rotate(90deg); }

/* ── Task list ── */
.task-list { list-style: none; padding: 0; margin: 0; }

.task-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: .5px solid var(--separator);
  transition: background .1s;
  position: relative;
}
.task-row:last-child { border-bottom: none; }
.task-row:hover { background: var(--fill3); }

/* Circular checkbox */
.task-check {
  width: 20px;
  height: 20px;
  border: 2px solid var(--gray3);
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
  cursor: pointer;
  background: none;
  padding: 0;
}
.task-check:hover { border-color: var(--blue); }
.task-check:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
.task-check.done {
  border-color: var(--green);
  background: var(--green);
}
.task-check.done svg { display: block; }
.task-check svg {
  display: none;
  width: 10px;
  height: 10px;
  color: #fff;
  flex-shrink: 0;
}

/* Task body */
.task-body { flex: 1; min-width: 0; }

.task-description {
  font-size: 14px;
  color: var(--label);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.task-description.done {
  text-decoration: line-through;
  color: var(--secondary-label);
}
.task-description.stale { color: var(--secondary-label); }

.task-notes-preview {
  font-size: 12px;
  color: var(--tertiary-label);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 1px;
}

/* Task meta (tags, due date) */
.task-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.task-tag {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--fill3);
  color: var(--secondary-label);
  text-decoration: none;
}
.task-tag:hover { background: var(--fill2); color: var(--label); text-decoration: none; }

.task-due {
  font-size: 12px;
  color: var(--secondary-label);
  white-space: nowrap;
}
.task-due.overdue { color: var(--red); font-weight: 500; }
.task-due.today   { color: var(--orange); font-weight: 500; }

/* Star indicator */
.task-star {
  width: 16px;
  height: 16px;
  color: var(--yellow);
  flex-shrink: 0;
}
.task-star.empty { color: var(--gray4); }

/* Hover-revealed action buttons */
.task-actions {
  display: none;
  gap: 4px;
  flex-shrink: 0;
}
.task-row:hover .task-actions,
.task-row:focus-within .task-actions { display: flex; }

.task-action-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--secondary-label);
  transition: background .1s, color .1s;
  padding: 0;
  flex-shrink: 0;
}
.task-action-btn:hover { background: var(--fill2); color: var(--blue); }
.task-action-btn.danger:hover { color: var(--red); }
.task-action-btn svg { width: 14px; height: 14px; pointer-events: none; }

/* ── Empty state ── */
.empty-state {
  padding: 40px 20px;
  text-align: center;
}
.empty-state-icon {
  margin: 0 auto 12px;
  width: 44px;
  height: 44px;
  color: var(--gray3);
}
.empty-state-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--secondary-label);
  margin-bottom: 6px;
}
.empty-state-body {
  font-size: 14px;
  color: var(--tertiary-label);
}

/* ── Form panel (right-side add/edit) ── */
.form-panel { width: var(--panel-w); flex-shrink: 0; }

.form-card {
  background: var(--bg2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 16px;
}
.form-card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--label);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-group { margin-bottom: 12px; }

.form-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--secondary-label);
  margin-bottom: 4px;
  display: block;
  text-transform: uppercase;
  letter-spacing: .3px;
}

.form-control {
  width: 100%;
  background: var(--fill3);
  border: .5px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 14px;
  color: var(--label);
  outline: none;
  transition: background .15s, border-color .15s, box-shadow .15s;
  appearance: none;
}
.form-control:focus {
  background: var(--bg2);
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, .15);
}
.form-control::placeholder { color: var(--placeholder); }
.form-control[aria-invalid="true"] {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(255, 59, 48, .15);
}

textarea.form-control { resize: vertical; min-height: 72px; }
select.form-control { background-image: none; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.form-hint {
  font-size: 11px;
  color: var(--tertiary-label);
  margin-top: 3px;
}
.form-error {
  font-size: 11px;
  color: var(--red);
  margin-top: 3px;
}

/* Error summary (Devise / model errors) */
.error-summary {
  background: rgba(255, 59, 48, .08);
  border: .5px solid rgba(255, 59, 48, .3);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 16px;
}
.error-summary-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--red);
  margin-bottom: 6px;
}
.error-summary ul { list-style: none; padding: 0; }
.error-summary li { font-size: 13px; color: var(--red); }

/* Toggle switch */
.toggle-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--secondary-label);
  cursor: pointer;
  margin-bottom: 12px;
}
.toggle {
  width: 34px;
  height: 20px;
  background: var(--gray4);
  border-radius: 10px;
  position: relative;
  transition: background .2s;
  cursor: pointer;
  flex-shrink: 0;
  border: none;
}
.toggle.on, input:checked + .toggle { background: var(--green); }
.toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .2s;
}
.toggle.on::after, input:checked + .toggle::after {
  transform: translateX(14px);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--sf-pro);
  cursor: pointer;
  border: none;
  transition: background .15s, transform .1s;
  text-decoration: none;
  line-height: 1;
}
.btn:active { transform: scale(.98); }
.btn:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn-primary {
  background: var(--blue);
  color: #fff;
}
.btn-primary:hover { background: #0071f3; color: #fff; text-decoration: none; }

.btn-primary--full {
  width: 100%;
  justify-content: center;
}

.btn-secondary {
  background: var(--fill3);
  color: var(--blue);
}
.btn-secondary:hover {
  background: var(--fill2);
  color: var(--blue);
  text-decoration: none;
}

.btn-danger {
  background: rgba(255, 59, 48, .1);
  color: var(--red);
}
.btn-danger:hover {
  background: rgba(255, 59, 48, .18);
  color: var(--red);
  text-decoration: none;
}

.btn-ghost {
  background: none;
  color: var(--secondary-label);
  padding: 6px 10px;
}
.btn-ghost:hover {
  background: var(--fill3);
  color: var(--label);
  text-decoration: none;
}

.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-sm svg { width: 12px; height: 12px; }

/* ── Badge ── */
.badge {
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  border-radius: 10px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
  line-height: 16px;
  display: inline-block;
}
.badge-gray {
  background: var(--gray4);
  color: var(--secondary-label);
}
.badge-blue {
  background: rgba(0, 122, 255, .12);
  color: var(--blue);
}
.badge-green {
  background: rgba(52, 199, 89, .12);
  color: var(--green);
}
.badge-orange {
  background: rgba(255, 149, 0, .12);
  color: var(--orange);
}

/* ── Segmented control ── */
.segmented {
  display: inline-flex;
  background: var(--fill3);
  border-radius: 9px;
  padding: 2px;
  gap: 2px;
  margin-bottom: 20px;
}
.seg-item {
  padding: 5px 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--secondary-label);
  cursor: pointer;
  transition: all .15s;
  border: none;
  background: none;
  font-family: inherit;
  text-decoration: none;
}
.seg-item:hover { color: var(--label); }
.seg-item.active, .seg-item[aria-selected="true"] {
  background: var(--bg2);
  color: var(--label);
  box-shadow: var(--shadow-sm);
}

/* ── View tabs (underline style) ── */
.view-tabs {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  border-bottom: .5px solid var(--separator);
  overflow-x: auto;
  scrollbar-width: none;
}
.view-tabs::-webkit-scrollbar { display: none; }

.view-tab {
  font-size: 14px;
  font-weight: 500;
  color: var(--secondary-label);
  padding: 8px 4px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all .15s;
  white-space: nowrap;
  text-decoration: none;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  font-family: inherit;
  flex-shrink: 0;
}
.view-tab:hover { color: var(--label); text-decoration: none; }
.view-tab.active, .view-tab[aria-current="page"] {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

/* ── Stats grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg2);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.stat-value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--label);
  line-height: 1;
  margin-bottom: 4px;
}
.stat-label {
  font-size: 12px;
  color: var(--secondary-label);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.stat-card.blue   .stat-value { color: var(--blue); }
.stat-card.green  .stat-value { color: var(--green); }
.stat-card.orange .stat-value { color: var(--orange); }
.stat-card.red    .stat-value { color: var(--red); }

/* ── Project row ── */
.project-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: .5px solid var(--separator);
  cursor: pointer;
  transition: background .1s;
  text-decoration: none;
  color: var(--label);
}
.project-row:last-child { border-bottom: none; }
.project-row:hover { background: var(--fill3); text-decoration: none; color: var(--label); }

.project-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.project-action-count {
  font-size: 13px;
  color: var(--secondary-label);
  flex-shrink: 0;
}
.project-row-actions {
  display: none;
  gap: 4px;
  flex-shrink: 0;
}
.project-row:hover .project-row-actions,
.project-row:focus-within .project-row-actions { display: flex; }

/* ── Context row ── */
.context-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: .5px solid var(--separator);
  transition: background .1s;
  text-decoration: none;
  color: var(--label);
}
.context-row:last-child { border-bottom: none; }
.context-row:hover {
  background: var(--fill3);
  text-decoration: none;
  color: var(--label);
}
.context-name { flex: 1; font-size: 14px; }
.context-count { font-size: 13px; color: var(--secondary-label); }
.context-state-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--fill3);
  color: var(--secondary-label);
}

/* ── Flash messages ── */
.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 500;
  animation: flash-in .25s ease both;
}
.flash__icon { width: 16px; height: 16px; flex-shrink: 0; }
.flash__message { flex: 1; }
.flash__dismiss {
  background: none;
  border: none;
  cursor: pointer;
  opacity: .6;
  padding: 2px;
  border-radius: 4px;
  display: flex;
  align-items: center;
}
.flash__dismiss:hover { opacity: 1; }
.flash__dismiss svg { width: 14px; height: 14px; }
.flash--success { background: rgba(52, 199, 89, .12); color: #1a7a3a; }
.flash--danger  { background: rgba(255, 59, 48, .10); color: #c0392b; }
.flash--info    { background: rgba(0, 122, 255, .10); color: var(--blue); }
.flash--warning { background: rgba(255, 149, 0, .10); color: #c87100; }
[data-theme="dark"] .flash--success { color: var(--green); }
[data-theme="dark"] .flash--danger  { color: var(--red); }
[data-theme="dark"] .flash--warning { color: var(--orange); }

/* ── Login / auth card ── */
.auth-card {
  background: var(--bg2);
  border-radius: var(--radius-xl);
  padding: 40px 36px;
  width: 340px;
  box-shadow: var(--shadow-lg), 0 0 0 .5px var(--separator);
  text-align: center;
}
.auth-logo {
  width: 64px;
  height: 64px;
  background: linear-gradient(145deg, #FF453A, #C0392B);
  border-radius: 16px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(192, 57, 43, .35);
}
.auth-logo svg { width: 32px; height: 32px; color: #fff; }
.auth-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.4px;
  margin-bottom: 6px;
}
.auth-subtitle {
  font-size: 14px;
  color: var(--secondary-label);
  margin-bottom: 28px;
}
.auth-footer {
  margin-top: 20px;
  font-size: 13px;
  color: var(--secondary-label);
}

/* ── Pagy pagination ── */
.pagy-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  padding: 20px 0;
}
.pagy-nav a, .pagy-nav span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--secondary-label);
  text-decoration: none;
  transition: background .1s, color .1s;
}
.pagy-nav a:hover { background: var(--fill3); color: var(--label); }
.pagy-nav .current {
  background: var(--blue);
  color: #fff;
}
.pagy-nav .disabled { opacity: .35; pointer-events: none; }

/* ── Tickler date section header ── */
.tickler-section-header {
  font-size: 11px;
  font-weight: 600;
  color: var(--secondary-label);
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 8px 16px 4px;
}

/* ── Defer popover / date picker row ── */
.defer-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--grouped-bg2);
  border-top: .5px solid var(--separator);
}
.defer-form .form-control { flex: 1; }

/* ── Project show page ── */
.card--padded { padding: 16px; }
.form-card--spaced { margin-top: 12px; }
.notes-section-title { padding: 16px 0 8px; }
.note-body {
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
}
.note-meta { margin-top: 8px; }
