* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Inter", "iranyekan", sans-serif;
  list-style: none;
}

:root {
  --primary: #6366f1;
  --primary-light: #eef2ff;
  --danger: #ef4444;
  --bg: #f9fafb;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --radius: 16px;
  --shadow: 0 10px 25px rgba(0, 0, 0, 0.06);
}

body.dark {
  --bg: #0f172a;
  --card: #020617;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --border: #1f2937;
  background: linear-gradient(135deg, #020617, #0f172a);
}

body {
  min-height: 100vh;
  background: linear-gradient(135deg, #eef2ff, #f9fafb);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: background 0.3s ease, color 0.3s ease;
  flex-direction: column;
}

header {
  text-align: center;
  margin-bottom: 1.5rem;
  position: relative;
  flex-direction: row;
  display: flex;
  margin-top: 1.5rem;
}

header h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  margin-right: 1rem;
}

.theme-toggle {
  /* position: absolute; */
  top: -0.5rem;
  right: -0.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 50%;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  font-size: 1rem;
  transition: 0.2s ease;
  margin-left: 1rem;
  align-self: center;
}

.theme-toggle:hover {
  transform: scale(1.1);
}

.container {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.form-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.todo-form {
  display: flex;
  align-items: center;
  background: var(--bg);
  border-radius: 12px;
  padding: 0.25rem;
  border: 1px solid var(--border);
}

.todo-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  color: var(--text);
}

.todo-input::placeholder {
  color: var(--muted);
}

.add-todo {
  background: var(--primary);
  border: none;
  color: white;
  padding: 0.6rem 0.9rem;
  border-radius: 10px;
  cursor: pointer;
  transition: 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.add-todo:hover {
  background: #4f46e5;
  transform: translateY(-1px);
}

.controls {
  display: flex;
  gap: 0.5rem;
}

.select {
  position: relative;
  flex: 1;
}

.select select {
  width: 100%;
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.65rem 1rem;
  background: var(--bg);
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

.select::after {
  content: "▾";
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--primary);
  pointer-events: none;
}

.clear-completed {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--danger);
  border-radius: 12px;
  padding: 0.65rem 0.9rem;
  cursor: pointer;
  font-weight: 600;
  transition: 0.2s ease;
}

.clear-completed:hover {
  background: rgba(239, 68, 68, 0.1);
}

.todo-container {
  margin-top: 1rem;
}

.todolist {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.todo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  transition: 0.25s ease;
  animation: fadeIn 0.25s ease forwards;
}

.todo:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.05);
}

.todo__title {
  flex: 1;
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
}

.todo__createdAt {
  font-size: 0.75rem;
  color: var(--muted);
  margin-right: 0.5rem;
  white-space: nowrap;
}

.theme-toggle i {
  color: var(--primary);
  font-size: 1.1rem;
  transition: 0.2s ease;
}

.theme-toggle:hover i {
  transform: rotate(15deg) scale(1.1);
}

.todo button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  transition: 0.2s ease;
  display: flex;
  align-items: center;
}

.todo button:hover {
  transform: scale(1.15);
}

.todo__check i {
  color: var(--primary);
}

.todo__remove i {
  color: var(--danger);
}

.completed {
  text-decoration: line-through;
  opacity: 0.55;
}

.footer {
  margin-top: 1rem;
  text-align: center;
}

.task-counter {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mobile polish */
@media (max-width: 480px) {
  .container {
    margin: 1rem;
    padding: 1.25rem;
  }

  header h1 {
    font-size: 1.75rem;
  }

  .controls {
    flex-direction: column;
  }
}
.todo.dragging {
  opacity: 0.5;
  background: var(--primary-light);
  border: 2px dashed var(--primary);
}

.todo__edit i {
  color: #10b981;
}
