*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: sans-serif;
  background: #f5f5f5;
  color: #222;
  min-height: 100vh;
}

.page {
  display: flex;
  justify-content: center;
  padding: 2rem 1rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

/* Card */
article {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 1.5rem;
  width: 100%;
  max-width: 480px;
  position: relative;
  overflow: hidden;
}

article.completed {
  opacity: 0.6;
}

#view-mode,
#edit-mode {
  padding-left: 10px;
}

.priority-indicator {
  position: absolute;
  top: 0;
  left: 0;
  width: 5px;
  height: 100%;
  border-radius: 10px 0 0 10px;
  transition: background 0.2s;
  background: #c0392b;
}

/* Header row */
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 1rem;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  flex: 1;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 3px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: #5046e5;
}

input[type="checkbox"]:focus {
  outline: 2px solid #5046e5;
  outline-offset: 2px;
}

h2 {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
}

h2.struck {
  text-decoration: line-through;
  color: #999;
}

/* Description */
p {
  font-size: 14px;
  color: #555;
  line-height: 1.6;
  margin-bottom: 0.5rem;
}

/* Meta row (due date + time remaining) */
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 1rem;
}

time {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid #ddd;
  background: #f9f9f9;
  color: #555;
}

time#time-remaining.overdue {
  background: #fff0f0;
  color: #c0392b;
  border-color: #f5c6c6;
}

time#time-remaining.soon {
  background: #fffbea;
  color: #92620a;
  border-color: #f5e0a0;
}

time#time-remaining.ok {
  background: #f0fff4;
  color: #276749;
  border-color: #9ae6b4;
}

/* Footer row */
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 36px;
  margin-bottom: 1rem;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Badges */
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
  border: 1px solid transparent;
}

.priority-high {
  background: #fff0f0;
  color: #c0392b;
  border-color: #f5c6c6;
}

.priority-medium {
  background: #fffbea;
  color: #92620a;
  border-color: #f5e0a0;
}

.priority-low {
  background: #f0fff4;
  color: #276749;
  border-color: #9ae6b4;
}

.status-progress {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.status-done {
  background: #f0fff4;
  color: #276749;
  border-color: #9ae6b4;
}

.status-pending {
  background: #f9f9f9;
  color: #555;
  border-color: #ddd;
}

/* overdue indicator badge */
#overdue-indicator {
  color: #c0392b;
  font-weight: 600;
  /* margin-left: 6px; */
  display: none;
}

#overdue-indicator.visible {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
  background: #fff0f0;
  color: #c0392b;
  border: 1px solid #f5c6c6;
  margin-bottom: 0.75rem;
}

/* Action buttons */
.actions {
  display: flex;
  gap: 8px;
}

button {
  font-size: 12px;
  padding: 5px 14px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: transparent;
  color: #555;
  cursor: pointer;
}

button:hover {
  background: #f5f5f5;
  color: #222;
}

button[data-testid="test-todo-delete-button"]:hover {
  background: #fff0f0;
  color: #c0392b;
  border-color: #f5c6c6;
}

button:focus {
  outline: 2px solid #5046e5;
  outline-offset: 2px;
}

/* Tags */
ul {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  padding-top: 1rem;
  border-top: 1px solid #eee;
}

ul li {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 99px;
  border: 1px solid #ddd;
  background: #f5f5f5;
  color: #555;
}

li[data-testid="test-todo-tag-work"] {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

li[data-testid="test-todo-tag-urgent"] {
  background: #fff0f0;
  color: #c0392b;
  border-color: #f5c6c6;
}

li[data-testid="test-todo-tag-design"] {
  background: #fdf4ff;
  color: #7e22ce;
  border-color: #e9d5ff;
}

/* collapsible description */
.collapsible {
  overflow: hidden;
}

.collapsible.collapsed {
  max-height: 3.2em;
  -webkit-mask-image: linear-gradient(to bottom, black 40%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 40%, transparent 100%);
}

.collapsible.expanded {
  max-height: 600px;
  -webkit-mask-image: none;
  mask-image: none;
}

.expand-btn {
  background: none;
  border: none;
  color: #5046e5;
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
  margin-bottom: 1.75rem;
  display: block;
}

.expand-btn:focus {
  outline: none;
}

.expand-btn:hover {
  background: none;
  color: #5146e5ef;
}

/* status select  */
select#status-control {
  font-size: 12px;
  padding: 4px 8px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  color: #222;
  cursor: pointer;
}

select#status-control:focus {
  outline: 2px solid #5046e5;
  outline-offset: 2px;
}

/* edit form  */
#edit-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: #555;
}

.form-group input[type="text"],
.form-group input[type="datetime-local"],
.form-group textarea,
.form-group select {
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  color: #222;
  width: 100%;
  font-family: sans-serif;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: 2px solid #5046e5;
  outline-offset: 2px;
  border-color: #5046e5;
}

.form-group textarea {
  resize: vertical;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
}

.form-actions {
  display: flex;
  gap: 8px;
}

button[data-testid="test-todo-save-button"] {
  font-size: 13px;
  padding: 7px 20px;
  border: none;
  border-radius: 6px;
  background: #5046e5;
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}

button[data-testid="test-todo-save-button"]:hover {
  background: #3730c8;
}
button[data-testid="test-todo-save-button"]:focus {
  outline: 2px solid #5046e5;
  outline-offset: 2px;
}

button[data-testid="test-todo-cancel-button"] {
  font-size: 13px;
  padding: 7px 20px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: transparent;
  color: #555;
  cursor: pointer;
}

button[data-testid="test-todo-cancel-button"]:hover {
  background: #f5f5f5;
}
button[data-testid="test-todo-cancel-button"]:focus {
  outline: 2px solid #5046e5;
  outline-offset: 2px;
}

/* Responsive */
@media (max-width: 480px) {
  article {
    padding: 1.25rem;
  }
  .form-row {
    flex-direction: column;
  }
  .card-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}
